Jars Required
1) cmudict04.jar2) cmulex.jar
3) cmutimelex.jar
4) cmu_time_awb.jar
5) cmu_us_kal.jar
6) en_us.jar
7) reetts-jsapi10.jar
8) freetts.jar
9) mbrola.jar
Code for Text to Speech
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import com.sun.speech.freetts.Voice;
import com.sun.speech.freetts.VoiceManager;
public class TextToSpeech {
// Default voice is Kevin16
private static final String VOICENAME = "kevin16";
public static void main(String[] args) {
Voice voice;
// Taking instance of voice from VoiceManager factory.
VoiceManager voiceManager = VoiceManager.getInstance();
voice = voiceManager.getVoice(VOICENAME);
// Allocating voice
voice.allocate();
// word per minute
voice.setRate(120);
voice.setPitch(100);
System.out.print("Enter your text: ");
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
try {
// Ready to speak
voice.speak(br.readLine());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}