i trying familiarize myself sphinx dissecting config file.
unfortunately, haven't been able compile. did using same class contents of helloworld example, removed config file listed , replaced 1 shown in http://cmusphinx.sourceforge.net/sphinx4/javadoc/edu/cmu/sphinx/util/props/doc-files/configurationmanagement.html
i getting null pointer exception , can't figure out why. imported sphinx4.jar, wsj_8gau....jar, js.jar, , jsapi.jar. know reading config file. compiling correctly when left as
helloworld.class.getresource("helloworld.config.xml"). below code slight changes made.
package speechcapture; //import edu.cmu.sphinx.demo.helloworld.helloworld; import edu.cmu.sphinx.frontend.util.microphone; import edu.cmu.sphinx.recognizer.recognizer; import edu.cmu.sphinx.result.result; import edu.cmu.sphinx.util.props.configurationmanager; public class capturespeech { public void speechtolist(string[] args){ configurationmanager cm; if (args.length > 0) { cm = new configurationmanager(args[0]); } else { cm = new configurationmanager("testing.config.xml"); } recognizer recognizer = (recognizer) cm.lookup("recognizer"); recognizer.allocate(); //where error occurs // start microphone or exit if program if not possible microphone microphone = (microphone) cm.lookup("microphone"); if (!microphone.startrecording()) { system.out.println("cannot start microphone."); recognizer.deallocate(); system.exit(1); } system.out.println("say: (good morning | hello) ( bhiksha | evandro | paul | philip | rita | )"); // loop recognition until program exits. while (true) { system.out.println("start speaking. press ctrl-c quit.\n"); result result = recognizer.recognize(); if (result != null) { string resulttext = result.getbestfinalresultnofiller(); system.out.println("you said: " + resulttext + '\n'); } else { system.out.println("i can't hear said.\n"); } } } }
recognizer null on line:
recognizer recognizer = (recognizer) cm.lookup("recognizer"); recognizer.allocate(); //where error occurs
because component named "recognizer" missing in config xml file. when update xml file check code in sync.
for more details see original discussion:
https://sourceforge.net/p/cmusphinx/discussion/sphinx4/thread/91efe5b7/?limit=25#52da
Comments
Post a Comment