Skip to content

Instantly share code, notes, and snippets.

@mmmaly
Created November 13, 2018 18:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mmmaly/e78fbc3d05cb232e38e6cee5cda6aa2d to your computer and use it in GitHub Desktop.
Save mmmaly/e78fbc3d05cb232e38e6cee5cda6aa2d to your computer and use it in GitHub Desktop.
Call Google speech recognize
#!/bin/bash
fileogg=$1
name=${fileogg%.ogg}
file=$name.flac
ffmpeg -i $fileogg -ar 16000 $file 2>/dev/null
gsutil cp $file gs://transcribe
gcloud ml speech recognize-long-running gs://transcribe/$file --sample-rate 16000 --encoding flac --language-code='sk-SK' --async > $$.id
id=`jq -r .name < $$.id `
gcloud ml speech operations wait $id > $name.json
jq -r .results[0].alternatives[0].transcript < $name.json | tee $name.txt
rm $$.id
rm $file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment