0

I am making voice recognition robot using raspberry pi, So I use usb sound card for microphone input. So I set the default sound input output on raspberry pi by changing /etc/asound.conf file to:

pcm.!default {
        type hw card 1
}

ctl.!default {
        type hw card 1
}

So I use the python SpeechRecognition library and requesting microphone by bellow code:

m = sr.Microphone(device_index = 2, sample_rate =44100, chunk_size =512)

The problem is, It works well at the first call. but then I used the same microphone call again, it gives me bellow error message:

Expression 'parameters->channelCount <= maxChans' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 1514
Expression 'ValidateParameters( inputParameters, hostApi, StreamDirection_In )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2818

Can anyone help me to figure out what is going wrong??? Thank you.

Nikolay Shmyrev
  • 24,897
  • 5
  • 43
  • 87
  • Possible duplicate of [ALSA Api: How to play two wave files simultaneously?](https://stackoverflow.com/questions/14398573/alsa-api-how-to-play-two-wave-files-simultaneously) – Nikolay Shmyrev Jun 18 '17 at 08:46
  • You can configure alsa properly to allow parallel access. But overall it is better to open microphone once and avoid opening microphone multiple times. – Nikolay Shmyrev Jun 18 '17 at 08:47

0 Answers0