ALSA lib pcm_hw.c:1667:(_snd_pcm_hw_open) Invalid value for card arecord: main:722: audio open error: No such file or directory

Aaditya Ura picture Aaditya Ura · Feb 14, 2016 · Viewed 15.8k times · Source

i am working on speech recognition . for this i am using "alsa-utils" but when i try to use this script

    #!/bin/bash

echo “Recording… Press Ctrl+C to Stop.”
arecord -D plughw:1,0 -q -f cd -t wav | ffmpeg -loglevel panic -y -i – -ar 16000 -acodec flac file.flac > /dev/null 2>&1

echo “Processing…”
wget -q -U “Mozilla/5.0” –post-file file.flac –header “Content-Type: audio/x-flac; rate=16000” -O – “http://www.google.com/speech-api/v1/recognize?lang=en-us&client=chromium” | cut -d” -f12 >stt.txt

echo -n “You Said: ”
cat stt.txt

rm file.flac > /dev/null 2>&1

i am getting this error

    “Recording… Press Ctrl+C to Stop.”
ALSA lib pcm_hw.c:1667:(_snd_pcm_hw_open) Invalid value for card
arecord: main:722: audio open error: No such file or directory
“Processing…”

please help :(

Answer

jamieguinan picture jamieguinan · Feb 15, 2016

From the pastebin I see card 0 then device 0 or device 1, so try lining up the arecord command with card,device in that order like one of these,

arecord -D plughw:0,0 -q -f cd -t wav | ...
arecord -D plughw:0,1 -q -f cd -t wav | ...