offilne speech recogintion

This commit is contained in:
Sandro Zimmermann 2025-12-06 13:47:19 +01:00
parent a730fbb2f5
commit 1b6ea0cded

View File

@ -2,12 +2,10 @@ import speech_recognition as sr
recognizer = sr.Recognizer() recognizer = sr.Recognizer()
with sr.Microphone() as source: with sr.Microphone() as source:
print("Speak something...") print("Say something...")
audio = recognizer.listen(source) audio = recognizer.listen(source)
try: try:
text = recognizer.recognize_google(audio) text = recognizer.recognize_sphinx(audio)
print("You said: {}".format(text)) print("Sphinx recognized: {}".format(text))
except sr.UnknownValueError: except sr.UnknownValueError:
print("Could not understand audio.") print("Could not understand audio.")
except sr.RequestError as e:
print("Error with API: {}".format(e))