There are multiple options for text to speech under freebsd , for example espeak and festival . This tutorial is about festival .
To install festival , issue the following command :
root$ pkg install festival
After installing festival , you must also install one of the voices , you can search for available voices using :
$ pkg search festvox # Search for available festival voices # to install . festvox-cmu_us_awb_arctic-0.95 CMU US English Scottish male voice for festival festvox-cmu_us_bdl_arctic-0.95 CMU US English male voice for festival festvox-cmu_us_clb_arctic-0.95 CMU US English female voice for festival festvox-cmu_us_jmk_arctic-0.95 CMU US English Canadian male voice for festival festvox-cmu_us_ksp_arctic-0.95 CMU US English Indian male voice for festival festvox-cmu_us_rms_arctic-0.95 CMU US English male voice for festival festvox-cmu_us_slt_arctic-0.95 CMU US English female voice for festival festvox-el11-1.4.0_2 Castilian Spanish male voice for Festival ... ... festvox-russian-0.5 Russian male voice for Festival speech synthesis system
As an example to install festvox-cmu_us_bdl_arctic-0.95 , issue the following command :
root$ pkg install festvox-cmu_us_bdl_arctic-0.95
After having installed festival , and one of the sounds under freeBSD , to configure festival, edit the siteinit.scm and voices.scm files :
root$ nano /usr/local/share/festival/lib/siteinit.scm
# Edit the siteinit.scm
# and add the following line :
(Parameter.set 'Audio_Method 'freebsd16audio)
root$ nano /usr/local/share/festival/lib/voices.scm
# Edit the voices.scm , and search
# using ctrl-w , if you are using
# nano for :
# (defvar default-voice-priority-list
# and add after '(
# the name of the voice , you just
# downloaded , for example for
# cmu_us_bdl_arctic_clunits :
(defvar default-voice-priority-list
'(cmu_us_bdl_arctic_clunits
kal_diphone
.....
Now to use festival , to read a file , you can just issue the command :
$ festival --tts nameOfFile
If you want to make festival read , a selection of text , then you can do it like so :
root$ pkg install xsel-conrad # Install a program , to access # selection from the x windowing # system , from the command # line . $ mkdir ~/bin && cd ~/bin # As a regular user , # create a bin directory in # your home folder and # cd into it . $ echo '#!/bin/sh' > festival.sh $ echo 'xsel | festival --tts' >> festival.sh $ chmod +x festival.sh # Create a script , which will # pipe what is selected to # festival . # Make the script executable .
Launch , the application finder using ALT+F3 , and type in Keyboard , and select the Edit Keyboard Setting .

Next select application shortcuts , Add , and select the script that was just created . On the next screen , assign a shortcut to , this script , for example Alt+1.
Now when you select some text , and press the assigned shortcut keys , festival will read the text .
In the same manner , you can create another shortcut to make festival stop reading , in this case , the command to be executed is pkill audsp .
If you want to save the output of festival , as an audio file , edit siteinit.scm , and add the following :
root$ nano /usr/local/share/festival/lib/siteinit.scm # Open the siteinit file and # comment out the line : # (Parameter.set 'Audio_Method 'freebsd16audio) # like this : ;(Parameter.set 'Audio_Method 'freebsd16audio) # And add these three lines . # These lines , will set the audio # method , to be a command , and # the format , to be sound , and # the command to be executed , # is to copy the generated sound , # into a file called tmp.wav , # in the same directory , where # the festival command is executed . (Parameter.set 'Audio_Method 'Audio_Command) (Parameter.set 'Audio_Required_Format 'snd) (Parameter.set 'Audio_Command "cp $FILE tmp.wav")
Now to create a wav file , you can just issue the following commands :
$ festival --tts nameOfFile # Will create a tmp.wav file # from the provided text file . $ xsel | festival --tts # Will create a tmp.wav file # from the selection .
It seems when using this method , festival will only convert one line , so it will stop conversion on periods . , colons : , new lines , and possibly on other punctuation marks .
As such , a solution to this problem , is to convert all periods , colons , new lines … to commas , before the start of the audio conversion .
$ tr ".:\n" "," nameOfFile | festival --tts # Convert periods , colons and # new lines , to commas , and create # a tmp.wav file from the # provided file . $ xsel | tr ".:\n" "," | festival --tts # Convert periods , colons and # new lines , from the selected # text , into commas . # Pipe the converted selection , # into festival , to convert it , # into a wav file , named # tmp.wav .
There is no option , to set the speed rate of text to speech using festival , but this can be done using any audio player .
root$ pkg install mplayer # install mplayer $ mplayer -speed 1.20 tmp.wav # play the tmp.wav file at # speed of 1.20 .
To create a keyboard shortcut for this , it can be done like this :
$ mkdir ~/bin && cd ~/bin # Create a bin directory in # your home folder # and cd into it . $ echo '#!/bin/sh' > festival-wav-player-rate.sh $ echo 'xsel | tr ".:\n" "," | festival --tts' >> festival-wav-player-rate.sh $ echo 'mplayer -speed 1.20 tmp.wav' >> festival-wav-player-rate.sh $ chmod +x festival-wav-player-rate.sh # Create a script which will # pipe the selected text , into # the tr command , to translate # punctuations into commas . # Next the output , is piped # into festival , which will create # a tmp.wav file in the directory # where the script is executed . # Next the mplayer command , # will play the tmp.wav file , # at a speed of 1.20 .
Assign a shortcut for this script , as shown earlier . You can also create a shortcut to stop the playing , by creating a script containing the command pkill mplayer , and assigning a shortcut to it .
# cd into ~/bin , and issue the # following commands . $ echo '#!/bin/sh' > festival-wav-player-stop.sh $ echo 'pkill mplayer' >> festival-wav-player-stop.sh $ chmod +x festival-wav-player-stop.sh


