gpt4 book ai didi

python - speech_recognition 模块卡在 "say something"- python

转载 作者:太空宇宙 更新时间:2023-11-04 10:09:30 33 4
gpt4 key购买 nike

我正在尝试用于语音识别的 python 脚本,我已经在我的环境中安装了所需的 pyaudio 和 SpeechRecognition 模块。

程序到昨天还好好的,现在卡在“say something”。下面是我的代码。

import speech_recognition as sr
print "say something1"
r = sr.Recognizer()
print "say something2"
with sr.Microphone() as source: # use the default microphone as the audio source
print "say something3"
audio = r.listen(source,timeout=3) # listen for the first phrase and extract it into audio data

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

控制台 o/p :-

say something1
say something2
ALSA lib pcm_dsnoop.c:606:(snd_pcm_dsnoop_open) unable to open slave
ALSA lib pcm_dmix.c:1029:(snd_pcm_dmix_open) unable to open slave
ALSA lib pcm.c:2266:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2266:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2266:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm_dmix.c:1029:(snd_pcm_dmix_open) unable to open slave
say something3

不重复/已提交给:- speech recognition python code not working

最佳答案

也许这可以解决您的问题。

print "say something2"
with sr.Microphone() as source: # use the default microphone as the audio source
r.adjust_for_ambient_noise(source) # here
print "say something3"
audio = r.listen(source,timeout=3)

看看这个。 https://github.com/Uberi/speech_recognition/issues/191

最后一个解决方案对我有用。希望对你有同样的作用

关于python - speech_recognition 模块卡在 "say something"- python,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39180695/

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