package net.sphene.goim.freetts;
import org.eclipse.core.runtime.Plugin;
import org.osgi.framework.BundleContext;
import com.sun.speech.freetts.Voice;
import com.sun.speech.freetts.VoiceManager;
/**
* The main plugin class to be used in the desktop.
*/
public class FreeTTSPlugin extends Plugin {
//The shared instance.
private static FreeTTSPlugin plugin;
private Voice voice;
/**
* The constructor.
*/
public FreeTTSPlugin() {
plugin = this;
}
/**
* This method is called upon plug-in activation
*/
public void start(BundleContext context) throws Exception {
super.start(context);
System.out.println("Started FreeTTS Plugin.");
getVoice();
}
/**
* This method is called when the plug-in is stopped
*/
public void stop(BundleContext context) throws Exception {
super.stop(context);
plugin = null;
}
/**
* Returns the shared instance.
*/
public static FreeTTSPlugin getDefault() {
return plugin;
}
public Voice getVoice() {
System.setProperty("freetts.voices","com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory");
if(this.voice == null) {
VoiceManager voiceManager = VoiceManager.getInstance();
Voice helloVoice = voiceManager.getVoice("kevin16");
if (helloVoice == null) {
System.err.println("Cannot find voices");
for(Voice voice : voiceManager.getVoices()) {
System.out.println("Voice: " + voice.getName());
}
}
helloVoice.allocate();
this.voice = helloVoice;
}
return this.voice;
}
}