-
-
Save MVoz/2a75b39e51268723903d5cca69d107a9 to your computer and use it in GitHub Desktop.
Speech recognition on linux using Google Speech API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Record from mic | |
arecord -d 3 -f cd -t wav -r 16000 -c 1 -D pulse test.wav | |
# Get record volume | |
sox test.wav -n stats -s 16 2>&1 | grep 'Max level' | awk '{print $3}' | |
# Convert to flac for smaller footprint | |
flac -f test.wav | |
# Google speech recognition | |
LANG=en-us | |
AGENT='Mozilla/5.0' | |
APIKEY='AIzaSyBOti4mM-6x9WDnZIjIeyEU21OpBXqWBgw' | |
curl -X POST \ | |
--data-binary @'test.flac' \ | |
--user-agent $AGENT \ | |
--header 'Content-Type: audio/x-flac; rate=16000;' \ | |
"https://www.google.com/speech-api/v2/recognize?output=json&lang=en&key="$APIKEY"&client="$AGENT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment