MBROLA voices with FreeTTS - Windows

MadCharlie picture MadCharlie · Oct 7, 2014 · Viewed 19.2k times · Source

Using MBROLA voices in a Java program with FreeTTS...

I am working on a simple text-to-speech program in Java. I have decided to use FreeTTS, but the voices are not really what I was thinking, and I was looking to use a female voice anyway. So I started looking around, and decided that I would use MBROLA to change the voice of my text-to-speech program.

I read that "FreeTTS can use MBROLA voices", but I searched everywhere and couldn't find a clear guide how to set MBROLA up, and what files are needed to do so. There are many forums on MBROLA working alongside FreeTTS, however it also seems that none of the people have any idea what they are doing.

So the questions:

  1. What files need to be downloaded?
  2. Steps to include these into my program?
  3. Simple FreeTTS example using MBROLA voices?

Answer

MadCharlie picture MadCharlie · Oct 7, 2014

Answers to the questions above:

1. What files need to be downloaded?

  1. FreeTTS with all the libraries (freeTTS 1.2.2-bin) - download here
  2. MBROLA zip folder mbr301d.zip
  3. Voices which can be found on the MBROLA website

1.1 The FreeTTS libraries (found in freetts-1.2.2-bin/freetts-1.2/lib):

  • cmu_time_awb.jar
  • cmu_us_kal.jar
  • cmudict04.jar
  • cmulex.jar
  • cmutimelex.jar
  • en_us.jar
  • freetts.jar
  • freetts-jsapi10.jar
  • mbrola.jar

1.2 The MBROLA zip folder will include:

  • mbrola.exe
  • mbr302a (folder)
  • readme.txt

1.3 The Voices are zipped folders that include a single folder named 'us1' or 'af1' etc.


2. Steps to include these into my program?

NOTE: I had the MBROLA Tooklit installed on my computer too, however I am unsure whether it has an impact on the program, but I suspect that it doesn't. EDIT: I have tested to see whether the MBROLA toolkit is needed to run MBROLA alongside FreeTTS, and it turns out that it is not needed.

  1. Extract freetts-1.2.2-bin
  2. Copy the libraries to your project and include in build path
  3. Unzip the mbr301d.zip folder
  4. Rename 'mbr301d' to 'mbrola'
  5. Unzip the voices to the folder you named 'mbrola'

After this is done, your mbrola folder should look like this:

  • [mbr302a] - folder
  • [us1] - folder (name depends on the language you downloaded)
  • mbrola.exe - file
  • readme.txt - file

You can place all your languages in this folder, and they will just be called from your Java program.


3. Simple FreeTTS example using MBROLA voices?

I've seen many people get this error:

System property "mbrola.base" is undefined.  Will not use MBROLA voices.

The mbrola.base refers to where your mbrola files are located on your computer, and without the property being pointed to the correct location, you will recieve this error.

To NON-MBROLA users who get this error: Simply remove the mbrola.jar from your referenced libraries if you're only using FreeTTS

To set the mbrola.base property, use:

System.setProperty("mbrola.base", "C:/Path/to/your/mbrola")

Below is a simple Example to use the MBROLA voices in your FreeTTS program. Note that the steps above must be done before this will work. Simply changing the name of the voice to "mbrola_us1" will not work if the base isn't set!

package com.madmob.test;

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

public class TestTTS {
    VoiceManager freettsVM;
    Voice freettsVoice;

    public TestTTS(String words) {
        // Most important part!
        System.setProperty("mbrola.base", "C:/mbrola");
        freettsVM = VoiceManager.getInstance();

        // Simply change to MBROLA voice
        freettsVoice = freettsVM.getVoice("mbrola_us1");

        // Allocate your chosen voice
        freettsVoice.allocate();
        sayWords(words);
    }

    public void sayWords(String words) {
        // Make her speak!
        freettsVoice.speak(words);
    }

    public static void main(String [] args) {
        new TestTTS("Hello there! Now M BROLA and Free T T S work together!");
    }
}

MBROLA and FreeTTS should now be working together! This code was copied right from my computer and has been tested before putting it down here.