我正在尝试制作一个使用语音识别的程序。现在我遇到了一个问题,即您必须按下按钮或 Enter 才能启动语音识别。有没有办法让你说出一个短语(有点像 Hey Google),它开始在 Python 3 中识别语音?这是我的代码:录制音频代码:r = sr.Recognizer()with sr.Microphone() as source: audio = r.listen(source)x = r.recognize_google(audio)print("I'm listening!")try: print("You said: " + r.recognize_google(audio))except speech_recognition.UnknownValueError: print("I am sorry but I couldn't understand you, try again.")except speech_recognition.RequestError as e: print("Could not request results from Google Speech Recognition service; {0}".format(e))提前致谢!
2 回答
烙印99
TA贡献1829条经验 获得超13个赞
代码:
from pocketsphinx import LiveSpeech
import os
for i in LiveSpeech():
print(i)
if "hey Google" in str(i):
os.startfile("Your File.your_format")
#works Perfectly and if you want to hide python console then save as youfile.pyw
添加回答
举报
0/150
提交
取消