0

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)
  • The error is due to the fact you didn't add sphinx4-data jar into your application classpath. In order to get help on this issue you need to explain how exactly do you add classes into classpath and how do you run your project. – Nikolay Shmyrev Apr 19 '16 at 08:45
  • I am having same error but I have added external libraries via build path – Adnan Ali Oct 22 '16 at 16:43

0 Answers0