Reputation: 3113
I am using FreeTTS to speak out some text in my java program. I want to embed MBROLA Voices in it. I followed the instructions, but I got stuck here:
Enable FreeTTS Support for MBROLA
To enable FreeTTS support for MBROLA, merely copy mbrola/mbrola.jar to lib/mbrola.jar. Then, whenever you run any FreeTTS application, specify the "mbrola.base" directory as a system property:
java -Dmbrola.base=/home/jim/mbrola -jar bin/FreeTTSHelloWorld.jar mbrola_us1
In the tutorial what they are doing is, they type this line in cmd to make a jar file speak in the voice they are telling (us1) but what i have to do is that, i already have a java program and i want to change the voice it speaks. How to do this?
I tried to change the vm options but that does not help.
Note: I am using Netbeans IDE and i also have the file 'FreeTTSHelloWorld.jar'
So in short, i am looking for a clear explanation on how to proceed/add MBROLA Voices into FreeTTS library in java(for a newbie)...
What do you say? should i consider changing my OS to Ubuntu for Java Development???
Upvotes: 1
Views: 3673
Reputation: 328568
Have you tried something like:
public static void main(String[] args) {
System.setProperty("mbrola.base", "your/mbrola/base/directory");
VoiceManager voiceManager = VoiceManager.getInstance();
String voice = "mbrola_us1";
Voice helloVoice = voiceManager.getVoice(voice);
if (helloVoice == null) {
Voice[] availableVoices = voiceManager.getVoices();
List<String> voiceList = new ArrayList<>();
for (Voice v : availableVoices) voiceList.add(v.getName());
System.out.println("Not a valid voice: " + voice + "\nValid voices: " + voiceList);
return;
}
helloVoice.allocate();
/* Synthesize speech. */
helloVoice.speak("Thank you for giving me a voice. " + "I'm so glad to say hello to this world.");
/* Clean up and leave. */
helloVoice.deallocate();
}
Upvotes: 0
Reputation: 27496
Into the terminal:-)This means you need to run your program from command line, here is nice tutorial how to do that.
But I think it can be also run from the NetBeans, go to the Properties
of your project, go to Run
and paste -Dmbrola.base=/home/jim/mbrola
into VM options
. You will of course need FreeTTSHelloWorld.jar
on the classpath (you can add it through Properties -> Libraries -> Add JAR/Folder
).
Upvotes: 4
Reputation: 68715
-D is used to provide a system property to your java program. So you need to provide it while running your java program:
java -Dmbrola.base=/home/jim/mbrola -jar bin/FreeTTSHelloWorld.jar mbrola_us1 yourJavaClass
If you are using an IDE such as eclipse then you can do the same by going to:
Run -> Run configurations, select project, second tab: “Arguments”. Top box is for your program, bottom box is for VM arguments, e.g. -Dmbrola.base=/home/jim/mbrola -jar bin/FreeTTSHelloWorld.jar mbrola_us1
Upvotes: 1