尝试使用CMU Sphinx 4创建一个语音到文本的Java程序。 已将jar文件加载到项目中。但是我收到了无法找到资源的错误。我已经确认资源存在于jar文件中。
对不起,我是CMU狮身人面像的新手,完全超出了我的深度...... 这是代码:
import edu.cmu.sphinx.api.Configuration;
import edu.cmu.sphinx.api.LiveSpeechRecognizer;
import edu.cmu.sphinx.api.SpeechResult;
public class TranscriberDemo {
public static void main(String[] args) throws Exception {
Configuration configuration = new Configuration();
configuration.setAcousticModelPath("resource:/edu/cmu/sphinx/models/en-us/en-us");
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");
LiveSpeechRecognizer recognizer = new LiveSpeechRecognizer(configuration);
recognizer.startRecognition(true);
SpeechResult result = recognizer.getResult();
while (result != null) {
System.out.format("Hypothesis: %s\n", result.getHypothesis());
}
recognizer.stopRecognition();
}
}
这些是我得到的错误:
Exception in thread "main" Property exception component:'acousticModelLoader' property:'location' - Can't locate resource:/edu/cmu/sphinx/models/en-us/en-us
edu.cmu.sphinx.util.props.InternalConfigurationException: Can't locate resource:/edu/cmu/sphinx/models/en-us/en-us
at edu.cmu.sphinx.util.props.ConfigurationManagerUtils.getResource(ConfigurationManagerUtils.java:468)
at edu.cmu.sphinx.linguist.acoustic.tiedstate.Sphinx3Loader.newProperties(Sphinx3Loader.java:219)
at edu.cmu.sphinx.util.props.PropertySheet.getOwner(PropertySheet.java:518)
at edu.cmu.sphinx.util.props.PropertySheet.getComponent(PropertySheet.java:296)
at edu.cmu.sphinx.linguist.acoustic.tiedstate.TiedStateAcousticModel.newProperties(TiedStateAcousticModel.java:101)
at edu.cmu.sphinx.util.props.PropertySheet.getOwner(PropertySheet.java:518)
at edu.cmu.sphinx.util.props.PropertySheet.getComponent(PropertySheet.java:296)
at edu.cmu.sphinx.linguist.lextree.LexTreeLinguist.newProperties(LexTreeLinguist.java:303)
at edu.cmu.sphinx.util.props.PropertySheet.getOwner(PropertySheet.java:518)
at edu.cmu.sphinx.util.props.PropertySheet.getComponent(PropertySheet.java:296)
at edu.cmu.sphinx.decoder.search.WordPruningBreadthFirstSearchManager.newProperties(WordPruningBreadthFirstSearchManager.java:211)
at edu.cmu.sphinx.decoder.search.WordPruningBreadthFirstLookaheadSearchManager.newProperties(WordPruningBreadthFirstLookaheadSearchManager.java:156)
at edu.cmu.sphinx.util.props.PropertySheet.getOwner(PropertySheet.java:518)
at edu.cmu.sphinx.util.props.PropertySheet.getComponent(PropertySheet.java:296)
at edu.cmu.sphinx.decoder.AbstractDecoder.newProperties(AbstractDecoder.java:81)
at edu.cmu.sphinx.decoder.Decoder.newProperties(Decoder.java:36)
at edu.cmu.sphinx.util.props.PropertySheet.getOwner(PropertySheet.java:518)
at edu.cmu.sphinx.util.props.PropertySheet.getComponent(PropertySheet.java:296)
at edu.cmu.sphinx.recognizer.Recognizer.newProperties(Recognizer.java:86)
at edu.cmu.sphinx.util.props.PropertySheet.getOwner(PropertySheet.java:518)
at edu.cmu.sphinx.util.props.ConfigurationManager.lookup(ConfigurationManager.java:163)
at edu.cmu.sphinx.api.Context.<init>(Context.java:73)
at edu.cmu.sphinx.api.Context.<init>(Context.java:45)
at edu.cmu.sphinx.api.AbstractSpeechRecognizer.<init>(AbstractSpeechRecognizer.java:44)
at edu.cmu.sphinx.api.LiveSpeechRecognizer.<init>(LiveSpeechRecognizer.java:34)
at TranscriberDemo.main(TranscriberDemo.java:21)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)