Asterisk festival installation
Created by: oej,Last modification on Fri 13 of Mar, 2009 [02:53 UTC] by dalekarsten
How to install Festival for Asterisk usage
Festival is a text-to-speech application that is callable from within Asterisk. Voice is rather rough, but usable.The current version of Festival as of this page update is 1.95beta.
Festival can be downloaded from http://www.cstr.ed.ac.uk/projects/festival
There are a few ways to Setup Festival with Asterisk:
- The first one is to use a standard installation of Festival and modify the festival configuration file. (Easiest way)
- The second one is to patch the source-code to add a special asterisk command.
- The third one is the use an external perl script to call Festival.
The first method is probably the easiest, as it doesn't involve installing Asterisk perl library or having to recompile Festival, but it's up to you which method you choose.
Method 1 : To Use a standard Festival Installation by only modifying the Festival configuration file
Step 1: Install Festival from the RPM or DEB or source tarball.
Step 2: Find the file festival.scm (should be in /etc, may also be hidden in /usr/share/festival, /usr/lib/festival or /usr/local/lib/festival) and add this command to it:
;; Enable access to localhost (needed by debian users)
(set! server_access_list '("localhost\\.localdomain" "localhost"))
;; set italian voice (comment the following 2 lines to use british_american)
(language_italian)
(set! voice_default 'voice_pc_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."
(let ((wholeutt (utt.synth (eval (list 'Utterance 'Text string)))))
(utt.wave.resample wholeutt 8000)
(utt.wave.rescale wholeutt 5)
(utt.send.wave.client wholeutt)))
;;; Command for Asterisk end
Place this chunk anywhere within that file, except between other parentheses. ;-)
Then restart the Festival server.
This code should work both with Festival 1.95 and the older 1.4.3, which is still shipped with many Linux distributions.
Debian Sarge - Festival Deb - Festival Access List - You may have to modify your Festival configuration with the following changes in order for this to work using Debian Sarge with the Festival deb package. (contributed by dsfr, aka Chris Hozian):
(set! server_access_list '("localhost\\.localdomain" "localhost"))
;;This will add both localhost.localdomain and localhost to the access list. You should use the init script provided by the Festival deb in order to start Festival correctly to function with Asterisk.
alternative you can make sure that localhost is the first entry on /etc/hosts i.e 127.0.0.1 localhost localhost.localdomain pbx pbx.mydomain
The option usecache=yes caused asterisk to crash on Debian with stock festival packages. Festival log showed an accepted connection, and then an immediate disconnect. After asterisk would sound "very funny" eventually resulting in a system crash. These same symptoms have been reported in the comments below. Changing usecache to no solved this issue. Asterisk had full read write permissions on the cache directory, and was infact writing data there.
Method 2 : Install Festival From Source with patching of the source-code
Using this method, the Festival source code requires a simple patch that is available in the standard /usr/src/asterisk distribution/cvs , See Asterisk CVS.
Downloading Festival
First you need to download the various source tar.gz files for Festival ...
What to download: check the readme files at the site for specific files associated with different countries. Be careful to watch the licensing, not every language file is allowed for commercial use.
For US/English, start with:
- festival-1.4.3-release.tar.gz
- festlex_CMU.tar.gz
- festlex_POSLEX.tar.gz
- festvox_kallpc16k.tar.gz
- speech_tools-1.2.3-release.tar.gz
Installation steps:
cd /usr/src ; assumes the downloaded files are located heretar xvzf speech_tools-1.2.3-release.tar.gz
cd speech_tools
./configure
make
cd ..
tar xvzf festival-1.4.3-release.tar.gz
tar xvzf festlex_CMU.tar.gz
tar xvzf festlex_POSLEX.tar.gz
tar xvzf festvox_kallpc16k.tar.gz
cd festival
patch -p1 </usr/src/asterisk/contrib/festival-1.4.3-diff (or wherever the patch is on your sys)
./configure
make
Note: an anonymous user has mentioned the they had to run the above 'patch' command BEFORE cd'n into the festival directory with Festival version 1.95beta.
Note: If compiling using gcc>2.95? you may need to use this patch http://lists.digium.com/pipermail/asterisk-users/2004-May/045134.html
Starting Festival
Debian (Sarge) users only have to edit /etc/init.d/festival and comment out
the line which reads "exit 0". Then run "/etc/init.d/festival start" to start the
server.
Note: The festival startup script can be run from the command line but it requires your path statement to include the location of the festival/bin directory, regardless from where you start it. To run festival from a system startup script, please review carefully the /usr/src/festival/bin/festival_server script and modify as needed.
export PATH=$PATH:/usr/src/festival/bin
- To start festival: /usr/src/festival/bin/festival_server
- Alternative manual start: /usr/src/festival/bin/festival --server
Note: regardless of where you are in your system when you issue the above command, that startup script will detect your exact location and write a festival_server.log file (and pid files) in that location.
The log file is useful for error messages, therefore pay attention to exactly which directory you happen to be in when you issue the above command. (Or, modify the startup script accordingly.)
Method 3 The Alternative approach using a Perl Script
by Donny Kavanagh (as posted on asterisk-users in Oct 2004)I�m not sure if this is a bug, or if I�m doing something wrong but I followed the instructions on the wiki for festival, I installed 1.4.3 applied two patches, one for it not compiling on fedora core2 (newer gcc) as well as one patch to make it work with cmd Festival. This seemed to work well however, it only works when called via the zaptel card. When I call via sip, I would see the Festival cmd execute on the cli, but I heard nothing, and the sip call hung up.
I ended up writing an agi myself which I believe will run on an unpatched copy of festival. It also works fine on both versions I have on my system 1.4.3 as well as 1.95beta.
Note that this AGI scsript requires the Asterisk perl library. You do not need to start the Festival server for this to work!
Here's an example snippet for your extensions.conf:
exten => 1234,1,Answer
exten => 1234,2,AGI(festival-script.pl|Welcome to the wonderful world of Asterisk! Your phone number is ${CALLERIDNUM}.)
exten => 1234,3,Hangup
festival-script.pl (to be placed into /var/lib/asterisk/agi-bin/)
#!/usr/bin/perl
#make a tts dir inside your sounds dir (as specified below)
#adjust the t2wp variable to point to your festival bin directory
use Asterisk::AGI;
use File::Basename;
use Digest::MD5 qw(md5_hex);
$AGI = new Asterisk::AGI;
my %input = $AGI->ReadParse();
my ($text)=@ARGV;
my $hash = md5_hex($text);
my $sounddir = "/var/lib/asterisk/sounds/tts";
my $wavefile = "$sounddir/"."tts-$hash.wav";
my $t2wp= "/root/www.cstr.ed.ac.uk/download/festival/1.95/festival/bin/";
unless (-f $wavefile) {
open(fileOUT, ">$sounddir"."/say-text-$hash.txt");
print fileOUT "$text";
close(fileOUT);
my $execf=$t2wp."text2wave $sounddir/say-text-$hash.txt -F 8000 -o $wavefile";
system($execf);
unlink($sounddir."/say-text-$hash.txt");
}
$AGI->stream_file('tts/'.basename($wavefile,".wav"));
Thanks to Donny for his script above, but I had to make some changes to make it work on my system with festival v1.4.2 (Fedora Core 2). (Update: redirect text2wave output):
festival-script.pl (to be placed into /var/lib/asterisk/agi-bin/)
#!/usr/bin/perl
#make a tts dir inside your sounds dir (as specified below)
#adjust the t2wp variable to point to your festival bin directory
use Asterisk::AGI;
use File::Basename;
use Digest::MD5 qw(md5_hex);
$AGI = new Asterisk::AGI;
my %input = $AGI->ReadParse();
my ($text)=@ARGV;
my $hash = md5_hex($text);
my $sounddir = "/var/lib/asterisk/sounds/tts";
my $wavefile = "$sounddir/"."tts-$hash.wav";
my $t2wp= "/usr/bin/";
unless (-f $wavefile) {
open(fileOUT, ">$sounddir"."/say-text-$hash.txt");
print fileOUT "$text";
close(fileOUT);
my $execf=$t2wp."text2wave -F 8000 -o $wavefile $sounddir/say-text-$hash.txt > /dev/null";
system($execf);
unlink($sounddir."/say-text-$hash.txt");
}
$AGI->stream_file('tts/'.basename($wavefile,".wav"));
unlink($wavefile);
Setting Up the Asterisk configuration files
Edit the /etc/asterisk/festival.conf file and ensure the following statements are uncommented (these are used by asterisk):
[general]
host=localhost
port=1314
usecache=yes
cachedir=/var/cache/asterisk/festival/
festivalcommand=(tts_textasterisk "%s" 'file)(quit)\n
The default value for cachedir depends on your distribution. Make sure that the directory exists and is writeable by Asterisk. Since this is only a performance cache, you can use /tmp as long as festival isn't reading back any privleged information.
Edit the extensions.conf file and include the following within your dial plan (for testing purposes):
; 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
- Restart asterisk
Troubleshooting:
- When a call is made to extension 555 (assuming you followed the above completely) and no voice is heard, check the contents of the festival_server.log file (wherever it is located on your system).
client(1) : rejected from myserver.mydomain.com not in access list
then edit the festival/bin/festival_server startup script to include that FQDM in the line with "localhost.*".
- If the festival_server.log contains an entry like:
after a place a call to extension 555, then asterisk is making the call to festival.
- From the asterisk CLI interface, a properly executed and functional call to festival will look like this:
— Executing Answer("SIP/3000-46a1", "") in new stack
— Executing Festival("SIP/3000-46a1", "mary had a litte lamb") in new stack
== Parsing '/etc/asterisk/festival.conf': Found
WARNING1209269552: File app_festival.c, Line 304 (festival_exec): Text passed to festival server : mary had a little lamb
WARNING1209269552: File app_festival.c, Line 381 (festival_exec): Passing text to festival...
WARNING1209269552: File app_festival.c, Line 400 (festival_exec): Passing data to channel...
WARNING1209269552: File app_festival.c, Line 410 (festival_exec): Festival WV command
WARNING1209269552: File rtp.c, Line 374 (ast_rtp_read): RTP Read error: Resource temporarily unavailable
WARNING1209269552: File app_festival.c, Line 202 (send_waveform_to_channel): Last frame
— Executing Hangup("SIP/3000-46a1", "") in new stack
For German voices in Festival see http://www.ims.uni-stuttgart.de/phonetik/synthesis/festival_opensource.html
If you use German voices (The IMS Uni-Stuttgart version) and want to use the PHPAGI text2wav call, make sure the first line in $FESTIVAL_ROOT/lib/ims_german_opensource.scm is commented out like this:
- /*(format t "German Festival 1.2-os (1.4.1)
- : Release August 2000\n")*/
If you don't do this, the generated WAV files will contain this header before the RIFF tag, rendering them useless.
For a Dutch installation manual see http://www.voip-wiki.nl/doku.php?id=fest
See also
- Asterisk cmd festival: The Festival Application
- Asterisk config festival.conf: The configuration file for Festival in Asterisk
- Festival: The Open Source Speech synthesis software
- Asterisk flite: Flite can replace festival
- Asterisk AGI MacinTalk: AGI to call MacInTalk speech syntesis (for Apple/Mac!?)
- Sphinx: Open source speech recognition tool
- TTS: Text-toSpeech solutions
- ZOIP: Text adventure ZORK for Asterisk (with text-to-speech and voice recognition)
- Asterisk tips and tricks

Comments
333Install and configure festival with asterisk on debian
festival (1.4.3)
speech-tools maybe need
festlex-poslex maybe need
Step 2: Find the file festival.scm (in /etc) and add this command to it:
;; 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."
(utt.send.wave.client (utt.wave.resample (utt.wave.rescale (utt.synth
(eval (list 'Utterance 'Text string))) 5) 8000)))
;;; Command for Asterisk end
Step 3: Starting Festival
1 variant (for work)
Comment next line in the /etc/init.d/festival:
exit 0
Run command:
/etc/init.d/festival start
2 variant (for testing only)
Run command:
festival --server
Step 4: Configuring asterisk
festival.conf
[general]
host=127.0.0.1
port=1314
usecache=no ; with usecache=yes my computer hung up
;cachedir=/var/lib/asterisk/festivalcache/
festivalcommand=(tts_textasterisk "%s" 'file)(quit)\n
extensions.ael
context test1 {
500 => Festival(Privet liudiski);
};
Restart asterisk.
Notes:
Work without sound card installed on the machine.
333festival installation with Asterisk 1.2.7 / Mandriva2006
Launch the Festval Server with
/bin/sh /usr/bin/festival_server -p 1314 -c /usr/share/festival/lib/festival.scm -l /var/log/asterisk/ &
(which is really the correct commend)
and I have added in /usr/share/festival/lib/festival.scm file the line
(set! server_access_list '("^.+" "127.0.0.1" "localhost.*" "smith1.softnet.local"))
without it there is this message in festival server log files
client(2) Fri Jun 16 09:41:00 2006 : rejected from smith1.softnet.local not in access list
With this configuration I have always de same behaviour
log file give the following traces
root@smith1 TranslateURL1# tail -f /var/log/asterisk/festival_server.log
"Load server start /var/log/asterisk//festival_server.scm"
314
wrapper ven jun 16 09:44:07 CEST 2006 : waiting
server Fri Jun 16 09:44:07 2006 : Festival server started on port 1314
client(1) Fri Jun 16 09:46:36 2006 : accepted from smith1.softnet.local
client(1) Fri Jun 16 09:46:36 2006 : disconnected
client(2) Fri Jun 16 09:47:14 2006 : accepted from smith1.softnet.local
client(2) Fri Jun 16 09:47:14 2006 : disconnected
and CLI console on Asterisk
— AGI Script ex-perl.eagi completed, returning 0
— Executing Festival("SIP/7296325051-9dec", "'Mary has a little lamb'") in new stack
== Parsing '/etc/asterisk/festival.conf': Found
If something is missing , I don't know what
333festival installation with Asterisk 1.2.7 / Mandriva2006
Launch the Festval Server with
/bin/sh /usr/bin/festival_server -p 1314 -c /usr/share/festival/lib/festival.scm -l /var/log/asterisk/ &
(which is really the correct commend)
and I have added in /usr/share/festival/lib/festival.scm file the line
(set! server_access_list '("^.+" "127.0.0.1" "localhost.*" "smith1.softnet.local"))
without it there is this message in festival server log files
client(2) Fri Jun 16 09:41:00 2006 : rejected from smith1.softnet.local not in access list
With this configuration I have always de same behaviour
log file give the following traces
root@smith1 TranslateURL1# tail -f /var/log/asterisk/festival_server.log
"Load server start /var/log/asterisk//festival_server.scm"
314
wrapper ven jun 16 09:44:07 CEST 2006 : waiting
server Fri Jun 16 09:44:07 2006 : Festival server started on port 1314
client(1) Fri Jun 16 09:46:36 2006 : accepted from smith1.softnet.local
client(1) Fri Jun 16 09:46:36 2006 : disconnected
client(2) Fri Jun 16 09:47:14 2006 : accepted from smith1.softnet.local
client(2) Fri Jun 16 09:47:14 2006 : disconnected
and CLI console on Asterisk
— AGI Script ex-perl.eagi completed, returning 0
— Executing Festival("SIP/7296325051-9dec", "'Mary has a little lamb'") in new stack
== Parsing '/etc/asterisk/festival.conf': Found
If something is missing , I don't know what
333festival installation with Asterisk 1.2.7 / Mandriva2006
Launch the Festval Server with
/bin/sh /usr/bin/festival_server -p 1314 -c /usr/share/festival/lib/festival.scm -l /var/log/asterisk/ &
(which is really the correct commend)
and I have added in /usr/share/festival/lib/festival.scm file the line
(set! server_access_list '("^.+" "127.0.0.1" "localhost.*" "smith1.softnet.local"))
without it there is this message in festival server log files
client(2) Fri Jun 16 09:41:00 2006 : rejected from smith1.softnet.local not in access list
With this configuration I have always de same behaviour
log file give the following traces
root@smith1 TranslateURL1# tail -f /var/log/asterisk/festival_server.log
"Load server start /var/log/asterisk//festival_server.scm"
314
wrapper ven jun 16 09:44:07 CEST 2006 : waiting
server Fri Jun 16 09:44:07 2006 : Festival server started on port 1314
client(1) Fri Jun 16 09:46:36 2006 : accepted from smith1.softnet.local
client(1) Fri Jun 16 09:46:36 2006 : disconnected
client(2) Fri Jun 16 09:47:14 2006 : accepted from smith1.softnet.local
client(2) Fri Jun 16 09:47:14 2006 : disconnected
and CLI console on Asterisk
— AGI Script ex-perl.eagi completed, returning 0
— Executing Festival("SIP/7296325051-9dec", "'Mary has a little lamb'") in new stack
== Parsing '/etc/asterisk/festival.conf': Found
If something is missing , I don't know what
333festival installation with Asterisk 1.2.7 / Mandriva2006
Launch the Festval Server with
/bin/sh /usr/bin/festival_server -p 1314 -c /usr/share/festival/lib/festival.scm -l /var/log/asterisk/ &
(which is really the correct commend)
and I have added in /usr/share/festival/lib/festival.scm file the line
(set! server_access_list '("^.+" "127.0.0.1" "localhost.*" "smith1.softnet.local"))
without it there is this message in festival server log files
client(2) Fri Jun 16 09:41:00 2006 : rejected from smith1.softnet.local not in access list
With this configuration I have always de same behaviour
log file give the following traces
root@smith1 TranslateURL1# tail -f /var/log/asterisk/festival_server.log
"Load server start /var/log/asterisk//festival_server.scm"
314
wrapper ven jun 16 09:44:07 CEST 2006 : waiting
server Fri Jun 16 09:44:07 2006 : Festival server started on port 1314
client(1) Fri Jun 16 09:46:36 2006 : accepted from smith1.softnet.local
client(1) Fri Jun 16 09:46:36 2006 : disconnected
client(2) Fri Jun 16 09:47:14 2006 : accepted from smith1.softnet.local
client(2) Fri Jun 16 09:47:14 2006 : disconnected
and CLI console on Asterisk
— AGI Script ex-perl.eagi completed, returning 0
— Executing Festival("SIP/7296325051-9dec", "'Mary has a little lamb'") in new stack
== Parsing '/etc/asterisk/festival.conf': Found
If something is missing , I don't know what
333festival installation with Asterisk 1.2.7 / Mandriva2006
Launch the Festval Server with
/bin/sh /usr/bin/festival_server -p 1314 -c /usr/share/festival/lib/festival.scm -l /var/log/asterisk/ &
(which is really the correct commend)
and I have added in /usr/share/festival/lib/festival.scm file the line
(set! server_access_list '("^.+" "127.0.0.1" "localhost.*" "smith1.softnet.local"))
without it there is this message in festival server log files
client(2) Fri Jun 16 09:41:00 2006 : rejected from smith1.softnet.local not in access list
With this configuration I have always de same behaviour
log file give the following traces
root@smith1 TranslateURL1# tail -f /var/log/asterisk/festival_server.log
"Load server start /var/log/asterisk//festival_server.scm"
314
wrapper ven jun 16 09:44:07 CEST 2006 : waiting
server Fri Jun 16 09:44:07 2006 : Festival server started on port 1314
client(1) Fri Jun 16 09:46:36 2006 : accepted from smith1.softnet.local
client(1) Fri Jun 16 09:46:36 2006 : disconnected
client(2) Fri Jun 16 09:47:14 2006 : accepted from smith1.softnet.local
client(2) Fri Jun 16 09:47:14 2006 : disconnected
and CLI console on Asterisk
— AGI Script ex-perl.eagi completed, returning 0
— Executing Festival("SIP/7296325051-9dec", "'Mary has a little lamb'") in new stack
== Parsing '/etc/asterisk/festival.conf': Found
If something is missing , I don't know what
333festival installation with Asterisk 1.2.7 / Mandriva2006
I'm trying to use Festival with asterisk 1.2.7 on Mandriva 2006
I haven't need to install Festival
It is present in /usr/share/festival (1.4.3 release)
I haver followed the instruction given on the
http://www.voip-info.org/wiki/index.php?page=Asterisk+festival+installation
The Log file for the festival server process gives
"Load server start /var/log/asterisk//festival_server.scm"
314
wrapper jeu jun 15 17:48:09 CEST 2006 : USING DEFAULT CONFIGURATION
wrapper jeu jun 15 17:48:09 CEST 2006 : waiting
server Thu Jun 15 17:48:09 2006 : Festival server started on port 1314
client(1) Thu Jun 15 17:48:25 2006 : accepted from smith1.softnet.local
client(1) Thu Jun 15 17:48:25 2006 : disconnected
So it seems that the Client cannot connect to the server festival.
I have launched the festival server with the following
/bin/sh /usr/bin/festival_server -p 1314 -l /var/log/asterisk/ &
and the process which are running are
root@smith1 TranslateURL-8khz# ps -ef | grep festival
root 10093 22704 0 17:48 pts/10 00:00:00 /bin/sh /usr/bin/festival_server -p 1314 -l /var/log/asterisk/
root 10103 10093 47 17:48 pts/10 00:16:21 festival --server /var/log/asterisk//festival_server.scm
bu I am surprised because in my dian plan (extensions.conf)
I have the following
exten => _72963251XX,1,Answer()
exten => _72963251XX,n,Festival, 'Hello asterisk user, how are you today?'
=> that is OK I can hear something
but I have no traces on asterisk CLI console
(traces which normally are related to
WARNING1209269552: File app_festival.c, Line 304 (festival_exec):........
Later in the diaplan I am trying another command
exten => _72963251XX,n,Festival,'Mary has a little lamb'
And this time nothing happens (i can't hear nothing) and the call remains connected
CLI>
-- AGI Script ex-perl.eagi completed, returning 0
-- Executing NoOp("SIP/7296325051-1bfe", "URL: mark.mcroy@micronics.us") in new stack
-- Executing Festival("SIP/7296325051-1bfe", " 'Hello asterisk user, how are you today?'") in new stack
== Parsing '/etc/asterisk/festival.conf': Found
-- Executing Festival("SIP/7296325051-1bfe", "'Mary has a little lamb'") in new stack
== Parsing '/etc/asterisk/festival.conf': Found
It seems like the festival server can't work
So
Even I have no debian system, i have tried to add
in /usr/share/festival/lib/festival.scm an additionnal line
but it is not enough
(set! server_access_list '(localhost))
Any help would be welcome
Thanks
333Re: can't run Festival with Mandriva
/etc/festival.scm ignored.
Solved editing
/usr/share/festival/festival.scm
333can't run Festival with Mandriva
— Executing Answer("SIP/7296325051-8195", "") in new stack
— Executing Festival("SIP/7296325051-8195", "Hello asterisk user, how are you today?") in new stack
== Parsing '/etc/asterisk/festival.conf': Found
the call remains connected but nothing happens. I can't see the instructions in the app-festival
333can't run Festival with Mandriva
— Executing Answer("SIP/7296325051-8195", "") in new stack
— Executing Festival("SIP/7296325051-8195", "Hello asterisk user, how are you today?") in new stack
== Parsing '/etc/asterisk/festival.conf': Found
the call remains connected but nothing happens. I can't see the instructions in the app-festival