#!/bin/bash

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>

# (c) Antonio Sánchez León <introlinux[fix@]gmail[fix.]com>
# (c) Miguel Anxo Bouzada <mbouzada[fix@]gmail[fix.]com>
# (c) GALPon MinNo Team <minino[fix@]galpon[fix.]org>
# july 2012

## -

# Aquí usamos la web AT&T http://www2.research.att.com/~ttsweb/tts/demo.php
# para conseguir una voz muy natural.

# Texto entre comillas
TEXT="`cat $HOME/.config/libreoffice/4/user/config/tts_str.txt`"
#TEXT="$@"


HAYINTERNET=`hayinternet`

if [ "$HAYINTERNET" = "up" ];then

case $LANG in

	ca*)
		VOZ="rosa"
	;;

	es*)
		VOZ="rosa"
	;;

	gl*)
		VOZ="rosa"
	;;

	en*)
		VOZ="rich"
	;;

	*)
		VOZ="rosa"
	;;
esac


#mplayer2 http://192.20.225.36$(curl --data "voice=$VOZ&txt=$TEXT&speakButton=SPEAK" "http://192.20.225.36/tts/cgi-bin/nph-nvdemo"|grep ".wav"|cut -d\" -f2)
minino-habla "$TEXT"

else

case $LANG in
    ca*)

	IDIOMA="ca"

    ;;
    es*)

	IDIOMA="es"

    ;;
    gl*)

	IDIOMA="gl"

    ;;
    *)
	IDIOMA="en"

    ;;
esac

#espeak -v $IDIOMA "$TEXT"
minino-habla "$TEXT"

fi