interstellar_ai/py/voice.py

14 lines
329 B
Python
Raw Normal View History

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)
elif option == "offline":
2024-09-24 09:55:23 +02:00
return r.recognize_sphinx(audio)
return False