respeaker / get_started_with_respeaker

This is the wiki of ReSpeaker Core V2, ReSpeaker Core and ReSpeaker Mic Array.
260 stars 83 forks source link

Invalid number of channels and no input device available? #209

Closed ocaduacelab closed 6 years ago

ocaduacelab commented 6 years ago

Hi. I have a respeaker V1 and I'm just trying to get the playmusic example file to work. Its saved in the same directory as the mp3, but I'm getting an error and I don't know how to address it:

Expression 'parameters->channelCount <= maxChans' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 1513
Expression 'ValidateParameters( inputParameters, hostApi, StreamDirection_In )' failed in 'src/hostapi/alsa/pa_linux_a
lsa.c', line: 2813
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 763, in run
    self.__target(*self.__args, **self.__kwargs)
  File "playmusic.py", line 16, in task
    mic = Microphone(quit_event=quit_event)
  File "/usr/lib/python2.7/site-packages/respeaker/microphone.py", line 89, in __init__
    input_device_index=self.device_index,
  File "/usr/lib/python2.7/site-packages/pyaudio.py", line 750, in open
    stream = Stream(self, *args, **kwargs)
  File "/usr/lib/python2.7/site-packages/pyaudio.py", line 441, in __init__
    self._stream = pa.open(**arguments)
IOError: [Errno -9998] Invalid number of channels

If I run pyaudio in interactive mode and try to get some basic system info I get:

>>> import pyaudio
>>> pa = pyaudio.PyAudio()
>>> pa.get_default_input_device_info()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/site-packages/pyaudio.py", line 949, in get_default_input_device_info
    device_index = pa.get_default_input_device()
IOError: No Default Input Device Available

Also I've already stopped mopidy

/etc/init.d/mopidy stop

How do I fix this?

Thanks!

xiongyihui commented 6 years ago

@ocaduacelab Cloud you try the following python script to find out where the problem is:

import pyaudio

pyaudio_instance = pyaudio.PyAudio()

print('\navailable devices:')

for i in range(pyaudio_instance.get_device_count()):
    dev = pyaudio_instance.get_device_info_by_index(i)
    name = dev['name'].encode('utf-8')
    print(i, name, dev['maxInputChannels'], dev['maxOutputChannels'])

print('\ndefault input & output device:')
print(pyaudio_instance.get_default_input_device_info())
print(pyaudio_instance.get_default_output_device_info())
KillingJacky commented 6 years ago

Will close this issue, please open a new issue if you have further questions.