CMU Sphinx Set Acoustic Model Path Error

徘徊边缘 提交于 2019-12-13 08:45:35

问题


Am trying to create a speech-to-text java program using CMU Sphinx 4. Have loaded jar files into project. But am receiving the error that a resource cannot be located. I have confirmed that the resource is present within the jar file.

Sorry, I'm completely new to CMU sphinx and totally out of my depth... This is the code:

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();
    }
}

These are the errors that I'm getting:

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)

来源:https://stackoverflow.com/questions/36700836/cmu-sphinx-set-acoustic-model-path-error

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!