Friday, February 15, 2013

FreeTTS: a Tutorial

These are the four simple steps to use FreeTTS, a TTS tool based on CMU's Flite engine.

Step 1:
Download from,

Step 2:
Unzip to get freetts-1.2 folder

Step 3:
Create a Java project, and copy the lib folder in freetts-1.2. to the project.
(Files not ended with .jar can be removed.)

Step 4:
Copy the codes below by which to create, and configure it on your own.

import com.sun.speech.freetts.Voice;
import com.sun.speech.freetts.VoiceManager;

public class FreeTTS {

 private static final String VOICENAME_kevin = "kevin";
 private String text; // string to speech

 public FreeTTS(String text) {
  this.text = text;

 public void speak() {
  Voice voice;
  VoiceManager voiceManager = VoiceManager.getInstance();
  voice = voiceManager.getVoice(VOICENAME_kevin);

 public static void main(String[] args) {
  String text = "FreeTTS was written by the Sun Microsystems Laboratories "
    + "Speech Team and is based on CMU's Flite engine.";
  FreeTTS freeTTS = new FreeTTS(text);


  1. FreeTTs is a great lib for text.speech!

    Nice Article, Keep it up!!

  2. This article is very useful.. Java speech to text can be very complicated, as can Java sound. I'm trying to teach Java students to use API's other than those included in SDK downloads. This is simple, to the point, and it works well on most systems.


  3. when i run your project it gives error in console

    [2014-03-08 10:43:38 - Dex Loader] Unable to execute dex: Multiple dex files define Lde/dfki/lt/freetts/mbrola/MbrolaAudioOutput;
    [2014-03-08 10:43:38 - ttstesting] Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Lde/dfki/lt/freetts/mbrola/MbrolaAudioOutput;

    1. Do not Mrbola.jar to your project or uncomment in file

  4. It gives error as package com.sun.speech.freetts.Voice doen't exists.