我正在尝试制作一个使用语音识别的程序。现在我遇到了一个问题,即您必须按下按钮或 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))
提前致谢!
烙印99
相关分类