1

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?
2
  • In practice what is the question? How to handle errors when importing modules or how to solve your specific issue? Commented Sep 5, 2018 at 22:56
  • you got any solution for this r.recognize_google(audio) ??? i got the same error too. Commented Feb 11, 2019 at 11:53

1 Answer 1

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()
Sign up to request clarification or add additional context in comments.

1 Comment

please don't use blockquotes for regular text.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.