offilne speech recogintion
This commit is contained in:
parent
a730fbb2f5
commit
1b6ea0cded
@ -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))
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user