Skip to content

Instantly share code, notes, and snippets.

@skorotkiewicz
Created May 27, 2017 19:02
Show Gist options
  • Save skorotkiewicz/1ded9db85daab1d34c9f4b99b5a72a3c to your computer and use it in GitHub Desktop.
Save skorotkiewicz/1ded9db85daab1d34c9f4b99b5a72a3c to your computer and use it in GitHub Desktop.
Multi Google Speech in CLI
#!/bin/bash
INPUT=$*
STRINGNUM=0
ary=($INPUT)
for key in "${!ary[@]}"
do
SHORTTMP[$STRINGNUM]="${SHORTTMP[$STRINGNUM]} ${ary[$key]}"
LENGTH=$(echo ${#SHORTTMP[$STRINGNUM]})
if [[ "$LENGTH" -lt "100" ]]; then
SHORT[$STRINGNUM]=${SHORTTMP[$STRINGNUM]}
else
STRINGNUM=$(($STRINGNUM+1))
SHORTTMP[$STRINGNUM]="${ary[$key]}"
SHORT[$STRINGNUM]="${ary[$key]}"
fi
done
for key in "${!SHORT[@]}"
do
echo "Playing line: $(($key+1)) of $(($STRINGNUM+1))"
NEXTURL=$(echo ${SHORT[$key]} | xxd -plain | tr -d '\n' | sed 's/\(..\)/%\1/g')
mpg123 -q "http://translate.google.com/translate_tts?ie=UTF-8&client=tw-ob&q=$NEXTURL&tl=Pl-pl"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment