Google 语音识别模块在我试用时抛出错误
Google Speech Recognition module throws error when I try it out
我正在做一个项目,我需要从我的内置麦克风获取输入并在 Python 中处理它。输入将是一个命令,如 "right"、"left"、"forward" 等
我找到了语音识别库 here。
当我 运行 命令 python -m speech_recognition
时,我得到以下输出:
A moment of silence, please...
ALSA lib pcm_dsnoop.c:614:(snd_pcm_dsnoop_open) unable to open slave
ALSA lib pcm_dmix.c:1024:(snd_pcm_dmix_open) unable to open slave
ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm_dmix.c:1024:(snd_pcm_dmix_open) unable to open slave
Cannot lock down 82274202 byte memory area (Cannot allocate memory)
Set minimum energy threshold to 48.5477227879
Say something!
ALSA lib pcm_dsnoop.c:614:(snd_pcm_dsnoop_open) unable to open slave
ALSA lib pcm_dmix.c:1024:(snd_pcm_dmix_open) unable to open slave
ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm_dmix.c:1024:(snd_pcm_dmix_open) unable to open slave
Traceback (most recent call last):
File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/usr/local/lib/python2.7/dist-packages/speech_recognition /__main__.py", line 12, in <module>
with m as source: audio = r.listen(source)
File "/usr/local/lib/python2.7/dist-packages/speech_recognition/__init__.py", line 377, in listen
buffer = source.stream.read(source.CHUNK, exception_on_overflow = False)
TypeError: read() got an unexpected keyword argument 'exception_on_overflow'
这个错误说明你的pyaudio太旧了。 speech_recognition 模块需要来自 PyAudio 0.2.9 的最新 API,您的版本较旧。升级 Pyaudio,错误就会消失。
我正在做一个项目,我需要从我的内置麦克风获取输入并在 Python 中处理它。输入将是一个命令,如 "right"、"left"、"forward" 等
我找到了语音识别库 here。
当我 运行 命令 python -m speech_recognition
时,我得到以下输出:
A moment of silence, please...
ALSA lib pcm_dsnoop.c:614:(snd_pcm_dsnoop_open) unable to open slave
ALSA lib pcm_dmix.c:1024:(snd_pcm_dmix_open) unable to open slave
ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm_dmix.c:1024:(snd_pcm_dmix_open) unable to open slave
Cannot lock down 82274202 byte memory area (Cannot allocate memory)
Set minimum energy threshold to 48.5477227879
Say something!
ALSA lib pcm_dsnoop.c:614:(snd_pcm_dsnoop_open) unable to open slave
ALSA lib pcm_dmix.c:1024:(snd_pcm_dmix_open) unable to open slave
ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm_dmix.c:1024:(snd_pcm_dmix_open) unable to open slave
Traceback (most recent call last):
File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/usr/local/lib/python2.7/dist-packages/speech_recognition /__main__.py", line 12, in <module>
with m as source: audio = r.listen(source)
File "/usr/local/lib/python2.7/dist-packages/speech_recognition/__init__.py", line 377, in listen
buffer = source.stream.read(source.CHUNK, exception_on_overflow = False)
TypeError: read() got an unexpected keyword argument 'exception_on_overflow'
这个错误说明你的pyaudio太旧了。 speech_recognition 模块需要来自 PyAudio 0.2.9 的最新 API,您的版本较旧。升级 Pyaudio,错误就会消失。