2024-09-24 09:55:23 +02:00
|
|
|
import speech_recognition as sr
|
|
|
|
|
|
|
|
|
|
|
|
class VoiceRecognition:
|
|
|
|
@staticmethod
|
|
|
|
def basic_recognition(audio, option):
|
|
|
|
r = sr.Recognizer()
|
|
|
|
if option == "online":
|
|
|
|
return r.recognize_google_cloud(audio)
|
2024-09-24 10:36:12 +02:00
|
|
|
elif option == "offline":
|
2024-09-24 09:55:23 +02:00
|
|
|
return r.recognize_sphinx(audio)
|
2024-09-24 10:36:12 +02:00
|
|
|
|
|
|
|
return False
|