summaryrefslogtreecommitdiffstats
path: root/util/bin/google.text2speech
blob: 061bb1c861185098544fa07eab6908eb73e53d97 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/sh
set -euf

TL=${TL:="en"}

usage(){
  echo 'TL= can specifiy which language to use, default is "en"'
  echo 'Example: TL="de" ./text2speech.google "whats up?" | mpv -'
  exit 0
}

text2speech(){
  text=$*
  url="http://translate.google.com/translate_tts?ie=UTF-8&tl=$TL"

  curl -A "Mozilla/5.0" -Ss "$url" --data-urlencode "q=$text"
}

if [ $# -eq 0 ]; then
  usage
fi

text2speech $*