We’ll go through the process of installing and Configuring Festival Speech-to-text utility developed by University of Edinburgh, UK community.
Text-to-speech conversion is very crucial when working with Asterisk Pbx or any Media servers used for routing calls. Text-to-speech utilities are used to convert strings of words into audio that can be played to the callers using the system. Text-to-speech is not a replacement for professionally recorded prompts.
Asterisk Installation guides:
Festival is free to use text-to-speech utility that works on all Linux systems. It is not recommended for production use because its sound quality is not clear enough, but used very often for development and testing purposes. For production use, you can have a look at Cepstral.
Install Festival on CentOS and RHEL
sudo yum install epel-release sudo yum install festival
Install Festival on Ubuntu
sudo apt update sudo apt-get install festival
See installation screen output:
After installing Festival, we would like to configure it to allow use with Asterisk PBX. To do this, we just have to edit festival.scm file located in /usr/share/festival/ directory. Open the file with any text editor you have.I will use vim:
$ sudo vim /usr/share/festival/lib/festival.scm
Add the the following text just above the last line; (provide ‘festival):
(define (tts_textasterisk string mode) (let ((wholeutt (utt.synth (eval (list 'Utterance 'Text string))))) (utt.wave.resample wholeutt 8000) (utt.wave.rescale wholeutt 5) (utt.send.wave.client wholeutt)))
Save changes and restart the Festival server
sudo festival_server 2>&1 > /dev/null &
Go to your Asterisk source directory and verify that the app_festival application is selected under Applications heading. If not, use make menuselect command to install Festival() diaplan apllication.If you had used my tutorial at:
$ sudo make menuselect
Make sure it’s checked.See screen shot below
sudo make install
Asterisk has to be configured to connect to Festival server on festival.conf file. There is a sample configuration file located in the Asterisk source directory.W e’ll copy it to /etc/asterisk/ directory then edit.
sudo cp configs/samples/festival.conf.sample /etc/asterisk/festival.conf
The default configuration is enough to connect to Festival server provided both are running on a local machine. If Festival service is running on a remote device, we’ll change the host parameter. All other configuration parameters will be left to default.
sudo vim /etc/asterisk/festival.conf
Change where necessary.
To verify that Festival() dialplan application is running, type following command on Asterisk command line interface.
core show application festival
If you don’t get any output, first load the app_festival.so module:
module load app_festival.so module show app_festival.so
You can check file availability in /usr/lib/asterisk/modules.If you used my tutorial to install Asterisk, you may have realized that I compiled asterisk with libdir being –libdir=/usr/lib64. For this case, the module will be on
ls -lh /usr/lib64/asterisk/modules/app_festival.so
ls -lh /usr/lib/asterisk/modules/app_festival.so
From here. you can create simple dialplan like one below for testing:
exten => 110,1,Verbose(2,Performing Festival test) same => n,Answer() same => n,System(echo "We are now doing Festival Test after successful installation" | /usr/bin/text2wave -scale 1.5 -F 8000 -o /tmp/test.wav) same => n,Playback(/tmp/test) same => n,System(rm -f /tmp/test.wav) same => n,Hangup()
If you dial extension number 110, it should automatically record test.wav audio file from the string “We are now doing Festival Test after successful installation” and play it back to you. We hope this tutorial helped you with your PBX project.