java - ClassNotFoundException: javax.speech.EngineModeDesc -
the following code i'm writing implement text speech in java using freetts , mbrola.
i have added jars of freetts classpath.
import java.applet.*; import java.awt.*; import java.awt.event.actionevent; import java.awt.event.actionlistener; import javax.speech.central; import javax.speech.enginelist; import javax.speech.enginecreate; import javax.speech.synthesis.synthesizermodedesc; import javax.speech.synthesis.synthesizer; import javax.speech.synthesis.voice; import com.sun.speech.freetts.jsapi.freettsenginecentral; import java.util.locale; import java.awt.event; public class voisedemo extends applet implements actionlistener { public synthesizer synth; private static voice kevinhq; textfield t1; public void init() { button b1 = new button("press me"); add(b1); b1.addactionlistener(this); t1 = new textfield(50); add(t1); } public void start() { } public void actionperformed(actionevent e) { // synthesizer.speakplaintext(“hello, world!”, null); try { setkevinhq(new voice("hitesh", voice.age_neutral, voice.gender_male, null )); system.setproperty("mbrola.base", "c:/users/sai/downloads/mbrola"); synthesizermodedesc modedesc = new synthesizermodedesc( null, "general", /* use “time” or “general” */ locale.us, boolean.false, null); freettsenginecentral central = new freettsenginecentral(); synthesizer synthesizer = null; synthesizer = central.createsynthesizer( modedesc ); enginelist list = central.createenginelist(modedesc); if (list.size() > 0) { enginecreate creator = (enginecreate) list.get(0); synthesizer = (synthesizer) creator.createengine(); } if (synthesizer == null) { system.err.println("cannot create synthesizer"); system.exit(1); } //get ready speak synthesizer.allocate(); synthesizer.resume(); string s1 = t1.gettext(); synthesizer.speakplaintext(s1, null); synthesizer.waitenginestate(synthesizer.queue_empty); synthesizer.deallocate(); } catch (exception eq) { eq.printstacktrace(); } } public static void setkevinhq(voice kevinhq) { voisedemo.kevinhq = kevinhq; } public static voice getkevinhq() { return kevinhq; } public void paint(graphics g) { } }
i compiled in command prompt using:
c:\users\sai\desktop\mini project>javac voisedemo.java
there no compilation errors.
but when ever run using:
c:\users\sai\desktop\mini project>java voisedemo
i'm getting following runtime errors:
error: jni error has occurred, please check installation , try again exception in thread "main" java.lang.noclassdeffounderror: javax/speech/enginemodedesc @ java.lang.class.getdeclaredmethods0(native method) @ java.lang.class.privategetdeclaredmethods(unknown source) @ java.lang.class.privategetmethodrecursive(unknown source) @ java.lang.class.getmethod0(unknown source) @ java.lang.class.getmethod(unknown source) @ sun.launcher.launcherhelper.validatemainclass(unknown source) @ sun.launcher.launcherhelper.checkandloadmain(unknown source) caused by: java.lang.classnotfoundexception: javax.speech.enginemodedesc @ java.net.urlclassloader.findclass(unknown source) @ java.lang.classloader.loadclass(unknown source) @ sun.misc.launcher$appclassloader.loadclass(unknown source) @ java.lang.classloader.loadclass(unknown source) ... 7 more
this program part of mini project.
please me solve error.
you need specify class path:
java -cp (fullpathifnotincurrentworkingdirectory)yourjarfile.jar;. voicedemo
answer taken here
Comments
Post a Comment