gpt4 book ai didi

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

转载 作者:太空狗 更新时间:2023-10-29 21:34:02 24 4
gpt4 key购买 nike

我在安装了 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com