I've looked at several tutorials/examples of setting up Speech to Text from command line but I can't figure out what my problem is. This is the example I have followed most closely: Raspberry Pi voice recognition works like Siri, but still can't get things to work.

  1. I set up my Logitech c270 and arecord appears to be working correctly.

    arecord -D "plughw:1,0" -f cd -d 5 -r 16000 -t wav | flac - -f --best --sample-rate 16000 -o file.flac
  2. Instead of using ffmpeg I decided to go with flac to convert my .wav file to .flac, and when I run mplayer file.flac the file sounds good.

  3. When submitting my .flac file using wget I see from my Google Developers Console that it records a successful request, but returns the following json:


Do I have my settings set up properly, or does Google speech API require a specific bit rate?

To further test I downloaded a free .wav file from the following page:

http://www.wavsource.com/snds_2016-01-10_6357263721580594/people/men/about_time.wav (U8 format with 11025 Rate)

...then converted this to flac:

flac about_time.wav -f --best --sample-rate 16000 -o file.flac
wget -U "Mozilla/5.0" --post-file file.flac --header "Content-Type: audio/x-flac; rate=16000" -O - "http://www.google.com/speech-api/v2/recognize?lang=en-us?key=my-key" >stt.txt
echo -n "You Said: "
cat stt.txt

and got the following json file:

{"result":[{"alternative":[{"transcript":"it's about time you got here","confidence":0.96557111},
{"transcript":"it's about time you got it"},
{"transcript":"it's about time you got"},
{"transcript":"it's about time you guys"},
{"transcript":"it's about time you got you"}],

Any ideas where I have gone wrong?


So, I tweaked my settings and for some reason the Google Speech API likes the Unsigned 8bit 11025Hz recording so I changed my code to be the following and now it works:


echo "Recording..."
arecord -D "plughw:1,0" -f U8 -r 11025 -d 5 | flac - -f --best --sample-rate 11025 -o file.flac

echo "Processing..."
wget -U "Mozilla/5.0" --post-file file.flac --header "Content-Type: audio/x-flac; rate=11025" -O - "http://www.google.com/speech-api/v2/recognize?lang=en-us?key=my-key" > stt.txt

echo -n "You Said: "
cat stt.txt
  • I hab the same problem and change the sampling rate didnt worked for me. U have tip? – user46458 May 13 '16 at 12:15
  • I got it working, but it still was returning nothing in the JSON file. I double checked to make sure everything was working correctly, and it turned out that the cheap mic ($10) that I bought was recording, but it was very quiet. I have since bought a new web cam as suggested in some of the tutorials for about $30 and it recorded loud enough for the Google Speech API to translate it. – Mark Nielsen May 13 '16 at 18:36

I have the same problem and solved it by adding -c 1 to arecord, so it uses only one channel. found a hint on another page

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.