I am trying to write a speech recognition code which takes voice from the microphone and process till a "Stop" is said. The code works for the first voice but then it gives an error. The code which I wrote is below:
import speech_recognition as sr
import webbrowser
r = sr.Recognizer()
with sr.Microphone() as source:
while True:
audio = r.listen(source)
print("You said " + r.recognize(audio))
if r.recognize(audio)=="Facebook":
webbrowser.open('https://www.facebook.com')
if r.recognize(audio)=="Google":
webbrowser.open('https://www.google.co.uk')
if r.recognize(audio)=="Stop":
break
The error which I am getting is :
You said Facebook
Traceback (most recent call last):
File "C:/Work/Scripts/SpeechRecognition/Speech.py", line 9, in <module>
print("You said " + r.recognize(audio)) # listen for the first phrase and extract it into audio data
File "C:\Users\roradhak.NDS-UK\AppData\Roaming\Python\Python27\site-packages\speech_recognition\__init__.py", line 324, in recognize
raise LookupError("Speech is unintelligible")
LookupError: Speech is unintelligible
Process finished with exit code 1