python – PyAudio尝试使用JACK

我在Python 2.6.6下运行PyAudio并希望它使用ALSA而不是JACK.

In [1]: import pyaudio

In [2]: pa = pyaudio.pa

In [3]: pa.initialize()
Cannot connect to server socket err = No such file or directory
Cannot connect to server socket
jack server is not running or cannot be started

解决方法:

对于那些碰巧通过谷歌发现自己处于这个老问题的人:

pyaudio显示的消息……

jack server is not running or cannot be started

……提供信息,而不是错误.这意味着portaudio尝试并且未能连接到Jack,但并不意味着它放弃了所有东西.

此时,您应该使用ALSA拥有一个功能齐全的PyAudio对象.您可以通过查看可用设备列表来验证这一点:

>>> import pyaudio
>>> pa = pyaudio.PyAudio()
[...lots of crap from ALSA...]
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
>>> print '\n'.join([y['name'] 
... for y in [pa.get_device_info_by_index(x)
... for x in range(pa.get_device_count())]])
bcm2835 ALSA: - (hw:0,0)
bcm2835 ALSA: IEC958/HDMI (hw:0,1)
USB Audio Device: - (hw:2,0)
sysdefault
dmix
default
上一篇:linux – ALSA时间戳函数返回什么以及结果如何相互关联?


下一篇:在Linux中获取C中的主音量