问题描述
我在python中有一个正在运行的语音助手,但是目前它一直在监听,我理想地希望它开始听类似于“嘿Google”的唤醒字。
有人可以帮忙吗?
下面的代码段
voices = engine.getProperty('voices')
engine.setProperty('voice',voice_id)
keyword = "jarvis"
r = sr.Recognizer()
def speak(text):
engine.say(text)
engine.runAndWait()
def wishMe():
hour = datetime.datetime.Now().hour
if 0 <= hour < 12:
speak("Hello chris,Good Morning")
print("Hello,Good Morning")
elif 12 <= hour < 18:
speak("Hello chris,Good Afternoon")
print("Hello,Good Afternoon")
else:
speak("Hello chris,Good Evening")
print("Hello,Good Evening")
def takeCommand():
with sr.Microphone() as source:
speak("yes chris...")
r.adjust_for_ambient_noise(source)
audio = r.listen(source,phrase_time_limit=5)
try:
statement = r.recognize_google(audio,language='en-uk')
print(f"user said:{statement}\n")
except Exception as e:
speak("sorry i Couldn't understand")
return "None"
return statement
speak("Loading jarvis")
wishMe()
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)