我正试着做一条巨蟒人工智能。使用speech_recognition
模块,我想在AI中添加一个热词检测功能,所以我尝试使用speech_recognition
鼠标来实现它,但是它没有工作,因为它每4到5秒听一次,然后开始识别所讲的内容,因此,如果我在hotword
开始识别4到5秒之后,它就不识别hotword
了
请任何人都能帮我解决这个问题
发布于 2021-02-22 22:35:08
使用pause_threshold
类
import speech_recognition as sr
hot_word='Hi'
r=sr.Recognizer()
r.pause_threshold=5#This waits for 5 sec after voice ends
with sr.Microphone() as source:
text=r.listen(source)
text=r.recognize_google(text)
if hot_word in text:
#do anything like calling a function or reply to it
谢谢
祝你今天愉快
-Lever
https://stackoverflow.com/questions/66327876
复制