Festival es un TTS (Text to speech) de la universidad de Edimburgo OpenSource. Las voces en Inglés tiene una calidad aceptable, pero en Español son pésimas así que explicaré como instalar unas un poco mejores.
En debian/ubuntu instalamos Festival por apt:
aptitude install festival festvox-ellpc11k
Se instalarán los siguiente paquetes NUEVOS:
esound-clients{a} esound-common{a} festival festlex-cmu{a} festlex-poslex{a} festvox-ellpc11k festvox-kallpc16k{a} libaudiofile0{a} libesd0{a} libestools1.2{a}
0 paquetes actualizados, 10 nuevos instalados, 0 para eliminar y 0 sin actualizar.
festvox-ellpc11k es la voz española predefinida. No tiene muy buena calidad. No obstante, dos empresas de Sevilla (Indisys y MP-Sistemas) han desarrollado dos voces en español neutro, masculina y femenina (Pedro y Silvia) según una petición de la Junta de Andalucía para dotar a su distribución GuadaLinex de un sintetizador de voz. Están disponibles con licencia libre para cualquiera que quiera utilizarlas:
http://forja.guadalinex.org/repositorio/frs/?group_id=21&release_id=110
Primero configuramos estival con la voz predefinida, para ello editamos /etc/festival.scm y ponemos (si no existe lo creamos):
;; Enable access to localhost (needed by debian users)
(set! server_access_list ‘(”localhost\\.localdomain” “localhost”))
;; set spanish voice (comment the following 2 lines to use british_american)
;; (language_spanish)
(set! voice_default ‘voice_el_diphone)
;;; Command for Asterisk begin
(define (tts_textasterisk string mode)
“(tts_textasterisk STRING MODE)
Apply tts to STRING. This function is specifically designed for
use in server mode so a single function call may synthesize the string.
This function name may be added to the server safe functions.”
(utt.send.wave.client (utt.wave.resample (utt.wave.rescale (utt.synth
(eval (list ‘Utterance ‘Text string))) 5) 8000)))
;;; Command for Asterisk end
Y en /etc/asterisk/festival.conf
;
; Festival Configuration
;
[general]
;
; Host which runs the festival server (default : localhost);
;
host=localhost
;
; Port on host where the festival server runs (default : 1314)
;
port=1314
;
; Use cache (yes, no - defaults to no)
;
;usecache=yes
;
; If usecache=yes, a directory to store waveform cache files.
; The cache is never cleared (yet), so you must take care of cleaning it
; yourself (just delete any or all files from the cache).
; THIS DIRECTORY *MUST* EXIST and must be writable from the asterisk process.
; Defaults to /tmp/
;
;cachedir=/var/lib/asterisk/festivalcache/
;
; Festival command to send to the server.
; Defaults to: (tts_textasterisk “%s” ‘file)(quit)\n
; %s is replaced by the desired text to say. The command MUST end
; with a (quit) directive, or the cache handling mechanism will hang.
; Do not forget the \n at the end.
;
festivalcommand=(tts_textasterisk “%s” ‘file)(quit)\n
;
;
Y por último corremos:
usr/bin/festival –server > /dev/null 2>&1 &
Y iniciamos o reiniciamos asterisk.
Para porbarla, usamos la application Festival. Ponemos por ejemplo:
exten => 100,1,Answer()
exten => 100,2,Festival(Esto es una prueba)
exten => 100,3,Hangup()
y marcamos la exten 100
La voz por defecto suena muy triste y robótica.
Para crear una locución para poder usar la application Background podemos crearlas con la utilidad de festival text2wave:
echo "Para hablar con un operador, pulse uno; para hablar con ventas, pulse 2; sino, espere porfavor" | iconv -f utf-8 -t iso-8859-1 | /usr/bin/text2wave -scale 1.5 -F 8000 -o ./bienvenida.wav
Voces de la junta de extremadura:
Bien, como veis, para ponerla en español (el_diphone) hay que poner el parámetro ‘voice_el_diphone’ que es la que instaló el paquete festvox-ellpc11k. Es la voz por defecto y es un poco cutre.
Así que nos descargamos los .deb de las voces anteriormente dichas, en:
http://forja.guadalinex.org/repositorio/frs/?group_id=21&release_id=110
En concreto yo he instalado las últimas:
Última versión Voz femenina:
festvox-sflpc16k_1.0-1_all.deb
Ultima versión voz masculina:
festvox-palpc16k_1.0-1_all.deb
Y las instalamos:
dpkg -i festvox-palpc16k_1.0-1_all.deb
dpkg -i festvox-sflpc16k_1.0-1_all.deb
Ahora editamos /etc/festival.scm y las probamos. La voz masculina se llama:
JuntaDeAndalucia_es_pa_diphone
y la femenina:
JuntaDeAndalucia_es_sf_diphone
por lo que pondremos:
(set! voice_default ‘voice_JuntaDeAndalucia_es_pa_diphone)
Y para la voz femenina:
(set! voice_default ‘voice_JuntaDeAndalucia_es_sf_diphone)
(una u otra comentando las otras con un ;;;)
Ahora suena bastante mejor, ¿no?
No son perfectas, pero es lo mejor que hay de código Abierto y gratis.
NOTA IMPORTANTE:
Festival es inseguro. Tiene algunos fallos de seguridad y aunque cambiemos el puerto puede que algún atacante lo utilice para hecrse con el sistema….No creo que sea fácil ni que mucha gente sepa del conocimiento para hacer esto (o incluso sepa de la existencia del mismo festival) pero cabe la posibilidad, así que quedas avisado.
Tenerlo corriendo como demonio no es buena idea a no ser que tu máquina no sea accesible desde fuera.
Si es una máquina en producción y accesible desde internet es mejor crear las locuiones a mano con la aplicación ‘text2wave’.
Si tu máquina es inaccesible y quieres tener Festival corriendo como demonio y que se arranque con tu sistema y así odamos usarlo desde el dialplan con la application ‘Festival’, has de poner este script en /etc/init.d/festival. Comprueba antes si debian te lo ha instalado ya por apt. A mi no me lo incluyó así que lo tuve que poner a mano:
#!/bin/sh
#/etc/init.d/festival
#
# Init script for starting Festival as a system-wide server process.
#
# Written by David Huggins-Daines
# LSBINITInfo by Kartik Mistry
# LSB logging functions by David Härdeman
### BEGIN INIT INFO
# Provides: festival
# Required-Start: $syslog
# Required-Stop: $syslog
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Starts Festival engine at boot time
# Description: Init script for starting Festival TTS as a
# system-wide server process
### END INIT INFO
[ -r /etc/default/festival ] && . /etc/default/festival
if [ "$RUN_FESTIVAL" != yes ]; then
exit 0
fi
# NOTE: Not just anybody can connect to your server; the list of allowed
# hostnames is a regexp. Check /usr/share/festival/festival.scm for more
# helpful comments; add your settings to /etc/festival.scm.
set -e
DAEMON=/usr/bin/festival
REALPROC=/usr/bin/festival
NAME=festival
. /lib/lsb/init-functions
test -x $DAEMON || exit 0
case "$1" in
start)
log_daemon_msg "Starting Festival server" "$NAME"
start-stop-daemon --start --chuid festival --background \
--exec $DAEMON -- --server
log_end_msg 0
;;
stop)
log_daemon_msg "Stopping Festival server" "$NAME"
start-stop-daemon --stop --oknodo --exec $REALPROC
log_end_msg 0
;;
restart|reload|force-reload)
log_daemon_msg "Restarting Festival server" "$NAME"
start-stop-daemon --stop --oknodo --exec $REALPROC
start-stop-daemon --start --chuid festival --background \
--exec $DAEMON -- --server
log_end_msg 0
;;
*)
echo "Usage: /etc/init.d/$NAME {start|stop|restart}" >&2
exit 2
;;
esac
exit 0
Y hacemos como root:
# update-rc.d festival defaults
Y en /etc/default/festival ponemos:
# Set RUN_FESTIVAL=yes to start festival at boot time.
RUN_FESTIVAL=yes
Cambiando simplemente este archivo poniéndolo a no, ya no se iniciará como demonio.
PD: Si alguien conoce unas voces en castellano de mejor calidad u otras variantes (Acento de Argentina, Méjico, etc) estaría bien que lo comentase.