0

I am using Sphinx4 for custome home automatization software and I am stuck on using my custom dict file, for some reason it cant find the file even though I am sure I am using the correct path.

This is my code :

package pccomone;

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;

import edu.cmu.sphinx.api.Configuration;
import edu.cmu.sphinx.api.LiveSpeechRecognizer;
import edu.cmu.sphinx.api.SpeechResult;
import edu.cmu.sphinx.api.StreamSpeechRecognizer;

public class Main {

private static final String BODICPATH = "PCCom/src/resource/bodict.dict";

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(BODICPATH);
    //configuration.setDictionaryPath("resource:/edu/cmu/sphinx/models/en-us/cmudict-en-us.dict"); use only for large commands!!!!!!!!!
    configuration.setLanguageModelPath("resource:/edu/cmu/sphinx/models/en-us/en-us.lm.bin");

    LiveSpeechRecognizer recognizer = new LiveSpeechRecognizer(configuration);

    recognizer.startRecognition(true);

    SpeechResult result;

    while((result = recognizer.getResult()) != null){
        String command = result.getHypothesis();
        if(command.equalsIgnoreCase("stop")){
            recognizer.stopRecognition();
            System.exit(0);
        }
        System.out.println(command);
    }
}

}

I didn't come far since I can't get it to use my custom dict file and the included dict file is way to large for the software to work fast and accurate.

This is the Error,

Exception in thread "main" java.lang.RuntimeException: Allocation of search manager resources failed at edu.cmu.sphinx.decoder.search.WordPruningBreadthFirstSearchManager.allocate(WordPruningBreadthFirstSearchManager.java:247) at edu.cmu.sphinx.decoder.AbstractDecoder.allocate(AbstractDecoder.java:103) at edu.cmu.sphinx.recognizer.Recognizer.allocate(Recognizer.java:164) at edu.cmu.sphinx.api.LiveSpeechRecognizer.startRecognition(LiveSpeechRecognizer.java:47) at pccomone.Main.main(Main.java:26) Caused by: java.io.FileNotFoundException: PCCom\src\resource\bodict.dict (The system cannot find the path specified) at java.io.FileInputStream.open0(Native Method) at java.io.FileInputStream.open(Unknown Source) at java.io.FileInputStream.(Unknown Source) at java.io.FileInputStream.(Unknown Source) at sun.net.www.protocol.file.FileURLConnection.connect(Unknown Source) at sun.net.www.protocol.file.FileURLConnection.getInputStream(Unknown Source) at java.net.URL.openStream(Unknown Source) at edu.cmu.sphinx.linguist.dictionary.TextDictionary.allocate(TextDictionary.java:180) at edu.cmu.sphinx.linguist.lextree.LexTreeLinguist.allocate(LexTreeLinguist.java:332) at edu.cmu.sphinx.decoder.search.WordPruningBreadthFirstSearchManager.allocate(WordPruningBreadthFirstSearchManager.java:243) ... 4 more

Keshav Pradeep Ramanath
  • 1,623
  • 4
  • 24
  • 33
Phoenix
  • 63
  • 2
  • Possible duplicate of [Exception in thread "main" java.io.FileNotFoundException: Error](https://stackoverflow.com/questions/13592325/exception-in-thread-main-java-io-filenotfoundexception-error) – Nikolay Shmyrev Jun 27 '17 at 15:14
  • Simply point a proper path. If you are not sure about relative path, point an absolute path. – Nikolay Shmyrev Jun 27 '17 at 15:15

0 Answers0