metalx1000

Transcribe MP3 Audio with Google speech API

Feb 24th, 2014
323
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.60 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. if [ $# -lt 1 ];then
  4.     echo "what file?"
  5.     exit
  6. fi
  7.  
  8. mp3splt -d split -s -p th=-30,min=1,rm $1
  9. cd split
  10.  
  11. for i in *.mp3
  12. do
  13.     avconv -i "$i" -acodec pcm_s16le -ac 1 -ar 16000 "$i.wav"&& rm "$i"
  14. done
  15.  
  16. for i in *.wav;
  17. do
  18.     flac "$i" -f --best --sample-rate 16000 -s -o "$i.flac"
  19. done
  20.  
  21. rm *.wav
  22.  
  23. for i in *.flac
  24. do
  25.     wget -q -U "Mozilla/5.0" --post-file "$i" --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 >> ../transcript.txt
  26.     clear
  27.     cat ../transcript.txt
  28. done
Add Comment
Please, Sign In to add comment