Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 :(

like image 458
Aaditya Ura Avatar asked Feb 14 '16 21:02

Aaditya Ura


1 Answers

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 | ...
like image 54
jamieguinan Avatar answered Oct 21 '22 15:10

jamieguinan