由于我在旧帖子或其他论坛中都没有找到问题的答案,我想向stackoverflow社区寻求建议。
我正在使用树莓派,版本 9(拉伸(,内核版本 4.14.71-v7。 它应该是可用的最新映像。
我想使用 pyaudio 进行播放和录制音频流。在我的Windows家用电脑上,一切正常,没有任何麻烦。但是,即使在树莓派上创建一个pyaudio对象也会引发一些奇怪的警告。
首先,我安装了以下东西来使用pyaudio:
sudo apt-get install libasound-dev
Raspberry Pi 自动选择 libasound2-dev
sudo apt-get install portaudio19-dev
sudo apt-get install python3-pyaudio
如果我运行以下python代码:
import pyaudio
py=pyaudio.PyAudio()
我收到以下警告:
'$'ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.bcm2835_alsa.pcm.front.0:CARD=0'
'$'ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
'$'ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
'$'ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM front
'$'ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
'$'ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
'$'ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
'$'ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.bcm2835_alsa.pcm.surround51.0:CARD=0'
'$'ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
'$'ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
'$'ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM surround21
'$'ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.bcm2835_alsa.pcm.surround51.0:CARD=0'
'$'ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
'$'ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
'$'ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM surround21
'$'ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.bcm2835_alsa.pcm.surround40.0:CARD=0'
'$'ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
'$'ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
'$'ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM surround40
'$'ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.bcm2835_alsa.pcm.surround51.0:CARD=0'
'$'ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
'$'ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
'$'ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM surround41
'$'ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.bcm2835_alsa.pcm.surround51.0:CARD=0'
'$'ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
'$'ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
'$'ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM surround50
'$'ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.bcm2835_alsa.pcm.surround51.0:CARD=0'
'$'ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
'$'ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
'$'ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM surround51
'$'ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.bcm2835_alsa.pcm.surround71.0:CARD=0'
'$'ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
'$'ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
'$'ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM surround71
'$'ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.bcm2835_alsa.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2 =0,AES3=2'
'$'ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
'$'ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
'$'ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM iec958
'$'ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.bcm2835_alsa.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2 =0,AES3=2'
'$'ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
'$'ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
'$'ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM spdif
'$'ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.bcm2835_alsa.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2 =0,AES3=2'
'$'ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
'$'ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
'$'ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM spdif
'$'ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
'$'ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
'$'ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
'$'ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
'$'ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
'$'ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
'$'ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'defaults.bluealsa.device'
'$'ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
'$'ALSA lib conf.c:4996:(snd_config_expand) Args evaluate error: No such file or directory
'$'ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM bluealsa
'$'ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'defaults.bluealsa.device'
'$'ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
'$'ALSA lib conf.c:4996:(snd_config_expand) Args evaluate error: No such file or directory
'$'ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM bluealsa
'$'connect(2) call to /tmp/jack-1000/default/jack_0 failed (err=No such file or directory)
'$'attempt to connect to server failed
对我来说,看起来pyaudio想要使用hdmi(带环绕声(,即 杰克和蓝牙(Bluealsa(。似乎pyaudio不使用端口音频。 但我不确定。
也许有人知道,为什么只创建一个对象会引发这些警告。 在这些警告旁边,pyaudio 库似乎可以工作。我可以播放 并录制音频流,但每次都会出现这些警告。
感谢stackoverflow社区。我得到了一个旧主题的链接,它给出了完美的解决方案。
- 主题名称:"PyAudio 工作正常,但每次都吐出错误消息">
解释了所有这些警告发生的原因以及如何使用 python 处理它们。
非常感谢!!