如何在 python AI 中添加热词检测

How to add Hotword Detection in python AI

我正在尝试制作一个 python AI。使用 speech_recognition 模块 我想在 AI 中添加热词检测功能,所以我尝试使用 speech_recognition 模块来实现它,但它不起作用,因为它在 4 到 5 秒内听一次并开始识别所说的话,因此如果我说话hotword 在开始识别 4 到 5 秒后无法识别 hotword

请任何人帮助我解决这个问题

使用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

谢谢
祝你有美好的一天
-杠杆