PyAudio 在 Raspberry Pi 上引发警告

Posted

技术标签:

【中文标题】PyAudio 在 Raspberry Pi 上引发警告【英文标题】:PyAudio throws warnings on Raspberry Pi 【发布时间】:2019-03-26 09:37:11 【问题描述】:

由于我在较早的帖子和其他论坛中都找不到我的问题的答案,因此我想向 *** 社区寻求建议。

我正在使用内核版本 4.14.71-v7 的树莓派版本 9(拉伸)。 它应该是可用的最新图像。

我想使用 pyaudio 来播放和录制音频流。在我的 Windows 家用电脑上,一切正常,没有任何问题。但即使在树莓派上创建一个 pyaudio 对象也会引发一些奇怪的警告。

首先我安装了以下东西来使用pyaudio:

    sudo apt-get install libasound-dev

树莓派自动选择 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不使用portaudio。 但我不确定。

也许有人知道,为什么只创建一个对象就会引发这些警告。 在这些警告旁边,pyaudio 库似乎可以工作。我可以播放 并录制音频流,但每次都会出现这些警告。

【问题讨论】:

见***.com/q/36956083和***.com/q/7088672。 这能回答你的问题吗? PyAudio working, but spits out error messages each time 【参考方案1】:

感谢 *** 社区。我有一个旧主题的链接,它提供了完美的解决方案。

主题名称:“PyAudio 工作,但每次都吐出错误消息”

解释了所有这些警告出现的原因以及如何用python处理它们。

非常感谢!!!

【讨论】:

以上是关于PyAudio 在 Raspberry Pi 上引发警告的主要内容,如果未能解决你的问题,请参考以下文章

树莓派(Raspberry Pi)4B无界面安装 Raspberry Pi 系统篇

树莓派(Raspberry Pi)4B无界面安装 Raspberry Pi 系统篇

在raspberry pi中安装缺少的python包

在树莓派2代B型/3代 上安装Fedora23 - Installing Fedora 23 on Raspberry Pi 2 model B or Raspberry Pi 3

在Raspberry Pi上使用python3进行Bash

并行计算Python / Raspberry Pi