python - 语音识别python代码不起作用

标签 python speech-recognition

我在安装了 pyAudio 的 Python 2.7 中运行以下代码。

import speech_recognition as sr
r = sr.Recognizer()
with sr.Microphone() as source:                # use the default microphone as the audio source
    audio = r.listen(source)                   # listen for the first phrase and extract it into audio data

try:
    print("You said " + r.recognize(audio))    # recognize speech using Google Speech Recognition
except LookupError:                           # speech is unintelligible
    print("Could not understand audio")

输出给出了一个闪烁的指针。就是这样。

最佳答案

可能的原因可能是 recognizer_instance.energy_threshold 属性设置的值可能太高而无法开始。您应该降低此阈值,或调用 recognizer_instance.adjust_for_ambient_noise(source, duration = 1)。您可以在 Speech Recognition 了解更多信息

关于python - 语音识别python代码不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32005310/

相关文章:

python - 无法在 python 中读取 .wav 文件

python - 从 Cython 访问 Fortran 公共(public)变量

python - pyparsing:组合多个元素的setResultsName

python - 函数参数的可变性

Python时间测量函数

android - Recognition Listener 不听

python - python字符串中的单引号和双引号

ios - Swift SFSpeechRecognizer 无法工作两次

delphi - 如何在Delphi2009+Vista中创建一个简单的听写板

machine-learning - 语音识别方面有现有的研究可以区分不同人的声音吗?