kusnier/dotfiles — Issue #2: gsay - google say
Author: kusnier
Created: 2011-12-14 13:30:24+00:00
State: open

```bash
#!/bin/bash
lang=de
str="$*"
tmp="/tmp/gsay.$$.mp3"
i=0

if [ "$str" == "" ]; then
line
[ -t 0 ] || str="$(cat)"
fi

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: Yes-Man' "$url" >| "$tmp" && afplay "$tmp"
done
rm -f "$tmp"
```