interstellar_ai/py/voice.py

16 lines
407 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":
2024-09-26 08:33:11 +02:00
with audio as source:
return r.recognize_google_cloud(source)
elif option == "offline":
2024-09-26 08:33:11 +02:00
with audio as source:
return r.recognize_sphinx(source)
return False