【问题标题】:Python speech to text using speechrecognition使用语音识别的 Python 语音到文本
【发布时间】: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


    【解决方案1】:

    你可以在 GitHub 上试试这个code。

    【讨论】:

      【解决方案2】:

      尝试替换

      audio=r.listen(source)
      

      到

      audio=r.record(source, duration=4)
      

      您可以更改持续时间的值。

      让我知道它是否有效:)

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2023-03-03
        • 2016-12-04
        • 2021-09-07
        • 1970-01-01
        • 1970-01-01
        • 2018-02-23
        相关资源
        最近更新 更多