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

问题描述 投票:0回答:1

我正在尝试使用

speech_recognition
模块制作一个 python AI, 我想在人工智能中添加一个热词检测功能,所以我尝试使用
speech_recognition
模块来实现它,但它不起作用。它在 4 - 5 秒后听了一次,并开始识别所说的内容。因此,如果我在 4-5 秒的时间范围后说出
hotword
,它不会识别
hotword

python speech-recognition
1个回答
2
投票

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

谢谢你
祝你有美好的一天

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.