Adding MBROLA speech to FreeTTS Java speech synthesiser

Welcome to the third in the series on adding speech to a Java application.  In the previous post, we wrote a small application to list out all the voices available in our Java FreeTTS speech synthesiser.

In this article, we will take a look at increasing the number of voices available to us by adding voices from MBROLA.

External files

As has become our habit, before we go too far, we will take a look at the external files needed to complete this section.

The MBROLA engine is included with the FreeTTS zip file as a JAR file we are going to downloaded the MBROLA engine as an executable file and can be downloaded from here:

http://tcts.fpms.ac.be/synthesis/mbrola/bin/pcdos/mbr301d.zip

This gives you a zip file with the mbrola.exe file contained within.

Next, we need to download some voices to work with our engine. The voices I will use are the three American voices.  I was unable to get the British voice to work and as yet I have not tried any of the others.  You can download the voices from here:

http://tcts.fpms.ac.be/synthesis/mbrola.html

Once on the page select the “Download” option and then click on “MBROLA binary and voices” and scroll down towards the bottom of the page where the various voices are listed.  Click on each of the US voices (US1, US2, US3) to download the three zip files containing the voices.

Setting up MBROLA

To install MBROLA so we can use it we need to extract the executable file from the zip file and place it on our local drive.  Now there are two versions of the file contained within the zip file, one is a Windows file and the other is a DOS file.  Surprisingly, we need the DOS base file which is located in the subdirectory “mbr302a”.  Simply extract the file to your local drive.  In my case, I went with C:\mbrola\mbrola.exe.

Once the executable file is in place next, we need to install the voices.  To install a voice simply extract the contents of the zip file into the same location as the MBROLA executable file.  You will end up with a folder for each voice and within the folder the voice-specific files.

The Code

Now that the MBROLA files are in place we can turn our attention to our code and make use of these new files.

To use MBROLA in our Java application we need to set the property “mbrola.base” to the location where the executable MBROLA file is located.  With this in place we can run our Java application, the same application we used in the previous post, and now see we have an additional voice available.

The code for this looks like this:

package uk.co.softwarepulse.speech.app;

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

/**
 * Getting started with text to speech
 * Accessing those tricky mbrola voices
 * @author jmcneil
 * (c) copyright Software Pulse 2019
 *
 */
public class BasicSound2 {
	private static Voice[] voices;

	public static void main (String[]args) throws Exception{

		System.setProperty("mbrola.base", "c:\\mbrola");
		VoiceManager vm;
		// VoiceManager uses the singleton approach to creating and 
		// providing an instance
		vm = VoiceManager.getInstance();
		// Get all the voices which the VoiceManager knows about
		voices = vm.getVoices();

		for( Voice voice:voices ) {
			// Find out what voices are available.
			System.out.println(voice.getName() + " - " + 
			voice.getDescription());
		}

	}

}

And this gives us the following results

alan – default time-domain cluster unit voice
kevin – default 8-bit diphone voice
kevin16 – default 16-bit diphone voice
mbrola_us1 – MBROLA Voice us1
mbrola_us2 – MBROLA Voice us2
mbrola_us3 – MBROLA Voice us3

Notice that when we run the application this time there is no warning about “mbrola.base” being undefined which we saw in the previous version.  We now have our MBROLA voices ready to use.

There is no download for this post as the code for this is only 1 line different from the previous posting and all the external files were provided as well.  Take a look at the JavaFX and adding basic speech post for the download link.

2 Replies to “Adding MBROLA speech to FreeTTS Java speech synthesiser”

  1. Hello John.

    Thank you for posting this article (Adding MBROLA speech to FreeTTS Java speech synthesiser) on your Software Pulse.

    I an new to Java programming, and was able to follow your instructions.

    Then I tried to download mbrola at:
    http://tcts.fpms.ac.be/synthesis/mbrola.html.
    Unfortunately, the web site is no longer supported.

    Would it be possible for you to email or post your copy of mbr301d.zip so I can complete my process?

    Thank you for reading my message and considering my request.

    Very respectfully,
    Robert Grisar

    1. Hi Robert,
      Thanks for posting your request. You can obtain a copy of all the files used in this example by downloading the source code. A link to the download page is provided at the end of the article “JavaFX and adding basic speech” of which a link to that article is provided at the bottom of this blog. You want the MBROLA binary files zip file.
      Hope this helps.
      Regards,
      John

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.