May the source be with you, but remember the KISS principle ;-)
Home Switchboard Unix Administration Red Hat TCP/IP Networks Neoliberalism Toxic Managers
(slightly skeptical) Educational society promoting "Back to basics" movement against IT overcomplexity and  bastardization of classic Unix


Synthesizing Voice From the Command Line Linux Journal by Mitch Frazier

I don't do a lot of audio/video stuff with my system, but the other day I had the urge to see if there was some voice synthesis software available on Linux and it turned out that I already had it installed: it's called Festival. Turns out there are a number of voice synthesis and analysis packages available.

Festival is, according to the website:

Festival offers a general framework for building speech synthesis systems as well as including examples of various modules. As a whole it offers full text to speech through a number APIs: from shell level, though [sic] a Scheme command interpreter, as a C++ library, from Java, and an Emacs interface. Festival is multi-lingual (currently English (British and American), and Spanish) though English is the most advanced.

As far as simple commands, Festival comes with two: saytime and text2wave. Saytime does what you would expect, it speaks the time (as well as outputting the spoken text to stdout). Note though, the time that is output tends to be less than specific:

$ saytime
The time is now, just after half past 10, in the morning.

A wave file of the output is attached (time.wav).

The second command that comes with Festival is text2wave which converts text read from stdin to a .wav file output:

$ echo Your job has completed | text2wave >job.wav
$ aplay job.wav

# OR
$ echo Your job has completed | text2wave | aplay

The wave file is attached (job.wav).

If these commands do not exist on your system you will need to install the festival package. For other voice related packages search the web or check the list here on

RPM is available on RHEL4 is festival-1.4.2-25.i386.rpm

Asterisk festival installation -

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

There are a few ways to Setup Festival with Asterisk: 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)
(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."
"the line below is shown incorrectly in this wiki 1 hour wasted :( add two brackets before wholeutt and at the end of the line"
(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 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:

Installation steps:

 cd /usr/src ; assumes the downloaded files are located here
 tar xvzf speech_tools-1.2.3-release.tar.gz
 cd speech_tools

 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) 

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

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

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
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(|Welcome to the wonderful world of Asterisk! Your phone number is ${CALLERIDNUM}.)
  exten => 1234,3,Hangup (to be placed into /var/lib/asterisk/agi-bin/)


 #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/";
 unless (-f $wavefile) {
         open(fileOUT, ">$sounddir"."/say-text-$hash.txt");
         print fileOUT "$text";

         my $execf=$t2wp."text2wave $sounddir/say-text-$hash.txt -F 8000 -o $wavefile";

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): (to be placed into /var/lib/asterisk/agi-bin/)


#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";
        my $execf=$t2wp."text2wave -F 8000 -o $wavefile $sounddir/say-text-$hash.txt";



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):

 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  

  Note: asterisk has to be started "after" festival.


If you see a message such as:
 client(1) : rejected from not in access list
then edit the festival/bin/festival_server startup script to include that FQDM in the line with "localhost.*".

  client(1) : accepted from 
after a place a call to extension 555, then asterisk is making the call to festival.


  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

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

Recommended Links



Groupthink : Two Party System as Polyarchy : Corruption of Regulators : Bureaucracies : Understanding Micromanagers and Control Freaks : Toxic Managers :   Harvard Mafia : Diplomatic Communication : Surviving a Bad Performance Review : Insufficient Retirement Funds as Immanent Problem of Neoliberal Regime : PseudoScience : Who Rules America : Neoliberalism  : The Iron Law of Oligarchy : Libertarian Philosophy


War and Peace : Skeptical Finance : John Kenneth Galbraith :Talleyrand : Oscar Wilde : Otto Von Bismarck : Keynes : George Carlin : Skeptics : Propaganda  : SE quotes : Language Design and Programming Quotes : Random IT-related quotesSomerset Maugham : Marcus Aurelius : Kurt Vonnegut : Eric Hoffer : Winston Churchill : Napoleon Bonaparte : Ambrose BierceBernard Shaw : Mark Twain Quotes


Vol 25, No.12 (December, 2013) Rational Fools vs. Efficient Crooks The efficient markets hypothesis : Political Skeptic Bulletin, 2013 : Unemployment Bulletin, 2010 :  Vol 23, No.10 (October, 2011) An observation about corporate security departments : Slightly Skeptical Euromaydan Chronicles, June 2014 : Greenspan legacy bulletin, 2008 : Vol 25, No.10 (October, 2013) Cryptolocker Trojan (Win32/Crilock.A) : Vol 25, No.08 (August, 2013) Cloud providers as intelligence collection hubs : Financial Humor Bulletin, 2010 : Inequality Bulletin, 2009 : Financial Humor Bulletin, 2008 : Copyleft Problems Bulletin, 2004 : Financial Humor Bulletin, 2011 : Energy Bulletin, 2010 : Malware Protection Bulletin, 2010 : Vol 26, No.1 (January, 2013) Object-Oriented Cult : Political Skeptic Bulletin, 2011 : Vol 23, No.11 (November, 2011) Softpanorama classification of sysadmin horror stories : Vol 25, No.05 (May, 2013) Corporate bullshit as a communication method  : Vol 25, No.06 (June, 2013) A Note on the Relationship of Brooks Law and Conway Law


Fifty glorious years (1950-2000): the triumph of the US computer engineering : Donald Knuth : TAoCP and its Influence of Computer Science : Richard Stallman : Linus Torvalds  : Larry Wall  : John K. Ousterhout : CTSS : Multix OS Unix History : Unix shell history : VI editor : History of pipes concept : Solaris : MS DOSProgramming Languages History : PL/1 : Simula 67 : C : History of GCC developmentScripting Languages : Perl history   : OS History : Mail : DNS : SSH : CPU Instruction Sets : SPARC systems 1987-2006 : Norton Commander : Norton Utilities : Norton Ghost : Frontpage history : Malware Defense History : GNU Screen : OSS early history

Classic books:

The Peter Principle : Parkinson Law : 1984 : The Mythical Man-MonthHow to Solve It by George Polya : The Art of Computer Programming : The Elements of Programming Style : The Unix Haters Handbook : The Jargon file : The True Believer : Programming Pearls : The Good Soldier Svejk : The Power Elite

Most popular humor pages:

Manifest of the Softpanorama IT Slacker Society : Ten Commandments of the IT Slackers Society : Computer Humor Collection : BSD Logo Story : The Cuckoo's Egg : IT Slang : C++ Humor : ARE YOU A BBS ADDICT? : The Perl Purity Test : Object oriented programmers of all nations : Financial Humor : Financial Humor Bulletin, 2008 : Financial Humor Bulletin, 2010 : The Most Comprehensive Collection of Editor-related Humor : Programming Language Humor : Goldman Sachs related humor : Greenspan humor : C Humor : Scripting Humor : Real Programmers Humor : Web Humor : GPL-related Humor : OFM Humor : Politically Incorrect Humor : IDS Humor : "Linux Sucks" Humor : Russian Musical Humor : Best Russian Programmer Humor : Microsoft plans to buy Catholic Church : Richard Stallman Related Humor : Admin Humor : Perl-related Humor : Linus Torvalds Related humor : PseudoScience Related Humor : Networking Humor : Shell Humor : Financial Humor Bulletin, 2011 : Financial Humor Bulletin, 2012 : Financial Humor Bulletin, 2013 : Java Humor : Software Engineering Humor : Sun Solaris Related Humor : Education Humor : IBM Humor : Assembler-related Humor : VIM Humor : Computer Viruses Humor : Bright tomorrow is rescheduled to a day after tomorrow : Classic Computer Humor

The Last but not Least Technology is dominated by two types of people: those who understand what they do not manage and those who manage what they do not understand ~Archibald Putt. Ph.D

Copyright 1996-2021 by Softpanorama Society. was initially created as a service to the (now defunct) UN Sustainable Development Networking Programme (SDNP) without any remuneration. This document is an industrial compilation designed and created exclusively for educational use and is distributed under the Softpanorama Content License. Original materials copyright belong to respective owners. Quotes are made for educational purposes only in compliance with the fair use doctrine.

FAIR USE NOTICE This site contains copyrighted material the use of which has not always been specifically authorized by the copyright owner. We are making such material available to advance understanding of computer science, IT technology, economic, scientific, and social issues. We believe this constitutes a 'fair use' of any such copyrighted material as provided by section 107 of the US Copyright Law according to which such material can be distributed without profit exclusively for research and educational purposes.

This is a Spartan WHYFF (We Help You For Free) site written by people for whom English is not a native language. Grammar and spelling errors should be expected. The site contain some broken links as it develops like a living tree...

You can use PayPal to to buy a cup of coffee for authors of this site


The statements, views and opinions presented on this web page are those of the author (or referenced source) and are not endorsed by, nor do they necessarily reflect, the opinions of the Softpanorama society. We do not warrant the correctness of the information provided or its fitness for any purpose. The site uses AdSense so you need to be aware of Google privacy policy. You you do not want to be tracked by Google please disable Javascript for this site. This site is perfectly usable without Javascript.

Last modified: March 12, 2019