Skip to content

Instantly share code, notes, and snippets.

@initbrain
Created September 19, 2013 19:08
Show Gist options
  • Save initbrain/6628371 to your computer and use it in GitHub Desktop.
Save initbrain/6628371 to your computer and use it in GitHub Desktop.
Text to speak installation script
#!/bin/bash
# Text to speak installation script
# Testé avec Lubuntu 13.04 x86_64
# Julien Deudon (initbrain)
# Vérifier les privilèges
if [ $USER = root -o $UID -eq 0 ]
then
echo "Veuillez exécuter ce script en tant qu'utilisateur normal,"
echo "il va acquérir les privilèges root au besoin via la commande \"sudo\"."
exit
fi
MBROLA_PATH=/home/$USER/Outils/mbrola
LLIAPHON_PATH=$MBROLA_PATH/lliaphon/bin
MBROLA_VOICE=$MBROLA_PATH/fr1/fr1
BIN_PATH=/usr/local/bin
#MEDIA_PATH=$(mount | grep lubuntu1304 | awk '{print $3}')
mkdir $MBROLA_PATH
cd $MBROLA_PATH
# Permettre l'exécution d'ELF 32 bits si kernel 64 bits
# Commandes alternatives :
# getconf LONG_BIT
# uname -m
if [[ "$(lscpu | head -n 1 | awk '{print $2}')" == "x86_64" ]]
then
sudo apt-get install -y ia32-libs
fi
# Téléchargement de mbrola
#unzip $MEDIA_PATH/custom/mbr301h.zip -d $MBROLA_PATH
wget http://tcts.fpms.ac.be/synthesis/mbrola/bin/pclinux/mbr301h.zip
unzip mbr301h.zip -d $MBROLA_PATH
rm -f mbr301h.zip
# Téléchargement d'une voix Française pour MBROLA
#unzip $MEDIA_PATH/custom/fr1-990204.zip -d $MBROLA_PATH
wget http://tcts.fpms.ac.be/synthesis/mbrola/dba/fr1/fr1-990204.zip
unzip fr1-990204.zip -d $MBROLA_PATH
rm -f fr1-990204.zip
# Test de la synthèse vocale
./mbrola-linux-i386 fr1/fr1 fr1/TEST/ceserait.pho -.au | aplay
# Installaton de lliaphon
#tar xvf $MEDIA_PATH/custom/lliaphon-0.4.tar.gz -C $MBROLA_PATH
wget http://download.gna.org/lliaphon/stable/lliaphon-0.4.tar.gz
tar xvf lliaphon-0.4.tar.gz -C $MBROLA_PATH
rm -f lliaphon-0.4.tar.gz
cd lliaphon-0.4
./configure --prefix $MBROLA_PATH/lliaphon
make
make install
cd ..
rm -rf lliaphon-0.4
cd $MBROLA_PATH/lliaphon
chmod +x bin/*
# Création du script d'utilisation
echo """#!/bin/sh
if [ "\$#" -ne 1 ]
then
echo 'Usage: tts \"some text to speak\"'
exit
fi
echo \$1 | iconv -f UTF-8 -t ISO_8859-1 > /tmp/tts_tampon.txt
lliaphon /tmp/tts_tampon.txt >> /tmp/tts_logs 2>&1
mbrola -e -t 0.75 -I $MBROLA_PATH/lliaphon/share/lliaphon/initfile.lia $MBROLA_PATH/fr1/fr1 /tmp/tts_tampon.ola -.au | aplay >> /tmp/tts_logs 2>&1
rm /tmp/tts_*
""" > $MBROLA_PATH/tts
chmod +x $MBROLA_PATH/tts
# Création des liens symboliques
sudo ln -s $MBROLA_PATH/mbrola-linux-i386 $BIN_PATH/mbrola
sudo ln -s $LLIAPHON_PATH/lliaphon $BIN_PATH/lliaphon
sudo ln -s $MBROLA_PATH/tts $BIN_PATH/tts
# Message de fin
echo -e "\n#####\n"
echo -e "Installation de la synthèse vocale terminée."
echo -e "Usage: tts \"some text to speak\"\n"
echo -e "Pour tout desinstaller utilisez la commande :"
echo -e "sudo rm -r $BIN_PATH/{mbrola,lliaphon,tts} $MBROLA_PATH\n"
# Easter egg :P
mbrola $MBROLA_PATH/fr1/fr1 $MBROLA_PATH/fr1/TEST/ileenf.pho -.au | aplay 2>/dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment