无法找到资源:/edu/cmu/sphinx/ models/en-us/en-us/in netbeans
问题描述:
`Configuration configuration = new Configuration();无法找到资源:/edu/cmu/sphinx/ models/en-us/en-us/in netbeans
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 我也试图把该文件在根目录但仍然没有工作。
答
我通过将模型放入edu.cmu.sphinix创建了jar文件,并用gradel构建了它,现在我已经超越了这个问题。