开发者

Troubleshooting "System property mbrola.base is undefined. Will not use MBROLA voices" when converting text to speech with JSAPI

I'm getting the following error:

System property "mbrola.base" is undefined.  Will not use MBROLA voices.
import javax.speech.*;
import javax.speech.synthesis.*;
import java.util.Locale;

public class HelloWorld
 {

public static void main(String args[]) 
{

try 
{
// C开发者_如何学Pythonreate a synthesizer for English

Synthesizer synth = Central.createSynthesizer(
new SynthesizerModeDesc(Locale.ENGLISH));

// Get it ready to speak

synth.allocate();

synth.resume();

// Speak the “Hello world” string

synth.speakPlainText("Hello", null);

// Wait till speaking is done

synth.waitEngineState(Synthesizer.QUEUE_EMPTY);

// Clean up

synth.deallocate();

} 
catch (Exception e)
 {
e.printStackTrace();
}

}

}


For those who are still struggling with this one, here's how I got it to work on Windows in a plain notepad, no Eclipse involved.

  1. I went to http://tcts.fpms.ac.be/synthesis/mbrola.html and downloaded 2 packages under downloads of binary voices: PC/Windows and PC/DOS

  2. unzip it all and put PC/Windows binary in the same directory as PC/DOS executable mbrola.exe. Please note mbrola.exe didn't work for me b/c it's 16-bit (go figure!), but i found this link:

    http://sourceforge.net/projects/freetts/forums/forum/137669/topic/1219083
    which had a zip file with 2 binaries, one from 2004 that appeared to work on my 64-bit Windows.

  3. Then I downloaded the voices on mbrola website up above in section 1 I wanted a female voice so I grabbed us1 and put the whole folder into the same directory as
    PC/Windows binaries above and PC/DOS executable.

  4. In the code i specified the following: System.setProperty("mbrola.base", "C:\devsrc\main\Head-Rev\src\java\freetts-1.2\mbrola"); voice=vm.getVoice("mbrola_us1");

And I got my female voice. I didn't need any compile or runtime flags.

Hope this helps someone.


For me :

  1. I downloaded Mbrola Tool

  2. I downloaded Mbrola Base folder

  3. Downloaded the required voice from Getting the MBROLA Voices section of Mbrola Site

  4. Unziped the file from step 3 to the unziped directory got from step2 .

  5. Set property "mbrola.base" by using : System.setProperty("mbrola.base", "E:\\xxx\\xxx\\mbrxxx");


Your code needs MBROLA app which is in the system. So you need to tell your application that MBROLA is here:

  1. From command line or eclipse launch configuration: -Dmbrola.base=/location/to/mbrola OR
  2. System.setProperty("mbrola.base", Morbola.class.getName()) and put the mbrola JAR is the classpath.

See this similar question

(You can use any one of the solution)


Works on Windows Systems for setting the mbrola.base: - set environment variable "MBROLA_HOME" in the windows os - use this code snippet to set the property mbrola.base

public class FreeTTSVoice {

private static String path = System.getenv("MBROLA_HOME");
//  System.out.println(path);  

public FreeTTSVoice(){
    System.setProperty("mbrola.base", path);
    listAllVoices();
}

public static void listAllVoices() {
    System.out.println("All voices available:");        
    VoiceManager voiceManager = VoiceManager.getInstance();
    Voice[] voices = voiceManager.getVoices();
    for (int i = 0; i < voices.length; i++) {
        System.out.println("    " + voices[i].getName()
                           + " (" + voices[i].getDomain() + " domain)");
    }

}

...


Because I used maven repository for mbrola instead of downloading it, I had to override this file in my java project: com.sun.speech.freetts -> internal_voices.txt and to add there:

# Uncomment to allow MBROLA voices:
de.dfki.lt.freetts.en.us.MbrolaVoiceDirectory


I am using ubuntu If you are using windows you will required only step 1 and 2 .

Created a folder called mbrola 1. put downloaded mbrola-base for my operating system linux to it 2. put downloaded us1, us2, us3 extracted folders to this folder 3. Install the mbrola in ubuntu by command line. sudo apt-get istall mbrola

After installation use this commad to check where your files has located
dpkg -L mbrola
  1. Copied /usr/bin/mbrola file to the above mbrola folder
  2. Update the program with the path to above program System.setProperty("mbrola.base", "/home/ngs/INCUBATOR/egg-8/libries/MBROLA/mbrola");

Now it should work

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜