问题描述
我正在开发一个 Python 助手,首先我让它可以处理文本命令,一切都很顺利。但是当我将其更改为在语音命令上工作时,它的工作很奇怪,虽然代码能够执行但它一直在监听和识别,并执行我没有分配给它执行的命令。
def takeCommand():
r = sr.Recognizer()
with sr.Microphone() as source:
print("Listening...")
r.adjust_for_ambient_noise(source)
audio = r.listen(source)
try:
print('Recognizing...')
query = r.recognize_google(audio,language='en=in')
print("You said : " + query)
except Exception as e:
return "none"
return query
if __name__=='__main__':
while True:
playsound.playsound(os.path.join('soundeffects\sfx',"howcanihelpyouNow.mp3"))
print("\n")
print('Tell Me How Can I Help you Now')
statement = takeCommand()
if statement==0:
continue
elif **THEN A BUNCH OF COMANDS***
这是代码的链接: https://pastebin.com/yPTSCpgp
我欢迎任何建议,我是初学者。 :)
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)