1

I am using a raspberry pi model B with a Logitech USB Microphone, and I have python version 2.7.3 and a new install of pyaudio version 0.2.8. When I try and run the record.py file located in the test folder provided when pyaudio was downloaded, I get this error

 ALSA lib pcm_dmix.c:957:(snd_pcm_dmix_open) The dmix plugin supports only playback stream
Expression 'parameters->channelCount <= maxChans' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 1438
Expression 'ValidateParameters( inputParameters, hostApi, StreamDirection_In )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2742
Traceback (most recent call last):
 File "record.py", line 26, in <module>
 frames_per_buffer=CHUNK)
 File "/usr/local/lib/python2.7/dist-packages/pyaudio.py", line 747, in open
 stream = Stream(self, *args, **kwargs)
 File "/usr/local/lib/python2.7/dist-packages/pyaudio.py", line 442, in __init__
 self._stream = pa.open(**arguments)
IOError: [Errno Invalid number of channels] -9998

I was not able to find any working answers on google.

Any help would be greatly appricated.

asked Jun 11, 2015 at 14:52

2 Answers 2

2

Indeed the question do not provide relevant details. Anyway, I walked with similar issue and I just realize that the problem, at least for me, was that I was using the wrong (nonexistent, default) device. So I just passed the device index as the argument of the open call:

stream = p.open(format=FORMAT,input_device_index = INDEX,
 channels=CHANNELS,
 rate=RATE,
 input=True,
 frames_per_buffer=CHUNK)

Where INDEX is 2 for me. I have obtained this index listing the devices with:

for i in range(p.get_device_count()):
 print(p.get_device_info_by_index(i))

Remember to import and initialize the pyaudio before run the previous code:

import pyaudio
p = pyaudio.PyAudio()

If you have problems like "jack server is not running or cannot be started" just manually start the jackd:

jackd -r -m -p 8 -d dummy
answered Apr 19, 2017 at 3:25
0

In the pyaudio code there is CHANNELS = 2 this is used for recording the sound stream = p.open(format=FORMAT,channels=CHANNELS,rate=RATE,input=True,frames_per_buffer=CHUNK), by changing this to CHANNELS = 1 it started working and recording audio

answered Jun 11, 2015 at 18:39

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.