Setup java speech jsapi using FreeTTS
April 13th, 2009
Getting JSAPI setup to work using freetts seems to be quite difficult as seen by here, here, here…..
Turns out the install instructions were incomplete. The instructions were:
1. Go to the FreeTTS/lib directory
2. Type .\jsapi.exe
3. If the binary license agreement is acceptable, accept
it by clicking “I Agree”. The jsapi.jar file will be unpacked
and deposited into the lib directory.
What you actually want to do is:
- Download FreeTTS
- Unzip the freeTTS binary package and check inside the \lib directory for jsapi.exe
- Run Jsapi.exe, say yes, to unpack jsapi.jar
- Find your JRE directory, mine was C:\Program Files\Java\jdk1.6.0_03\jre\lib\ext
- Copy all the Jars (jsapi.jar, freetts.jar, cmu_time_awb.jar, cmu_us_kal.jar, etc.) to that directory
- Check in netbeans your projects properties ie right click on project->properties->libraries->manage platforms and the jars should be listed there. If they are not, restart and hopefully they should now be there.
- Copy speech.properties to the relevant folder. To find out where this is run the HelloWorld example that comes with FreeTTS. In my case the file was located in C:\Documents and Settings\Username\java.home\lib and contained the following
1 2 3 4 5
# Modify this accordingly... # #TextSynthEngineCentral=com.sun.speech.engine.synthesis.text.TextEngineCentral # FreeTTSSynthEngineCentral=com.sun.speech.freetts.jsapi.FreeTTSEngineCentral
Or you can set the property using
1
System.setProperty("freetts.voices", "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory");
Any problems, post here and I will try to help you out.

Step 7 is not clear.
please explain it clearly. in which folder “java folder” or ” netbeans folder” or “project folder” or other folder we have to copy speech.properties
@dinesh
Run the helloworld sample that comes with FreeTTS it will tell you for sure which folder. In my case the folder was:
C:\Documents and Settings\Username\java.home\lib
Hey i got my Helloworld example to work. Am using eclipse And i have used the sample code from the sun website for helloworld.
import javax.speech.*;
import javax.speech.synthesis.*;
import java.util.Locale;
public class HelloWorld {
public static void main(String args[]) {
try {
// Create a synthesizer for English
Synthesizer synth = Central.createSynthesizer(
new SynthesizerModeDesc(Locale.ENGLISH));
// Get it ready to speak
synth.allocate();
synth.resume();
// Speak the “Hello world” string
synth.speakPlainText(”Hello, world!”, null);
// Wait till speaking is done
synth.waitEngineState(Synthesizer.QUEUE_EMPTY);
// Clean up
synth.deallocate();
} catch (Exception e) {
e.printStackTrace();
}
}
}
after compiling, console output says”mbrola voices do not exist” which is the same i got from executing HelloWorld.jar from freetts\lib. But I dont get any output audio. Whats wrong? When i execute the HelloWorld.jar in the lib folder, i get Hello World as audio output. But no speech in eclipse when executing above code. Help!!
OMG !! its WORKING its WORKING
Thank you VERY MUCH… U R a life Saver… !!
U r page will diffinitly go into my favorite…
Thanksssssss
hi step 7 isn’t work with me and the examples are work but when i make a program it does not work plz help
Hi, I am a student and I have a project to help blind I download TTS but I can not find the Arabic synthesizer can you help me please Thank you
I needed speech.properties here…
C:\Program Files\Java\jdk1.6.0_16\jre\lib
and all jars from…
C:\Downloads\Java\freetts-1.2.2-bin\freetts-1.2
in…
C:\Program Files\Java\jdk1.6.0_16\jre\lib\ext
Hey there, thanks a lot, you really helped me, I didnt know all I needed was to add all the .jar files to my Build Path.
Thx a lot i got it work ahahahah thx thx thx
Hi ,I am an engineer trying to use freetts on Java Speech API . I followed your instructions above and i dont get any error on netbeans. However I dont get any audio either. I modified the code slightly and noticed the program hangs as illustrated on the code snippet below
import javax.speech.*;
import javax.speech.synthesis.*;
import java.util.Locale;
public class helloWorld {
public static void main(String args[]) {
try {
// Create a synthesizer for English
Synthesizer synth = Central.createSynthesizer(
new SynthesizerModeDesc(Locale.ENGLISH));
System.out.println(”aaaaaaaaaaa”);
// Get it ready to speak
synth.allocate();
System.out.println(”bbbbbbbbbbb”);
synth.resume();
System.out.println(”ccccccccccc”);
// Speak the “Hello world” string
synth.speakPlainText(”Hello, world!”, null);
System.out.println(”dddddddddddd”);
// Wait till speaking is done
synth.waitEngineState(Synthesizer.QUEUE_EMPTY);
System.out.println(”eeeeeeeeeeee”);
// Clean up
synth.deallocate();
} catch (Exception e) {
e.printStackTrace();
}
}
}
The output i got was
System property “mbrola.base” is undefined. Will not use MBROLA voices.
aaaaaaaaaaa
bbbbbbbbbbb
ccccccccccc
dddddddddddd
so the program hangs was wondering why.
I am using Ubuntu 9.10 and Netbeans 6.9.1
Hey i got my Helloworld example to work. Am using eclipse And i have used the sample code from the sun website for helloworld.
import javax.speech.*;
import javax.speech.synthesis.*;
import java.util.Locale;
public class HelloWorld {
public static void main(String args[]) {
try {
// Create a synthesizer for English
Synthesizer synth = Central.createSynthesizer(
new SynthesizerModeDesc(Locale.ENGLISH));
// Get it ready to speak
synth.allocate();
synth.resume();
// Speak the “Hello world” string
synth.speakPlainText(”Hello, world!”, null);
// Wait till speaking is done
synth.waitEngineState(Synthesizer.QUEUE_EMPTY);
// Clean up
synth.deallocate();
} catch (Exception e) {
e.printStackTrace();
}
}
}
after compiling, console output says”java.lang.NullPointerException
at HelloWorld.main(HelloWorld.java:36)”
Help.
I’ve compiled a troubleshooting page: http://ondra.zizka.cz/stranky/programovani/java/misc/freetts-line-unavailable-classcastexception-kevinvoicedirectory-error-opening-zipfile.texy
HTH,
Ondra
sir i create synthesizer code but this code output get the exception is null pointer exception
sir why the htrows this exception
immediately
and sir give me total step for running the code of speech synthesizer
i use the simple edutor like as notepad and jdk 1.6 and speech package
thank you very much. i am striving my head for a week to add tts to netbeans. really good work .
hi ryan,
I’m having the problem faced by S.Suja.
Kindly help.
Hi Ryan,
Thanks for the tutorial.
I’m having the same problem as rob and s.suja.
Kindly help.
7th step can be resolved using System.out.println (System.getProperty(
“java.home” ) );
but how to set the mbrola voices i am getting this error
System property “mbrola.base” is undefined. Will not use MBROLA voices.
@S.Suja
I get the same problem as S.Suja, did you find a solution for that? If yes,could you please share it?
@rob
i have the same problem where install the voices..?? and where i can download the voices to work…:S thk..
@dana
excuse me… if you don’t mind, i really need certain help in making it work, can i expect some support from your side..!!
thanks for your help dude… atlast it is working for me… now my project is half done..
Thanks for the instructions! This was way more difficult to install than it should have been.
For those of you confused about step 7: Run the “HelloWorld.jar” from the command line (if in windows, it will look something like this):
java -jar HelloWorld.jar
This should spit out some text output that will tell you where your speech.properties file needs to go. Here’s the output from mine:
C:\Users\Nicholas\Downloads\freetts-1.2.2-bin\freetts-1.2\bin>java -jar HelloWorld.jar
All general Mode JSAPI Synthesizers and Voices:
Using voice: kevin16
No synthesizer created. This may be the result of any
number of problems. It’s typically due to a missing
“speech.properties” file that should be at either of
these locations:
user.home : C:\Users\Nicholas
java.home/lib: C:\Program Files\Java\jre6\lib
Another cause of this problem might be corrupt or missing
voice jar files in the freetts lib directory. This problem
also sometimes arises when the freetts.jar file is corrupt
or missing. Sorry about that. Please check for these
various conditions and then try again.
Thank you so much!
Exception in thread “main” java.lang.RuntimeException: Uncompilable source code - illegal start of expression
at voice.Main.main(Main.java:18)
Java Result: 1
Hell Yeah!!!
Many Thanks to You Guys:). I’ve finally made it to work.
Works Perfectly
hi Ryan,i am doing a project based on speech recognition in j2me..if you know about it anything relevant then pls help me…thanx
Hi all,
I got problem in the step 6. When installing Jsapi.exe I get a msg:
the program might have not installed correctly.try re-installing..
Can anyone help?