我正在尝试使用麦克风将语音转换为文本,并在最后打印输出。由于某种原因,它没有检测到任何东西,也没有给我输出。有人可以找出为什么不起作用吗?
我正在使用的代码是
r = sr.Recognizer()
with sr.microphone() as source:
print("Bro say something!")
audio = r.listen(source)
try:
print("You precious words are: " + r.recognize_google(audio))
except sr.UnknownValueError:
print("Google Speech Recognition could not understand audio")
except sr.RequestError as e:
print("Could not request results from Google Speech Recognition service; {0}".format(e))
开始时,麦克风检测到我说的所有内容,但是经过3-4个小时后再次运行时,它不起作用。