Skip to content

Instantly share code, notes, and snippets.

@zaclang
Forked from meskarune/speech2text.sh
Created December 16, 2016 07:42
Show Gist options
  • Save zaclang/9a55f08bb25c5a871e09435c44ee921a to your computer and use it in GitHub Desktop.
Save zaclang/9a55f08bb25c5a871e09435c44ee921a to your computer and use it in GitHub Desktop.
speech to text bash script using google's voice recognition api
#!/bin/bash
#http://blog.oscarliang.net/raspberry-pi-voice-recognition-works-like-siri/
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment