speech_recognition.UnknownValueError - 谁能给我解释一下这个错误

speech_recognition.UnknownValueError - Can someone explain this error to me

我不太确定这个问题的标题是什么,所以如果无法理解,我很抱歉。我最近一直在做的这个项目是一个 Jarvis-related 项目 (Python),这是我的错误

Traceback (most recent call last):
File "C:\Users\Admin\Rohan_Python\Virtual Assistant.py", line 13, in <module>
text = recog.recognize_google(sound)
File "D:\Rohan_Python\lib\site-packages\speech_recognition\__init__.py", line 858, in 
recognize_google
if not isinstance(actual_result, dict) or len(actual_result.get("alternative", [])) == 0: raise 
UnknownValueError()
speech_recognition.UnknownValueError

我的代码...

             import pyttsx3 as py
             import speech_recognition as sr
             # initializing speech_recognition
             engine = py.init()
             engine.say("Hey there! I'm Trevor. A virtual assistant for 
             programmers.")
             engine.runAndWait()
             recog = sr.Recognizer()
             with sr.Microphone() as Sound_source:
             recog.energy_threshold = 10000
             recog.adjust_for_ambient_noise(Sound_source, 1.2)
             print("Listening...")
             sound = recog.listen(Sound_source)
             text = recog.recognize_google(sound)
             print(text)

我认为这可能是一个简单的错误,但有人可以解释错误的含义以及我的错误是什么吗?也给我解决方案。请谢谢!

识别失败。您应该捕获该错误:

try:
    text = recog.recognize_google(sound)
    print(text)
except sr.UnknownValueError:
    print("Could not understand")