pilight/py/speech.py
2025-12-06 13:47:19 +01:00

12 lines
351 B
Python

import speech_recognition as sr
recognizer = sr.Recognizer()
with sr.Microphone() as source:
print("Say something...")
audio = recognizer.listen(source)
try:
text = recognizer.recognize_sphinx(audio)
print("Sphinx recognized: {}".format(text))
except sr.UnknownValueError:
print("Could not understand audio.")