Usage:
$ say en lol #says "lol" in englishAnd here goes the script:
$ somecommand | say fr - #read text to say from a pipe
#!/bin/ash
lang=$1
shift
if [ "$1" = "-" ]
then
read text
echo $text
else
text=$*
fi
len=`expr length "$text"`
if [ -z "$text" ] ; then
echo "Please specify string to translate (up to 100 characters incl.)."
exit 4
elif [ "$len" -gt "100" ] ; then
echo "Can't translate more than 100 characters at once! (entered $len)"
exit 2
fi
wget -qU Mozilla -O - "http://translate.google.com/translate_tts?ie=UTF-8&tl=$lang&q=$text" | madplay -Q -o wave:- - | aplay -q -
exit 0
Hello Saironiq,
ReplyDeleteI had the same problem with accents and finally solved it. Just add the parameter ie=UTF-8 to the URL after the ? sign. It worked with spanish. I guess it will work with croatian too.
Best regards,
Marduk
Thanks a lot! Script updated.
ReplyDeleteWe can determine if the string has given doing this
ReplyDeleteSTRING="${@:?Usage: Give me words to speech}"