Created
September 29, 2016 00:00
-
-
Save G10DRAS/2dae710f9b06e304ba47d85510729a56 to your computer and use it in GitHub Desktop.
Test Google Speech Private 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 | |
hardware="plughw:0,0" | |
duration="4" | |
lang="en" | |
client="Mozilla/5.0" | |
apikey="XXxxXXxXxXxxXX_8XxxXXXXxxxxx_X8XXxxxxxX" | |
arecord -D $hardware -f S16_LE -t wav -d $duration -r 16000 | flac - -f --best --sample-rate 16000 -o /tmp/out.flac 1>/tmp/voice.log 2>/tmp/voice.log; curl -X POST --data-binary @/tmp/out.flac --user-agent 'Mozilla/5.0' --header 'Content-Type: audio/x-flac; rate=16000;' "https://www.google.com/speech-api/v2/recognize?output=json&lang=$lang&pfilter=2&maxresults=6&key=$apikey&client=$client" | sed -e 's/[{}]/''/g' | awk -F":" '{print $4}' | awk -F"," '{print $1}' | tr -d '\n' | |
rm /tmp/out.flac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment