notes/Transcribe MP3 Audio with Google speech API-eWqmhCbE.sh
#!/bin/bash
if [ $# -lt 1 ];then
echo "what file?"
exit
fi
mp3splt -d split -s -p th=-30,min=1,rm $1
cd split
for i in *.mp3
do
avconv -i "$i" -acodec pcm_s16le -ac 1 -ar 16000 "$i.wav"&& rm "$i"
done
for i in *.wav;
do
flac "$i" -f --best --sample-rate 16000 -s -o "$i.flac"
done
rm *.wav
for i in *.flac
do
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
clear
cat ../transcript.txt
done
syntax highlighted by Code2HTML, v. 0.9.1