使用下面的代码,虚拟助手将监听命令,但在说“再试一次”后它将停止监听。如何使用唤醒命令“嘿助手”让它再次收听。
def myCommand():
r = sr.Recognizer()
with sr.Microphone() as source:
print("Listening...")
r.pause_threshold = 1
text = r.listen(source)
try:
query = r.recognize_google(text, language='en')
print('User: ' + query + '\n')
except sr.UnknownValueError:
speak('Sorry sir! I didn\'t get that.')
query = str(input('Try again'))
return query