我对sphinx4-5 prealpha释放有疑问。我无法使用类识别器,在sphinx4之前我们能够像这样使用:Recognizer recognizer = new Recognizer();
recognizer.allocate();
但是sphinx4-5 prealpha中的同一段代码在recognizer.allocate()时给出了nullPointerException;
代码段:
`Configuration cn = new Configuration();
cn.setAcousticModelPath(Acoustic_Model);
cn.setDictionaryPath(Dictionary_Path);
cn.setLanguageModelPath(LANGUAGE_MODEL);
Recognizer recognizer = new Recognizer();
recognizer.allocate();`
StackTrace:Exception in thread "main" java.lang.NullPointerException at edu.cmu.sphinx.recognizer.Recognizer.allocate(Recognizer.java:164) at edu.cmu.sphinx.demo.dialog.SampleSphinx.main(SampleSphinx.java:26) Exception is at recognizer.allocate
在sphinx4中,我们使用如下配置来分配资源:
Configuration configuration = new Configuration(); Recognizer recognizer = new Recognizer(); recognizer = (Recognizer) configuration.lookup();
但是现在我们知道我们在sphinx4-5 prealpha中使用api而我们在Configuration类中没有lookup()。那么我们将如何在sphinx4-5 pre alpha中加载JSGFGrammar和Recognizer。希望我清楚我的怀疑,请提前帮助@nikolay谢谢你。