这是脚本的全部内容
def MyCommand():
#init recongnize voice
r = sr.Recongnize()
r.pause_thershold = 3
#threshold = one second, waiting to adjust threshold dependent on noise levels
r.adjust_for_ambient_noise(source, duraiton=3)
audio = r.listen(source)
try:
command = r.recognize_google(audio).lower()
print('you said:' + command + '\n')
#loopback to continue to listen for commands if unrecognized speech is received
except sr.UnknownValueError:
print('I did not hear that')
command = myCommand();
return command
while True:
assistant(myCommand())
else:
error = random.choice(error)
talk(error)
为什么它不能让我把它放进去,我尝试删除并重新安装SR模块,但是没有运气。我试图在网上找到一些东西,但是没有什么确切的信息可以打破这个问题,我发现的大多数事情都与实际的SR模块有关。