Traceback (most recent call last): File "C:\Users\farha\Desktop\VoicebotRuuh_6_langs_Modified - Copy\chatbot.py", line 188, in exec() File "C:\Users\farha\Desktop\VoicebotRuuh_6_langs_Modified - Copy\chatbot.py", line 121, in exec result = r.recognize_google(audio) File "C:\Python36-32\lib\site-packages\speech_recognition__init__.py", line 859, in recognize_google if not isinstance(actual_result, dict) or len(actual_result.get("alternative", [])) == 0: raise UnknownValueError() speech_recognition.UnknownValueError
This is what I get when I run 'python chatbot.py'
There is an error raised in init.py file which is a file in the python package called speech_recognition, which is imported into chatbot.py.
Following is a snippet of chatbot.py based on this problem.
import speech_recognition as sr
try:
audio = r.record(source, duration = 5)
#print("Done")
except:
exec()
- I guess this is not working because the error is raised in the imported python package file but not in the main file (chatbot.py)
- How do I handle this error?
1 Answer 1
use the error as an exception!
import speech_recognition as sr
try:
audio = r.record(source, duration = 5)
#print("Done")
except sr.UnknownValueError:
exec()
-
please don't use blockquotes for regular text.jrswgtr– jrswgtr09/07/2018 12:03:30Commented Sep 7, 2018 at 12:03
r.recognize_google(audio)
??? i got the same error too.