`gsay` function (use Google’s Translate API to say things) #31

mathiasbynens opened this Issue Dec 12, 2011 · 2 comments


None yet
3 participants

mathiasbynens commented Dec 12, 2011

function gsay { local lang=nl str="$*" tmp="/tmp/gsay.$$.mp3" i=0 line; [ -t 0 ] || str="$(cat)"; fmt -w 100 <<< "$str" | while read -r line; do url="http://translate.google.com/translate_tts?ie=UTF-8&tl=$lang&q=${line//&/%26}"; url="${url// /+}"; curl -sH 'User-Agent: Notabot' "$url" >| "$tmp" && afplay "$tmp"; done; rm -f "$tmp"; }

/by @janmoesen

styfle commented Apr 10, 2012

Very clever. I'm not sure how this is better than say but it might be fun to translate from the command line.


sindresorhus commented Apr 25, 2012

The built in voice in Mac is actually better than the Google Translate one. What would be useful is a quick way to translate some text with Google Translate.

githubutilities pushed a commit to githubutilities/dotfiles that referenced this issue May 30, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment