VOIP

Install Festival TTS for Asterisk on Ubuntu 24.04

Festival is a free, open-source text-to-speech (TTS) system developed at the University of Edinburgh. It converts written text into spoken audio – a core requirement for building dynamic IVR menus, voicemail greetings, and call notifications in Asterisk PBX systems.

Original content from computingforgeeks.com - post 46

This guide walks through installing Festival TTS on Ubuntu 24.04, configuring it in server mode, and integrating it with Asterisk using the app_festival module. We also cover alternative TTS engines (eSpeak-NG, Pico TTS) and common troubleshooting steps. Festival 2.4 is the current stable release, available directly from Ubuntu’s default repositories.

Prerequisites

Before starting, confirm you have the following in place:

  • Ubuntu 24.04 LTS server with root or sudo access
  • Asterisk installed and running – see our guide on installing Asterisk 20 LTS on Ubuntu
  • At least 512 MB free RAM for the Festival server process
  • Working SIP phone or softphone for testing (Zoiper, Linphone, etc.)

Step 1: Install Festival TTS on Ubuntu 24.04

Festival and its dependencies are available in Ubuntu’s default repositories. Install the base package along with the speech tools library.

sudo apt update
sudo apt install -y festival festvox-kallpc16k

The festvox-kallpc16k package provides the default American English male voice (kal) at 16kHz sample rate, which produces better audio quality than the 8kHz version bundled with the base install.

Verify the installation completed successfully by checking the Festival version.

festival --version

The output confirms Festival 2.4 is installed:

Festival Speech Synthesis System 2.4:release July 2014
Edinburgh Speech Tools Library 2.4:release July 2014

Step 2: Test Festival From the Command Line

Before integrating with Asterisk, confirm Festival works standalone. The quickest test sends a text string through Festival’s text2wave utility to generate a WAV file.

echo "Hello, this is a test of Festival text to speech on Ubuntu." | text2wave -o /tmp/test_tts.wav

Check the generated audio file exists and has a reasonable size:

ls -lh /tmp/test_tts.wav

A typical short sentence produces a WAV file between 50-200 KB:

-rw-r--r-- 1 root root 156K Mar 22 10:30 /tmp/test_tts.wav

You can also test Festival interactively to verify the synthesis engine is working. Enter the Festival shell and run a quick speech test.

festival

Inside the Festival interactive prompt, type these Scheme commands:

festival> (SayText "Testing Festival text to speech")
festival> (quit)

If your server has audio output configured, you will hear the synthesized speech. On headless servers, use the text2wave method above and download the WAV file to test locally.

Step 3: Install Additional Festival Voices

The default kal voice works fine for testing, but you may want higher-quality or different voices for production IVR systems. Ubuntu provides several voice packages.

List all available Festival voice packages in the repository.

apt-cache search festvox

Common voice packages you can install include:

PackageDescription
festvox-kallpc16kAmerican English male (kal) – 16kHz, default
festvox-donBritish English male (don)
festvox-rablpc16kAmerican English male (rab) – 16kHz
festvox-us-slt-htsAmerican English female (slt) – HTS engine
festvox-ellpc11kCastilian Spanish male

Install additional voices as needed. For example, to add the British English male and American English female voices:

sudo apt install -y festvox-don festvox-us-slt-hts

Verify the installed voices are recognized by Festival:

festival -b '(voice.list)'

This prints a list of all available voices, for example:

(kal_diphone don_diphone us_slt_arctic_hts rab_diphone)

Step 4: Configure Festival in Server Mode

Asterisk connects to Festival over a TCP socket. Festival must run as a persistent server process listening on port 1314 (the default). This is how app_festival sends text and receives synthesized audio.

First, create a Festival configuration file that enables server mode and sets the default voice.

sudo vi /etc/festival.conf

Add the following configuration to enable the Festival server, restrict access to localhost, and set the default voice:

;; Festival configuration for Asterisk integration
;; Listen on localhost only for security
(set! server_port 1314)
(set! server_log_file "/var/log/festival.log")
(set! server_passwd nil)
(set! server_access_list '("localhost" "127.0.0.1"))

;; Set default voice
(set! default_voice 'kal_diphone)

;; Increase server timeout for long text
(set! server_timeout 0)

The server_access_list restricts connections to localhost only. If Asterisk runs on a different server, add that IP to the list. The server_timeout 0 setting prevents the server from closing idle connections.

Create a systemd service unit so Festival starts automatically and runs as a background daemon.

sudo vi /etc/systemd/system/festival.service

Add the following service definition:

[Unit]
Description=Festival Speech Synthesis Server
After=network.target

[Service]
Type=simple
ExecStart=/usr/bin/festival --server
Restart=on-failure
RestartSec=5
User=nobody
Group=nogroup

[Install]
WantedBy=multi-user.target

Enable and start the Festival server service.

sudo systemctl daemon-reload
sudo systemctl enable --now festival.service

Verify the service is running and listening on port 1314:

sudo systemctl status festival.service

The output should show the service as active and running:

● festival.service - Festival Speech Synthesis Server
     Loaded: loaded (/etc/systemd/system/festival.service; enabled; preset: enabled)
     Active: active (running) since Sat 2026-03-22 10:45:00 UTC; 5s ago
   Main PID: 12345 (festival)
     Memory: 24.0M
        CPU: 500ms
     CGroup: /system.slice/festival.service
             └─12345 /usr/bin/festival --server

Confirm the server is listening on port 1314:

ss -tlnp | grep 1314

You should see Festival bound to the port:

LISTEN  0  5  *:1314  *:*  users:(("festival",pid=12345,fd=3))

Step 5: Configure Asterisk to Use Festival TTS

Asterisk communicates with Festival through the app_festival module and a helper AGI script. The module sends text to the Festival server, receives the synthesized audio, and plays it to the caller. This is documented in the Asterisk Festival application reference.

First, verify the app_festival module is loaded in Asterisk:

sudo asterisk -rx "module show like festival"

You should see the module listed as loaded:

Module                         Description                              Use Count  Status
app_festival.so                Simple Festival Interface                 0          Running
1 modules loaded

If the module is not loaded, load it manually and add it to the modules configuration:

sudo asterisk -rx "module load app_festival.so"

Next, configure the Festival connection settings in Asterisk. Open the Festival configuration file.

sudo vi /etc/asterisk/festival.conf

Set the Festival server host, port, and audio caching options:

[general]
; Festival server connection settings
host=localhost
port=1314

; Cache synthesized audio to reduce processing time
; Set to yes if you reuse the same phrases frequently
usecache=no
cachedir=/var/lib/asterisk/festivalcache/

; Festivalcommand sets the TTS command sent to Festival
; (tts_textasterisk "%s" 'file) is the default
festivalcommand=(tts_textasterisk "%s" 'file)

If you enable caching, create the cache directory:

sudo mkdir -p /var/lib/asterisk/festivalcache
sudo chown asterisk:asterisk /var/lib/asterisk/festivalcache

Reload the Asterisk dialplan to pick up the configuration changes:

sudo asterisk -rx "module reload app_festival.so"

Step 6: Create an IVR With Festival TTS

With Festival and Asterisk configured, create a simple dialplan that uses TTS to greet callers and present menu options. This demonstrates how Festival() works in a real call flow.

Open the Asterisk extensions configuration file.

sudo vi /etc/asterisk/extensions.conf

Add the following IVR context that uses Festival for dynamic TTS prompts:

[festival-demo]
; Simple IVR using Festival TTS
exten => 100,1,Answer()
 same => n,Festival(Welcome to the company phone system.)
 same => n,Festival(Press 1 for sales. Press 2 for support. Press 3 to leave a message.)
 same => n,WaitExten(5)

exten => 1,1,Festival(Connecting you to the sales department. Please hold.)
 same => n,Dial(SIP/sales,30)
 same => n,Hangup()

exten => 2,1,Festival(Connecting you to technical support.)
 same => n,Dial(SIP/support,30)
 same => n,Hangup()

exten => 3,1,Festival(Please leave your message after the tone.)
 same => n,Voicemail(100@default)
 same => n,Hangup()

exten => t,1,Festival(No input received. Goodbye.)
 same => n,Hangup()

exten => i,1,Festival(Invalid selection. Please try again.)
 same => n,Goto(festival-demo,100,1)

Reload the dialplan:

sudo asterisk -rx "dialplan reload"

Test the IVR by dialing extension 100 from a SIP phone registered to your Asterisk server. You should hear Festival speaking the welcome message and menu options.

For a quick CLI test without a SIP phone, use the Asterisk console to originate a call:

sudo asterisk -rx "channel originate Local/100@festival-demo application Echo"

Check the Asterisk log for any Festival connection errors:

sudo tail -20 /var/log/asterisk/messages | grep -i festival

Step 7: Alternative TTS Engines – eSpeak-NG and Pico TTS

Festival works well for basic TTS needs, but two other free engines are worth considering depending on your requirements.

eSpeak-NG

eSpeak-NG is a compact, formant-based speech synthesizer that supports over 100 languages. The audio quality is more robotic than Festival, but it starts faster and uses less memory – useful on resource-constrained systems.

sudo apt install -y espeak-ng

Test eSpeak-NG from the command line by generating a WAV file:

espeak-ng "This is a test of eSpeak NG text to speech" -w /tmp/espeak_test.wav

To use eSpeak-NG with Asterisk, you would generate WAV files externally and play them using the Playback() application, or use an AGI script that calls eSpeak-NG and feeds the audio back to the call.

Pico TTS (SVOX)

Pico TTS produces noticeably more natural-sounding speech than both Festival and eSpeak. It supports English, French, German, Italian, and Spanish.

sudo apt install -y libttspico-utils

Generate a test WAV file with Pico:

pico2wave -w /tmp/pico_test.wav "This is a test of Pico text to speech"

Pico TTS does not have a native Asterisk module like Festival does. The typical integration approach is writing an AGI script that calls pico2wave, converts the output to Asterisk’s preferred format (8kHz, 16-bit, mono WAV or SLN), and plays it using Playback(). For production IVR systems where voice quality matters, Pico is a strong choice over Festival.

Step 8: Troubleshoot Festival and Asterisk TTS

Here are the most common issues when running Festival with Asterisk and how to fix them.

Festival server not responding

If Asterisk logs show “connect to Festival failed” errors, check that the Festival service is running and the port is open.

sudo systemctl status festival.service
ss -tlnp | grep 1314

Test the connection manually using netcat:

echo "(SayText \"test\")" | nc localhost 1314

If netcat connects but gets no response, check the Festival log for errors:

sudo cat /var/log/festival.log

No audio played to caller

This usually means Asterisk received the audio but could not play it. Check that the app_festival module is loaded and the festival.conf settings match your Festival server.

sudo asterisk -rx "module show like festival"
sudo asterisk -rx "festival show settings"

Also verify Asterisk has write access to the /tmp directory, which it uses to store temporary audio files from Festival.

Audio quality issues

Festival’s diphone voices can sound choppy. Use the 16kHz voice packages (kal16k, rab16k) instead of the default 8kHz versions. If audio quality is critical for your use case, consider the HTS voices or switch to Pico TTS as described in Step 7.

Permission denied errors

If Festival runs as nobody (as configured in our systemd unit), it needs read access to voice data files. Verify permissions on the Festival data directory:

ls -la /usr/share/festival/voices/

The voice directories should be world-readable. If not, fix the permissions:

sudo chmod -R o+r /usr/share/festival/voices/

Firewall considerations

Festival listens on TCP port 1314. If Asterisk and Festival run on the same server (which is the recommended setup), no firewall changes are needed since traffic stays on localhost. If they run on separate servers, open port 1314 on the Festival server:

sudo ufw allow from 10.0.1.5 to any port 1314 proto tcp comment "Asterisk to Festival"

Replace 10.0.1.5 with your Asterisk server’s IP address. Never expose Festival to the public internet – it has no authentication mechanism.

Conclusion

Festival provides a straightforward, free TTS solution for Asterisk-based phone systems on Ubuntu 24.04. The server mode integration through app_festival requires minimal configuration – install the package, start the server, point Asterisk at it, and call Festival() in your dialplan. For production deployments where voice quality is a priority, pair Festival with the 16kHz voice packages or evaluate Pico TTS as an alternative. Keep the Festival server restricted to localhost or trusted IPs, and consider FreePBX for a web-based management interface on top of your Asterisk setup.

Related Articles

Ubuntu How To Install PHP 8.0 on Ubuntu 24.04|22.04|20.04 Containers Run Home Assistant in Docker and Docker Compose on Ubuntu 24.04 Ubuntu How To Install phpList on Ubuntu 22.04|20.04|18.04 Ubuntu Install NoMachine RDP on Ubuntu 22.04|20.04|18.04

Leave a Comment

Press ESC to close