【发布时间】:2020-12-13 22:04:11
【问题描述】:
我正在制作一个 python 脚本,它会听你的声音,然后根据你所说的执行功能。
我刚开始做一个“唤醒词”,代码如下:
while True:
try:
with sr.Microphone() as source1:
SpeakText("one")
r.adjust_for_ambient_noise(source1)
print("Set minimum energy threshold to {}".format(r.energy_threshold))
SpeakText("two")
audio1 = r.listen(source)
SpeakText("three")
MyText = r.recognize_google(audio1)
print(MyText)
SpeakText("four")
MyText = MyText.lower()
if MyText == "oink" or "ink" or "link":
playsound("oink_boop.mp3")
detect_command()
except sr.UnknownValueError:
print("No Speech or No Internet")
现在我放入 SpeakText 部分(使用 pyttsx3)只是出于调试目的,但它说“两个”,然后在 audio1 = r.listen(source) 上听我的演讲时卡住了
它似乎并没有停止听我说话,我什至尝试将麦克风静音,但也没有用。
【问题讨论】:
标签: python speech-recognition voice pyttsx