【发布时间】:2018-11-02 05:03:08
【问题描述】:
我正在制作一个使用语音转文本的软件。我已经阅读了一些文章并在stackoverflow上发表了文章。我试过这个代码-
r = sr.Recognizer()
with sr.Microphone(device_index=1) as source:
r.adjust_for_ambient_noise(source)
print("Speak:")
audio = r.listen(source)
try:
print("You said " + r.recognize_google(audio)+';')
except sr.UnknownValueError:
print("Could not understand audio")
except sr.RequestError as e:
print("Could not request results; {0}".format(e))
在我运行代码后,当它到达这部分时,它进入输入阶段并停止。它什么也不做,tkinter 窗口不响应。看起来像这样。
我尝试了r.recognize_google 和r.recognize_sphinx。我也尝试不使用麦克风索引。我不明白发生了什么。当涉及到r.listen(source) 时,它会停止。谢谢你的建议。
【问题讨论】:
标签: python python-3.x speech-recognition speech-to-text google-speech-api