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 freetts-1.2.2-bin.zip from http://sourceforge.net/projects/freetts/files/latest/download?source=dlp,

Step 2:
Unzip freetts-1.2.2-bin.zip 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 FreeTTS.java, 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);
  voice.allocate();
  voice.speak(text);
 }

 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);
  freeTTS.speak();
 }
}



8 comments:

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

    Nice Article, Keep it up!!

    ReplyDelete
  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.

    Thanks,

    ReplyDelete
  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;

    ReplyDelete
    Replies
    1. Do not Mrbola.jar to your project or uncomment in gradle.build file

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

    ReplyDelete