Text To Speech (TTS) in JAVA
Festival, it allows us to convert Text to Speech (TTS) in wav format. In this article we will learn on how we can perform TTS from Java applications.
What is Festival?
It is an Open Source tool available that performs Text to Speech(TTS) Synthesis System. You can install Festival directly by directly calling:
yum -y install festivalThis will ensure that all the dependencies associated with the Festival also gets installed.
Starting Festival TTS Speech Synthesis System:
Once the Festival is installed, we can see the folder Festival getting created in /usr/share. Now goto command prompt and type Festival.
Example:
[root@Hitesh ~]# festival
After entering the following command we get to see following output.
[root@Hitesh ~]# festival Festival Speech Synthesis System 1.95:beta July 2004 Copyright (C) University of Edinburgh, 1996-2004. All rights reserved. For details type `(festival_warranty)' festival>
After seeing festival prompt we are sure that now we can use it to generate Text to Speech Conversion.
Using Festival TTS Speech Synthesis System:
To check the list of voices available we need to enter (voice.list) in the festival prompt.
festival> (voice.list) (cmu_us_slt_arctic_hts cmu_us_jmk_arctic_hts cmu_us_bdl_arctic_hts cmu_us_awb_arctic_hts ked_diphone kal_diphone) festival>
We can change the voice whenever we want to by calling (voice_
festival> (voice_kal_diphone) kal_diphone festival>
Text to Speech (TTS) Conversion:
Now the most important part in Festival is to convert Text content to Speech. We can achieve this by calling.
festival> (SayText "Hello World")
After entering this command you will hear “Hello World” from your speaker.
Using Festival Speech Synthesis System inside Java Application:
After you have successfully installed Festival, you get an new command called “text2wave” this command allow us to convert the text content to WAV file.
[root@Hitesh hitesh]# text2wave hello.txt -o /home/hitesh/hello.wav
Here if you see i am passing hello.txt contains the text content and the output file will get generated at location /home/hitesh/hello.wav . Now we will achieve the same in our Java application by calling:
Runtime rt = RunTime.getRunTime(); rt.exec("text2wave hello.txt -o /home/hitesh/hello.wav");
If we want to change the voice we need to append -eval argument to text2wave command as shown below:
Runtime rt = RunTime.getRunTime(); rt.exec("text2wave hello.txt -o /home/hitesh/hello.wav -eval '(voice_ked_diphone)');
This will ensure that the Speech Synthesizer will use ked_diphone voice while performing text to speech conversion.
















Hi..this was a great usefull post..thanks buddy..i tried this this out..the festival was successfully installed…i used the festival class from phpclasses…in that i got the first function working text2Wav($string)..which uses this command “text2wave $filename -o $outputfile”…got the output file…but there was one more function..text2Speech($string) which uses this command “festival –tts $filename”..but this is not working…it seems like the function is working…but cant hear the voice..is there anything that i shud do with the incoming waveform of speech….i think i should grab that speech and pass it on to flash player something..what your opinion…