Section 10.1. Festival

10.1. Festival

Festival is a popular open source text-to-speech engine. The basic premise of using Festival with Asterisk is that your dialplan can pass a body of text to Festival, which will then "speak" the text to the caller. Probably the most obvious use for Festival would be to have it read your email to you when you are on the road.

10.1.1. Getting Festival Set Up and Ready for Asterisk

There are currently two ways to use Festival with Asterisk. The first (and easiest ) methodwithout having to patch and recompile Festivalis to add the following text to Festival's configuration file ( festival.scm , usually located in /etc/ or /usr/share/festival/ ):

 (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)     (utt.send.wave.client wholeutt))) 

You may place this text anywhere in the file, as long as it is not between any other parentheses.

The second (and more traditional) way is to compile Festival with an Asterisk-specific patch (located in the contrib / directory of the Asterisk source).

Information on both of these methods is contained in the README.festival file, located in the contrib/ directory of the Asterisk source.

For either method, you'll need to modify the Festival access list in the festival.scm file. Simply search for the word "localhost," and replace it with the fully qualified domain name of your server.

Both of these methods set up Festival to be able to correctly communicate with Asterisk. After setting up Festival, you should start the Festival server. You can then call the Festival( ) application from within your dialplan.

10.1.2. Configuring Asterisk for Festival

The Asterisk configuration file that deals with Festival is aptly called festival.conf . Inside this file, you specify the hostname and port of your Festival server, as well some settings for the caching of Festival speech. For most installations (if you're going to run Festival on your Asterisk server), the defaults will work just fine.

10.1.3. Starting the Festival Server

To start the Festival server for debugging purposes, simply run festival with the server argument, like this:

 [root@asterisk ~]#  festival --server  

Once you're sure that the Festival server is running and not rejecting your connections, you can start Festival by typing:

 [root@asterisk ~]#  festival_server 2>&1 >/dev/null &  

10.1.4. Calling Festival from the Dialplan

Now that Festival is configured and the Festival server is started, let's call it from within a simple dialplan:

 exten => 123,1,Answer( )     exten => 123,2,Festival(Asterisk and Festival are working together) 

You should always call the Answer( ) application before calling Festival( ) , to ensure that a channel is established.


As Asterisk connects to Festival, you should see output like this in the terminal where you started the Festival server:

 [root@asterisk ~]#  festival --server  server    Sun May  1 18:38:51 2005 : Festival server started on port 1314     client(1) Sun May  1 18:39:20 2005 : accepted from asterisk.localdomain     client(1) Sun May  1 18:39:21 2005 : disconnected 

If you see output like the following, it means you didn't add the host to the access list in festival.scm :

 [root@asterisk ~]#  festival --server  server    Sun May  1 18:30:52 2005 : Festival server started on port 1314     client(1) Sun May  1 18:32:32 2005 : rejected from asterisk.localdomain not      in access list 

Yet Another Way to Use Festival with Asterisk

Some people in the Asterisk community have reported good success by passing text to Festival's text2wave utility and then having Asterisk play back the resulting .wav file. For example, you might do something like this:

 exten => 124,1,Answer( )     exten => 124,2,System(echo "This is a test of Festival"  /usr/bin/text2wave     -scale 1.5 -F 8000 -o /tmp/festival.wav)     exten => 124,3,Playback(/tmp/festival)     exten => 124,4,System(rm /tmp/festival.wav)     exten => 124,5,Hangup( ) 

This method also allows you to call other text-to-speech engines, such as the popular speech engine from Cepstral. [a] For this example, we'll assume that Cepstral is installed in /usr/local/cepstral/ :

 exten => 125,1,Answer( )     exten => 125,2,System(/usr/local/cepstral/bin/swift -o /tmp/swift.wav     "This is a test of Cepstral")     exten => 125,3,Playback(/tmp/swift)     exten => 125,4,System(rm /tmp/swift.wav)     exten => 125,5,Hangup( ) 


[a] Cepstral can be evaluated at http://www.cepstral.com. Cepstral is an inexpensive commercial derivative of Festival with very good-sounding voices.



Asterisk. The Future of Telephony
Asterisk: The Future of Telephony: The Future of Telephony
ISBN: B0026OR3OO
EAN: N/A
Year: 2001
Pages: 380

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net