cmusphinx / pocketsphinx

A small speech recognizer
Other
3.92k stars 716 forks source link

continuous.c invalid argument #112

Closed highvoltage379 closed 6 years ago

highvoltage379 commented 6 years ago

Hi,

I'm not sure if it's related to issues with pulse audio, but I have a strange error with "continuous.c". I want to do live speech recognition with a ReSpeaker far-field Mic Aray, so I'm using this command:

sudo pocketsphinx_continuous -adcdev plughw:1,0-dict fr.dic -hmm ./cmusphinx-fr-5.2 -lm ./fr-phone.lm.dmp -inmic yes

But I get this error: Error opening audio device plughw:1,0 for capture: Invalid argument FATAL: "continuous.c", line 245: Failed to open audio device

I know the device name is right, because I can record wav with this command: arecord -v -D plughw:1,0 -f S16_LE -r 16000 -c 1 audio-test.wav

I don't have any problem when I'm using built-in microphone.

Am I missing something ? Thank you in advance !

nshmyrev commented 6 years ago

Device names depend on the audio library that pocketsphinx uses

https://cmusphinx.github.io/wiki/faq/#q-failed-to-open-audio-devicedevdsp-no-such-file-or-directory

highvoltage379 commented 6 years ago

Okay, but how could I know which library pocketsphinx is using ?

For others users, this command list the device names : pacmd list-sources | grep -e device.string -e 'name:'

(from https://wiki.archlinux.org/index.php/PulseAudio/Examples#Set_default_input_sources)

highvoltage379 commented 6 years ago

If I understood correctly, this command is supposed to give the devices name, depending on pulse audio: pacmd list-sources | grep -e device.string -e 'name:'

I got: name: device.string = "2" name: device.string = "1" name: device.string = "front:1" name: device.string = "0" name: device.string = "front:0"

If I do cat /proc/asound/cards, I get : 0 [PCH ]: HDA-Intel - HDA Intel PCH HDA Intel PCH at 0xc3110000 irq 30 1 [UAC20 ]: USB-Audio - ReSpeaker MicArray UAC2.0 SeeedStudio ReSpeaker MicArray UAC2.0 at usb-0000:00:14.0-1, full speed 2 [HDMI ]: HDA-Intel - HDA ATI HDMI HDA ATI HDMI at 0xc2020000 irq 31

So my guess is the device name I have to use is either "front:1" either "plughw1,0". But none of them are working. I really don't understand why.

highvoltage379 commented 6 years ago

I double checked, and I'm definitely using PulseAudio for cross-compilation. So, the device name should be plughw:1,0 or hw:1,0.

By the way, the python script found here (https://github.com/respeaker/respeaker_python_library), it says: INFO:mic:Use ReSpeaker MicArray UAC2.0: USB Audio (hw:1,0) And the speech recognition is working.

More and more confusing...

nshmyrev commented 6 years ago

Okay, but how could I know which library pocketsphinx is using ?

You can use ldd to check the dependent libraries:

   ldd /usr/local/bin/pocketsphinx_continuous

Alsa device names like hw:1,0 might not be supported in pulseaudio. In pulseaudio you can set any device as a source and just use defaults for adcdev.