我开发了一个新程序来与我的聊天机器人交谈。它工作得很好,但有一个我似乎无法弄清楚的奇怪问题。每次重复该过程(控制台输出监听并进行语音识别)时,它都会变慢。第一次走的很快,第二次走慢,第三走慢,然后它就太慢而无法响应。请帮我弄清楚导致这种情况的语法。
import speech_recognition as sr
r = sr.Recognizer()
with sr.Microphone() as source:
while True:
print("say something")
audio = r.listen(source)
try:
print("Text:"+r.recognize_google(audio, language = 'en-us', show_all=False));
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))