2011-01-12 78 views
3

我在Python 2.6.6下運行PyAudio,並希望它使用ALSA而不是JACK。PyAudio試圖使用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 
+0

如果你從終端手動運行JACK,通過`jackstart`發生什麼呢?如果您更喜歡圖形用戶界面,您也可以使用http://qjackctl.sourceforge.net/來控制JACK守護進程。無論如何,發佈守護進程的啓動輸出。 – 2011-01-12 20:23:19

+0

從[http://people.csail.mit.edu/hubert/pyaudio/docs/](http://people.csail.mit.edu/hubert/pyaudio/docs/)處的文檔,我想你會需要將`pyaudio.paALSA`傳遞給`pa.open()`,而不是依靠系統來選擇。 – ldrumm 2013-05-21 01:41:01

回答

5

對於那些誰碰巧通過谷歌發現自己在這個老問題:

通過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