So… you want your PBX to talk to you? This could be the start of a very bad relationship! In this short piece, I’ll describe making Asterisk on Debian/Ubuntu talk to Festival that is also installed on a Debian or Ubuntu server.
Firstly, have a read at VoIP-Info but don’t make any changes to files just yet. In this scenario, I’ll be using Method 1.
Create /etc/festival.scm and put the following into it – you may recognize it from Step 1 in the wiki.
;; Enable access to localhost (needed by debian users)
(set! server_access_list ‘(“localhost\\.localdomain” “localhost”))
;;; 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.”
(let ((wholeutt (utt.synth (eval (list ‘Utterance ‘Text string)))))
(utt.wave.resample wholeutt 8000)
(utt.wave.rescale wholeutt 5)
;;; Command for Asterisk end
If you are going to access it from a different host, put the source IP address or hostname into the server_access_list array variable.
Next up, execute cp /usr/share/doc/festival/examples/festival.init /etc/init.d/festival to copy a sample init script to the init.d directory. Use chmod +x /etc/init.d/festival to make it executable, and then use update-rc.d festival defaults to insert startup links in the default runlevel directories.
/etc/default/festival also requires RUN_FESTIVAL=yes in it, in order for the init script to start the server.
Once all of the above is complete, you should be able to run /etc/init.d/festival start and Festival will start. This can be verified as such…
root@mxns2:~# ps waux | grep -i festiva[l]
festival 25411 0.0 8.4 26728 21496 ? S 22:52 0:00 /usr/bin/festival –server -b /etc/festival.scm
You can also check to see that Festival is listening on the network, as it should be in this case.
root@mxns2:~# netstat -lnp | grep -i festival
tcp 0 0 0.0.0.0:1314 0.0.0.0:* LISTEN 25411/festival
This tells us that it is listening on all IP addresses assigned to the server, on port 1314. Access control is provided by the array mentioned earlier.
Next up, Asterisk has to be told how to communicate with Festival. This is done by creating the /etc/asterisk/festival.conf file, and putting the following data into it.
festivalcommand=(tts_textasterisk “%s” ‘file)(quit)\n
As noted above, the port that Festival is listening on is 1314, and in this case Asterisk and Festival are both running on the same server – hence localhost. In my setup, I have a remote Festival server, and I put in the IP address of the Festival server.
So, almost all good to go. All you need to do now is set up an extension with the appropriate details. As per the wiki, you could stick the following into your extensions.conf
; testing festival (text-to-speech app)
exten => 555,1,Answer
exten => 555,2,Festival(mary had a little lamb) ; do NOT use quotes around the string! if you use commas, you will have to escape them with a “\” (backslash).
exten => 555,3,Hangup
Reload Asterisk, and off you go!