November 2011 - Teknologi Suara

HOWTO: Make festival TTS use better voices (MBROLA / CMU / HTS)

Introduction


Festival is a Text-To-Speech synthesis system developed at the University of Edinburgh. It can be used with several different voices, which are the models and data it uses to convert typed text into audible speech.

This HOWTO is meant to be a centralized collection of information about how to install the currently available voices for the Festival TTS. While sections of this HOWTO may apply to installing voices for other languages, it is primarily concerned with the English language voices.

The layout of this HOWTO is as follows:
  • Installing the standard Festvox diphone voices
  • Installing the enhanced MBROLA voices
  • Installing the enhanced CMU Arctic voices
  • Installing the enhanced Nitech HTS voices
  • Testing voices and choosing a default voice
  • Installing Festival 1.96 from source

Before we get started, make sure all of the preliminary packages are installed on your system with the following command:

Code:
sudo apt-get install festival festlex-cmu festlex-poslex festlex-oald libestools1.2 unzip

Installing the standard Festvox diphone voices

These are the voices that are supplied by the Festvox project, which is run by the Carnegie Mellon University speech group. See the voice demo page (kal, ked, don and rab are the voices of interest). Of all of the voices we are concerned with, these take up the smallest size on disk, and are the only voices currently in the Ubuntu package tree. All of the other voices have to be installed manually. However, these are also the poorest quality voices and currently, on my computer, they cause festival to segfault (though I have used them successfully with other set-ups in the past). YMMV.

Some of the voices have 8k and 16k versions. This is the output frequency of the audio synthesis. The 16k versions have higher quality output and sound better. The four English voices are:

festvox-don
festvox-rablpc[8|16]k
festvox-kallpc[8|16]k
festvox-kdlpc[8|16]k

Searching for other voices to install

To find all the available festvox voices, execute the following command:

Code:
apt-cache search festvox-*

Installing the voices

Once you've decided on the voices to install, just install them as you would any other apt package. For example, this command will install all of the English voices using the higher quality 16k voices:

Code:
sudo apt-get install festvox-don festvox-rablpc16k festvox-kallpc16k festvox-kdlpc16k

Installing the enhanced MBROLA voices

These voices are provided by the MBROLA project, run by the TCTS Lab of the Faculté Polytechnique de Mons in Belgium. They offer several voices, in a variety of languages, which sound much better than the Festvox diphone voices. The database of voices can be viewed at the project's download page. See the voice demo page (the us1, us2 and us3 are the voices of interest). To use the MBROLA voices we need three parts: (1.) the mbrola binary program that parses a tokenstream the festival program feeds it and returns audio data back to festival, (2.) the MBROLA voices, and (3.) the Festvox wrappers to let the festival program use the voices. This may sound scary, but it's really very easy to do.

Downloading the voices, binary and wrappers

We will download everything we need for the English voices into a temporary directory (total download size is approximately twenty megs):

Code:
mkdir mbrola_tmp
cd mbrola_tmp/
s.fpms.ac.be/synthesis/mbrola/bin/pclinux/mbrola3.0.1h_i386.deb
wget -c http:/
wget http://tc
t/tcts.fpms.ac.be/synthesis/mbrola/dba/us1/us1-980512.zip
2-980812.zip
wget -c http://tcts.fpms.ac.be/synthesis/mbrola/dba/us3/u
wget -c http://tcts.fpms.ac.be/synthesis/mbrola/dba/us2/u
ss3-990208.zip
wget -c http://www.festvox.org/packed/festival/latest/festvox_us1.tar.gz
www.festvox.org/packed/festival/latest/festvox_us3.tar.gz
wget -c http://www.festvox.org/packed/festival/latest/festvox_us2.tar.gz
wget -c http:/
/

Installing the binary, unpacking the voices and wrappers

Since the MBROLA project has kindly provided us with a binary deb, we can skip the step of building the binary from souce and just use dpkg to install it:

Code:
sudo dpkg -i mbrola3.0.1h_i386.deb

If you're paranoid about installing a deb from a third-party like the MBROLA project, you can grab the binary in a zip file from their download page and install it manually. There doesn't appear to be any source package released to the public, so if you're extremely paranoid, you may just want to avoid using the MBROLA voices altogether. I've personally never had a problem using the binary either from the zip or the deb.

Next we'll unpack the voices and the wrappers:

Code:
unzip -x us1-980512.zip
unzip -x us2-980812.zip
tar xvf festvox_us1.tar
unzip -x us3-990208.zip
.gz
ar xvf festvox_us3.tar.gz
tar xvf festvox_us2.tar.gz

t

Installing the voices and wrappers

First we'll make the directories where the voices will be installed:

Code:
sudo mkdir -p /usr/share/festival/voices/english/us1_mbrola/
sudo mkdir -p /usr/share/festival/voices/english/us2_mbrola/
sudo mkdir -p /usr/share/festival/voices/english/us3_mbrola/

Then we can install the voices and wrappers there:

Code:
sudo mv us1 /usr/share/festival/voices/english/us1_mbrola/
sudo mv us2 /usr/share/festival/voices/english/us2_mbrola/
sudo mv festival/lib/voices/english/us1_mbrola/* /usr/shar
sudo mv us3 /usr/share/festival/voices/english/us3_mbrola/
e/festival/voices/english/us1_mbrola/
udo mv festival/lib/voices/english/us3_mbrola/* /usr/share/festival/voices/english/us3_mbrola/
sudo mv festival/lib/voices/english/us2_mbrola/* /usr/share/festival/voices/english/us2_mbrola/

s

Tidy up

Lastly, we can remove the temporary directory:

Code:
cd ../
rm -rf mbrola_tmp/

If all went well, you now have a set of working MBROLA voices installed. See the section below on how to test that the voices are working properly.


Installing the enhanced CMU Arctic voices

These voices were developed by the Language Technologies Institute at Carnegie Mellon University. They sound much better than both the diphone and the MBROLA voices. See the information page and voice demo page (the *_arctic_cg are the voices of interest). The drawback is that each voice takes over a hundred megs on disk, and with six English voices to choose from, that can take up a lot of bandwidth to download and depending on how much disk space you have to work with, six-hundred plus megs of space might be a bit much for voice data. However, the HTS voices discussed in the next section may in fact provide equal or better quality synthesis, and are only less than %2 of the size.

Downloading the voices

We will download everything we need for the English voices into a temporary directory (total download size is approximately six-hundred megs — you might want to go brew some coffee or something, lots of it...we might be here a while):

Code:
mkdir cmu_tmp
cd cmu_tmp/
://www.speech.cs.cmu.edu/cmu_arctic/packed/cmu_us_awb_arctic-0.90-release.tar.bz2
wget -c htt
wget -c htt
pp://www.speech.cs.cmu.edu/cmu_arctic/packed/cmu_us_bdl_arctic-0.95-release.tar.bz2
e.tar.bz2
wget -c http://www.speech.cs.cmu.edu/cmu_arctic/packed/cmu_us_jmk_arctic-0.95-relea
wget -c http://www.speech.cs.cmu.edu/cmu_arctic/packed/cmu_us_clb_arctic-0.95-relea
sse.tar.bz2
wget -c http://www.speech.cs.cmu.edu/cmu_arctic/packed/cmu_us_rms_arctic-0.95-release.tar.bz2
wget -c http://www.speech.cs.cmu.edu/cmu_arctic/packed/cmu_us_slt_arctic-0.95-release.tar.bz2
Note: You can add the option "--limit-rate" to wget to set a maximum transfer speed (e.g., "wget -c --limit-rate=60K ..." to limit the download rate to 60KB/s).

Unpacking the voices

Due to the size of the archives, this will probably take a few minutes as well (Maybe get a slice of cake this time? Also, note than tar is run non-verbosely so we don't have seven-million lines flooding the terminal):

Code:
for t in `ls cmu_*` ; do tar xf $t ; done
rm *.bz2

Installing the voices

Now we can install the voices:

Code:
sudo mkdir -p /usr/share/festival/voices/english/
sudo mv * /usr/share/festival/voices/english/

The voices are now installed, but Festival requires them to have slightly different directory names, so we'll rename the directories as needed.

Code:
for d in `ls /usr/share/festival/voices/english` ; do
if [[ "$d" =~ "cmu_us_" ]] ; then
s/english/${d}" "/usr/share/festival/voices/english/${d}_clunits" 
fi ; done
sudo mv "/usr/share/festival/voic
e
Note: We could just use symlinks, but then the list of installed voices (see section below on testing voices) would show entries for the actual directories and the symlinks, though only the symlinks would work properly.


Tidy up

Lastly, we can remove the temporary directory:

Code:
cd ../
rm -rf cmu_tmp/

If all went well, you now have a set of working CMU Arctic voices installed. See the section below on how to test that the voices are working properly.


Installing the enhanced Nitech HTS voices

Note: Unfortunately, these voices require at least Festival 1.95, but only 1.4 is available on Ubuntu prior to Hardy (8.04). This means that if you want to use these voices on any prior release (Gutsy, Feisty...), you need to compile Festival from source. This is relatively easy to do, and a section at the bottom of this HOWTO will guide you through the process. Don't waste your time trying to install these voices on Festival versions less that 1.95, they just won't work.

These voices are produced by the HTS working group hosted at the Nagoya Institute of Technology. They have produced excellent quality voices which take up very little disk space. In terms of quality and size, probably the best (non-commercial) English voices availible for Festival. See the voice demo page (the *_arctic_hts are the voices of interest). Highly recommended. The voices are available on their download page.

Downloading the voices

We will download everything we need for the English voices into a temporary directory (total download size is approximately ten megs):

Code:
mkdir hts_tmp
cd hts_tmp/
://hts.sp.nitech.ac.jp/archives/2.1/festvox_nitech_us_awb_arctic_hts-2.1.tar.bz2
wget -c htt
wget -c htt
pp://hts.sp.nitech.ac.jp/archives/2.1/festvox_nitech_us_bdl_arctic_hts-2.1.tar.bz2
1.tar.bz2
wget -c http://hts.sp.nitech.ac.jp/archives/2.1/festvox_nitech_us_rms_arctic_hts-2
wget -c http://hts.sp.nitech.ac.jp/archives/2.1/festvox_nitech_us_clb_arctic_hts-2
..1.tar.bz2
wget -c http://hts.sp.nitech.ac.jp/archives/2.1/festvox_nitech_us_slt_arctic_hts-2.1.tar.bz2
://hts.sp.nitech.ac.jp/archives/1.1.1/cmu_us_kal_com_hts.tar.gz
wget -c http://hts.sp.nitech
wget -c http://hts.sp.nitech.ac.jp/archives/2.1/festvox_nitech_us_jmk_arctic_hts-2.1.tar.bz2
wget -c htt
p.ac.jp/archives/1.1.1/cstr_us_ked_timit_hts.tar.gz

Unpacking the voices

Next we'll unpack the voices:

Code:
for t in `ls` ; do tar xvf $t ; done

Installing the voices

Now we can install the voices:

Code:
sudo mkdir -p /usr/share/festival/voices/us
sudo mv lib/voices/us/* /usr/share/festival/voices/us/
sudo mv lib/hts.scm /usr/share/festival/hts.scm

Tidy up

Lastly, we can remove the temporary directory:

Code:
cd ../
rm -rf hts_tmp/

If all went well, you now have a set of working Nitech HTS voices installed. See the section below on how to test that the voices are working properly.


Testing voices and choosing a default voice

Now that you have some voices to play with, you may want to try out different voices to suite your taste, or just to make sure things are working properly. To get a list of all the voices that are installed, you can simply look at the directories under /usr/share/festival/voices:

Code:
for d in `ls /usr/share/festival/voices` ; do ls "/usr/share/festival/voices/${d}" ; done

Or you can run the fetival program, and, at the prompt, enter (voice.list). The result will look something like this:

Code:
festival> (voice.list)
(us1_mbrola
us2_mbrola
us3_mbrola
lt_arctic_hts
 nitech_us_
nitech_us_
sjmk_arctic_hts
rctic_hts
 nitech_us_rms_
nitech_us_clb_
aarctic_hts
 nitech_us_bdl_arctic_hts
nitech_us_awb_arctic_hts)

Playing with the voices

To select a voice, add the prefix "voice_" to the voice name, and surround it by parentheses:

Code:
festival> (voice_us2_mbrola)

Then you can test it using (SayText "The text") to speak a single line of text, or (tts "somefile.txt" nil) to process an entire file. You can also hear a short introduction about Festival with (intro).

Code:
festival> (SayText "Hello from Ubuntu")
festival> (tts "story.txt" nil)
festival> (intro)

Selecting a default voice

You can edit the file /etc/festival.scm to select a default voice. Open the file in your favorite editor (you will need super-user privleges, so run it with sudo or gksu) and add the line:

Code:
(set! voice_default 'voice_nitech_us_rms_arctic_hts)

Simply replace "voice_nitech_us_rms_arctic_hts" with whatever your favorite voice is.

Making it work with PulseAudio, ESD or ALSA

By default, festival tries to synthesize speech to /dev/dsp using OSS. To make it work with ESD, PulseAudio or ALSA you have two options. The first is to use a wrapper to call festival, and the second is to make festival internally try to use one of them output. The advantage to the first method is that you can use the esd, pluseaudio or the alsa wrapper at any time, without having to edit the config file. The advantage of the second method is that you don't have to remember to call the wrapper—directly running festival works.

The available wrappers I know of are: the aoss wrapper program from the alsa-oss package, the padsp wrapper from pulseaudio-utils, and the esddsp wrapper from esound-clients — but caveat emptor — there is a bug (#214465) in the esddsp script right now (see this post for a quick-fix).

To use the internal method, see the instructions for editing /etc/festival.scm at the community docs on TextToSpeech.

An example /etc/festival.scm

This is a drop-in /etc/festival.scm file. It covers all of the options mentioned about selecting a default voice and using ESD or ALSA for audio output. The ";;" are comment specifiers, so to use any of the options simply uncomment them by removing the ";;" in from of them and adding it to whatever you want to deactivate. It doesn't matter whether you have two different options uncommented at the same time (e.g., two different default_voice options), Festival will simply use whichever one is defined last in the file, however it may be a little bit slower to start up in such a case and it's better to just uncomment the one you want to use.

Code:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;
;;;; setup audio output
;;;;
;;;;;;;;;;;

;;;; defaults to oss output

;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; use pulseaudio to output sound
aplay $FILE") 
;;(Parameter.set 'Audio_Method 'A
;;(Parameter.set 'Audio_Command "
pudio_Command)
;;(Parameter.set 'Audio_Required_Format 'snd)

esdplay $FILE") 
;;(Paramete
;;;; use esd to output sound
;;(Parameter.set 'Audio_Command 
"r.set 'Audio_Method 'Audio_Command)
;;(Parameter.set 'Audio_Required_Format 'snd)

-c 1 -t raw -f s16 -r $SR $F
;;;; use alsa to output sound
;;(Parameter.set 'Audio_Command "aplay -D plug:dmix -
qILE") 
;;(Parameter.set 'Audio_Method 'Audio_Command)
;;(Parameter.set 'Audio_Required_Format 'snd)


;;;;;;;;;;;;;;;;;;

;;;; Festvox voices
;;(set
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;
;;;; setup voices
;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;
;! default_voice 'voice_rab_diphone)
;;(set! default_voice 'voice_don_diphone)
;;(set! default_voice 'voice_kal_diphone)
ice 'voice_us2_mbrola)
;;(set! default_vo
;;(set! default_voice 'voice_ked_diphone)

;;;; MBROLA voices
;;(set! default_voice 'voice_us1_mbrola)
;;(set! default_v
oice 'voice_us3_mbrola)

;;;; CMU Arctic voices
;;(set! voice_default 'voice_cmu_us_rms_arctic_clunits)
;;(set! voice_default 'voice_cmu_us_bdl_arctic_clunits)
lunits)
;;(set! voice_default 'voice_cmu_us_jmk_arctic_
;;(set! voice_default 'voice_cmu_us_slt_arctic_clunits)
;;(set! voice_default 'voice_cmu_us_clb_arctic_clunits)
;;(set! voice_default 'voice_cmu_us_awb_arctic_
cclunits)

;;;; Nitech HTS voices
(set! voice_default 'voice_nitech_us_rms_arctic_hts)
;;(set! voice_default 'voice_nitech_us_bdl_arctic_hts)
;;(set! voice_default 'voice_nitech_us_slt_arctic_hts)
_us_kal_com_hts)
;;(set! voice_default 'voice_cstr_us_
;;(set! voice_default 'voice_nitech_us_clb_arctic_hts)
;;(set! voice_default 'voice_nitech_us_awb_arctic_hts)
;;(set! voice_default 'voice_nitech_us_jmk_arctic_hts)
;;(set! voice_default 'voice_cm
uked_timit_hts)


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;
;;;; Advanced voice configuration
;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;; Slow the HTS speech down.
;;(set! hts_duration_stretch 0.1)

;;;; Slow the standard voices down
;;(Parameter.set 'Duration_Stretch 2.5)

;;;; Set volume.
;;(set! default_after_synth_hooks
;;    (list (lambda (utt) (utt.wave.rescale utt 2.0 t))))
Note: Advanced voice config based on this page


Installing Festival 1.96 from source

Note: If you have any errors that stop the build process, please report them here so I can update the HOWTO. Even if it's something trivial like a broken path, and you fix it yourself, others may not know how to fix it.

The HTS voices above require at lest Festival 1.95. Here we will go through the steps necessary to build and install Festival 1.96. This method was tested on the Dapper 6.06.1 VMplayer appliance using VirtualBox, so it should work on all Ubuntu releases. We will build a backport using official Ubuntu sources, so you don't need to remove any existing festival installation — apt will upgrade it for you.

We firstly need some development tools, libraries and headers. Use the following command to install the build requirements:

Code:
sudo apt-get install autotools-dev debhelper gawk libesd0-dev libncurses5-dev quilt g++ texinfo dpkg-dev devscripts fakeroot

Say yes to whatever dependencies are required.

Downloading the source packages

We will download everything we need for building Festival 1.96 into a temporary directory (total download size is approximately five megs):

Code:
mkdir fest_tmp
cd fest_tmp/
//archive.ubuntu.com/ubuntu/pool/universe/s/speech-tools/speech-tools_1.2.96~beta-2.dsc
wget -c http
wget -c http
:://archive.ubuntu.com/ubuntu/pool/universe/s/speech-tools/speech-tools_1.2.96~beta.orig.tar.gz
.diff.gz
wget -c http://archive.ubuntu.com/ubuntu/pool/universe/f/festival/festival_1.96~beta-7ubuntu1.d
wget -c http://archive.ubuntu.com/ubuntu/pool/universe/s/speech-tools/speech-tools_1.2.96~beta-
2sc
wget -c http://archive.ubuntu.com/ubuntu/pool/universe/f/festival/festival_1.96~beta.orig.tar.gz
wget -c http://archive.ubuntu.com/ubuntu/pool/universe/f/festival/festival_1.96~beta-7ubuntu1.diff.g
z

Unpacking the sources

Next we'll unpack the sources and fix some versioning stuff so we can backport:

Code:
sed -i -e "s/(>= 5)/(>= 4.1.75)/" festival_1.96~beta-7ubuntu1.dsc
sed -i -e "s/(>= 5)/(>= 4)/" speech-tools_1.2.96~beta-2.dsc
x speech-tools_1.2.96~beta-2.dsc
sed -i -e "s/
dpkg-source -x festival_1.96~beta-7ubuntu1.dsc
dpkg-source 
-(>= 5)/(>= 4)/" -e "s/\${binary:Version}/\${Source-Version}/g" speech-tools-1.2.96~beta/debian/control
"s/\${binary:Version}/\${Source-Version}/g" festival-1.96~beta/debian/control
sed -i -e "s/(>= 5)/(>= 4.1.75)/" -e "s/ (>= 3.105)//" -e "s/ (>= 3.0-10)//" -e "s/ (>= 2.86.ds1)//" -e
 

Compiling and installing the sources

Now we can compile the sources. Firstly we need to compile the Speech Tools. I'm using debuild because it makes it easier.

Code:
cd speech-tools-1.2.96~beta/
debuild binary
cd ../

This should have created three deb files, which we need to install before we can build and install Festival:

Code:
sudo dpkg -i libestools1.2_1.2.96~beta-2_i386.deb libestools1.2-dev_1.2.96~beta-2_i386.deb speech-tools_1.2.96~beta-2_i386.deb

Now we can build Festival, but first we should add a patch for HTS voices (patch derived from Nitech hts.scm file included in their voices). This step is optional, but recommended, as it can improve the synthesis in some circumstances. Save the following file to festival-1.96~beta/debian/patches/lib_hts.scm.diff:

Code:
--- a/lib/hts.scm
+++ b/lib/hts.scm
@
   (format ofd "+
@@ -108,7 +108,7 
@%s" (if (string-equal "0" (item.feat s "n.name"))
"x" (item.feat s "n.name")))
 ;  nn.name
tem.feat s "n.n.name"))
+  (format ofd "=%s" (if (string-equal "0" (
-  (format ofd "+%s" (if (string-equal "0" (
iitem.feat s "n.n.name"))
    "x" (item.feat s "n.n.name")))
 
 ;  position in syllable (segment)
)
 
 ;  distance fr
@@ -299,7 +299,7 @@
        (item.feat s "R:SylStructure.parent.parent.R:Word.content_words_out")
)om content word in phrase
-  (format ofd ";%s" 
+  (format ofd "#%s" 
item.feat s "R:SylStructure.parent.parent.R:Word.
(if (string-equal "pau" (item.feat s "name"))
        "x"
        
(lisp_distance_to_p_content")))
@@ -377,7 +377,7 @@
:Phrase.parent.n.lisp_num_syls_in_phrase")))
 
 ;  length of next phrase (word)
-  (format ofd "
(item.feat s "R:SylStructure.parent.parent.
R=:%s" 
+  (format ofd "=%s" 
    (if (string-equal "pau" (item.feat s "name"))
rds_in_phrase")
        (item.feat s "R:SylStructure.parent.parent.R:Phrase.parent.n.lisp_num_w
(item.feat s "n.R:SylStructure.parent.parent.R:Phrase.parent.lisp_num_w
oords_in_phrase")))
Note: This file needs to preserve formatting and tab characters! If you get an error about patching failing in the patch command below, try downloading the file from here(right-click save-as) and re-running the patch command. Alternately, you could grab the hts.scm file from a Nitech HTS voice (see section above) and replace the festival-1.96~beta/lib/hts.scm file with it, and skip the patch step.

Now for the actual build:

Code:
cd festival-1.96~beta/
patch -p1 -i debian/patches/lib_hts.scm.diff
debuild binary
cd ../

And now the install:

Code:
sudo dpkg -i festival_1.96~beta-7ubuntu1_i386.deb festival-dev_1.96~beta-7ubuntu1_i386.deb
sudo apt-get install festlex-cmu festlex-poslex

Tidy up

Lastly, we can remove the temporary directory:

Code:
cd ../
rm -rf fest_tmp/

If all went well, you now have Fastival 1.96 installed.


That's it! Have fun!
__________________
[People] are usually satisfied with bad argument only when their convictions rest on other grounds. (John Oman, Grace and Personality [New York: Macmillan, 1925], p. 38).