`配置配置=新配置();
configuration.setDictionaryPath("resource:/edu/cmu/sphinx/models/en-us/cmudict-en-us.dict");
configuration.setLanguageModelPath("resource:/edu/cmu/sphinx/models/en-us/en-us.lm.bin");
的System.out.println( “setAcousticModelPath” + configuration.getAcousticModelPath());
StreamSpeechRecognizer recognizer = new StreamSpeechRecognizer(configuration);
InputStream stream = new FileInputStream(new File("test.wav"));
recognizer.startRecognition(stream);
SpeechResult result;
while ((result = recognizer.getResult()) != null) {
System.out.format("Hypothesis: %s\n", result.getHypothesis());
}
recognizer.stopRecognition();
` 在这里,我将资源文件放到项目src目录中,如下图The structure of netbeans project所示 我也尝试将该文件放在根目录中,但它仍无效。
答案 0 :(得分:0)
我通过将模型放入edu.cmu.sphinix并使用gradel构建它来创建jar文件,现在我已经超越了这个问题。