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.