interstellar_ai/py/voice.py
2024-09-24 10:36:12 +02:00

13 lines
329 B
Python

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":
return r.recognize_sphinx(audio)
return False