diff options
| -rwxr-xr-x | god/ivan/naturalvoices_cached.sh | 33 | ||||
| -rwxr-xr-x | util/bin/naturalvoices.att | 20 | ||||
| -rwxr-xr-x | util/lib/naturalvoices/att.sh | 32 | 
3 files changed, 62 insertions, 23 deletions
| diff --git a/god/ivan/naturalvoices_cached.sh b/god/ivan/naturalvoices_cached.sh index df180108..d64d9b78 100755 --- a/god/ivan/naturalvoices_cached.sh +++ b/god/ivan/naturalvoices_cached.sh @@ -2,25 +2,24 @@  # The cached version of naturalvoices  # This should prevent us from being pwned again ... +. ../../util/lib/naturalvoices/att.sh + +: ${1?what to say?Please provide text as parameter.} +  text=$(echo $* | sed -e 's/ /+/g' -e 's/\//%2F/g')  voice="klara" -ip=192.20.225.36 -base_url="http://$ip" + +  CACHE_DIR="/tmp/ivan-speech" -mkdir -p $CACHE_DIR -TXTFILE="$CACHE_DIR/${text}.wav" -if [ ! -e $TXTFILE ] ;then -    echo "Downloading $TXTFILE" -    wget $base_url$( curl  -Ss  -H 'Host:$ip' \ -  -H 'Origin:http://www2.research.att.com' \ -  -e "http://www2.research.att.com/~ttsweb/tts/demo.php" \ -  -A "Mozilla/5.0 (X11; Linux x86_64; rv:23.0) Gecko/20100101 Firefox/23.0" \ -  -d "voice=$voice" -d "txt=$text" -d "speakButton=SPEAK" \ -  -H 'Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' \ -      $base_url/tts/cgi-bin/nph-nvttsdemo | \ -      grep HREF|sed 's/.*\(".*"\).*/\1/'  | \ -      sed -e 's/"//g' ) -O "$TXTFILE" 2>/dev/null +mkdir -p "$CACHE_DIR" +OUTFILE="$CACHE_DIR/${text}.wav" + + +if [ ! -e $OUTFILE ] ;then +    echo "Downloading $OUTFILE" +    get_tts "$text"  else -    echo "using cached version of $TXTFILE" +    echo "using cached version of $OUTFILE"  fi -aplay "$TXTFILE" + +play_file "$OUTFILE" diff --git a/util/bin/naturalvoices.att b/util/bin/naturalvoices.att index 6085e511..a2fe457c 100755 --- a/util/bin/naturalvoices.att +++ b/util/bin/naturalvoices.att @@ -1,10 +1,18 @@  #!/bin/sh +cd $(dirname $(readlink -f $0)) + +. ../lib/naturalvoices/att.sh + +: ${1?please provide \$1 as text} +  text=$(echo $* | sed 's/ /+/g') -voice="klara" -base_url="http://192.20.225.36" +voice="reiner" + +OUTFILE=`mktemp` +trap "rm $OUTFILE" TERM INT EXIT + +get_tts "$text" + +play_file "$OUTFILE" -TMPFILE=`mktemp` -trap "rm $TMPFILE" TERM INT EXIT - wget $base_url$( curl  -Ss  -H 'Host:192.20.225.36' -H 'Origin:http://www2.research.att.com' -e "http://www2.research.att.com/~ttsweb/tts/demo.php" -A "Mozilla/5.0 (X11; Linux x86_64; rv:23.0) Gecko/20100101 Firefox/23.0" -d "voice=$voice" -d "txt=$text" -d "speakButton=SPEAK" -H 'Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' $base_url/tts/cgi-bin/nph-nvttsdemo | grep HREF|sed 's/.*\(".*"\).*/\1/'  |sed -e 's/"//g' ) -O $TMPFILE -aplay $TMPFILE diff --git a/util/lib/naturalvoices/att.sh b/util/lib/naturalvoices/att.sh new file mode 100755 index 00000000..5e966c79 --- /dev/null +++ b/util/lib/naturalvoices/att.sh @@ -0,0 +1,32 @@ +#!/bin/sh +# The cached version of naturalvoices +# This should prevent us from being pwned again ... + + + +get_tts(){ +    # ENV: +    #   OUTFILE - path to outfile (required) +    #   voice   - voice to use (default: klara) +    # INP: +    #   $@      - input text + +    : ${OUTFILE?please provide OUTFILE} +    text=$(echo $* | sed -e 's/ /+/g' -e 's/\//%2F/g') +    voice="${voice:-klara}" +    ip=192.20.225.36 +    base_url="http://$ip" +    wget $base_url$( curl  -Ss  -H 'Host:$ip' \ +        -H 'Origin:http://www2.research.att.com' \ +        -e "http://www2.research.att.com/~ttsweb/tts/demo.php" \ +        -A "Mozilla/5.0 (X11; Linux x86_64; rv:23.0) Gecko/20100101 Firefox/23.0" \ +        -d "voice=$voice" -d "txt=$text" -d "speakButton=SPEAK" \ +        -H 'Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' \ +            $base_url/tts/cgi-bin/nph-nvttsdemo | \ +            grep HREF|sed 's/.*\(".*"\).*/\1/'  | \ +            sed -e 's/"//g' ) -O "$OUTFILE" 2>/dev/null +} + +play_file(){ +    aplay "$*" >/dev/null +} | 
