简体   繁体   English

PyAudio无法在Ubuntu 14.04上使用“无法打开奴隶”的麦克风

[英]PyAudio cannot use microphone on Ubuntu 14.04 with 'unable to open slave'

I have tried several days to use microphone on my ubuntu 14.04 with PyAudio. 我已经尝试了几天在我的ubuntu 14.04和PyAudio上使用麦克风。 Actually I want to use ' Speech Recognition ' package in the github. 其实我想在github中使用' Speech Recognition '包。

I find it uses pyaudio internal, and It is nightmare on ubuntu 14.04. 我发现它使用pyaudio内部,它是ubuntu 14.04的噩梦。 It shows the following error message and cannot recognize my voice from microphone: 它显示以下错误消息,无法从麦克风识别我的声音:

ALSA lib pcm_dsnoop.c:618:(snd_pcm_dsnoop_open) unable to open slave
ALSA lib pcm_dmix.c:1022:(snd_pcm_dmix_open) unable to open slave
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm_dmix.c:1022:(snd_pcm_dmix_open) unable to open slave

I find several similar posts on the websites, and there is no solution about this. 我在网站上发现了几个类似的帖子,但没有解决方案。 I cannot record my voice through microphone, it just stucks there. 我无法通过麦克风录制我的声音,它只是卡在那里。 Anyone run it successfully on ubuntu 14.04 ? 有人在ubuntu 14.04上成功运行吗? (PyAudio to record the voice or Speech Recognition ) (PyAudio录制语音或语音识别

I don't know if this also solves your problem, but in my case the HDMI-sound-devices and pulse came in the way (also Ubuntu 14.04). 我不知道这是否也解决了你的问题,但在我的情况下,HDMI声音设备和脉冲阻碍了(也是Ubuntu 14.04)。 Since the indices of the devices seem to change, I came up with this little script that enumerates all available devices and gives me the index of the pulse-device (you may need another device, eg if you have a usb-mic or s.th.): 由于设备的索引似乎发生了变化,我想出了这个小脚本,它列举了所有可用的设备并给了我脉冲设备的索引(你可能需要另一个设备,例如,如果你有一个usb-mic或s。日):

import pyaudio
pa = pyaudio.PyAudio()
chosen_device_index = -1
for x in xrange(0,pa.get_device_count()):
    info = pa.get_device_info_by_index(x)
    print pa.get_device_info_by_index(x)
    if info["name"] == "pulse":
        chosen_device_index = info["index"]
        print "Chosen index: ", chosen_device_index

After that I am able to open the stream: 之后,我可以打开流:

p = pyaudio.PyAudio()
stream = p.open(format=pyaudio.paInt16, channels=1, rate=16000, input_device_index=chosen_device_index, input=True, output=False)
stream.start_stream()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM