coding4fun
coding4fun

Reputation: 3507

IndexOutOfBound when trying Sphinx4

I have created all the models required by Sphinx4 (language model, dictionary and acoustic model). I created a Maven project in Eclipse and all the libraries downloaded, but when I run the program as shown in the official website (http://cmusphinx.sourceforge.net/wiki/tutorialsphinx4), an IndexOutOfBounds Exception is thrown.

Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 768, Size: 768
at java.util.ArrayList.rangeCheck(ArrayList.java:635)
at java.util.ArrayList.get(ArrayList.java:411)
at edu.cmu.sphinx.linguist.acoustic.tiedstate.Pool.get(Pool.java:55)
at edu.cmu.sphinx.linguist.acoustic.tiedstate.Sphinx3Loader.createSenonePool(Sphinx3Loader.java:403)
at edu.cmu.sphinx.linguist.acoustic.tiedstate.Sphinx3Loader.loadModelFiles(Sphinx3Loader.java:341)
at edu.cmu.sphinx.linguist.acoustic.tiedstate.Sphinx3Loader.load(Sphinx3Loader.java:278)
at edu.cmu.sphinx.frontend.AutoCepstrum.newProperties(AutoCepstrum.java:118)
at edu.cmu.sphinx.util.props.PropertySheet.getOwner(PropertySheet.java:508)
at edu.cmu.sphinx.util.props.ConfigurationManager.lookup(ConfigurationManager.java:165)
at edu.cmu.sphinx.util.props.PropertySheet.getComponentList(PropertySheet.java:422)
at edu.cmu.sphinx.frontend.FrontEnd.newProperties(FrontEnd.java:160)
at edu.cmu.sphinx.util.props.PropertySheet.getOwner(PropertySheet.java:508)
at edu.cmu.sphinx.util.props.PropertySheet.getComponent(PropertySheet.java:290)
at edu.cmu.sphinx.decoder.scorer.SimpleAcousticScorer.newProperties(SimpleAcousticScorer.java:46)
at edu.cmu.sphinx.decoder.scorer.ThreadedAcousticScorer.newProperties(ThreadedAcousticScorer.java:130)
at edu.cmu.sphinx.util.props.PropertySheet.getOwner(PropertySheet.java:508)
at edu.cmu.sphinx.util.props.PropertySheet.getComponent(PropertySheet.java:290)
at edu.cmu.sphinx.decoder.search.WordPruningBreadthFirstSearchManager.newProperties(WordPruningBreadthFirstSearchManager.java:201)
at edu.cmu.sphinx.util.props.PropertySheet.getOwner(PropertySheet.java:508)
at edu.cmu.sphinx.util.props.PropertySheet.getComponent(PropertySheet.java:290)
at edu.cmu.sphinx.decoder.AbstractDecoder.newProperties(AbstractDecoder.java:70)
at edu.cmu.sphinx.decoder.Decoder.newProperties(Decoder.java:37)
at edu.cmu.sphinx.util.props.PropertySheet.getOwner(PropertySheet.java:508)
at edu.cmu.sphinx.util.props.PropertySheet.getComponent(PropertySheet.java:290)
at edu.cmu.sphinx.recognizer.Recognizer.newProperties(Recognizer.java:89)
at edu.cmu.sphinx.util.props.PropertySheet.getOwner(PropertySheet.java:508)
at edu.cmu.sphinx.util.props.ConfigurationManager.lookup(ConfigurationManager.java:165)
at edu.cmu.sphinx.api.Context.<init>(Context.java:73)
at edu.cmu.sphinx.api.Context.<init>(Context.java:44)
at edu.cmu.sphinx.api.AbstractSpeechRecognizer.<init>(AbstractSpeechRecognizer.java:37)
at edu.cmu.sphinx.api.LiveSpeechRecognizer.<init>(LiveSpeechRecognizer.java:33)
at Main.main(Main.java:26)

The source code which I am running is as follows:

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
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 {

public static void main(String[] args) {

    Configuration configuration = new Configuration();

    configuration.setAcousticModelPath("Alphabets/acoustic");

    configuration.setDictionaryPath("Alphabets/alphabets.dic");

    configuration.setLanguageModelPath("Alphabets/alphabets.lm.dmp");

    LiveSpeechRecognizer recognizer = null;
    try {
        recognizer = new LiveSpeechRecognizer(configuration);
    } catch (IOException e) {
        e.printStackTrace();
    }
    recognizer.startRecognition(true);
    SpeechResult result = recognizer.getResult();
    recognizer.stopRecognition();

    System.out.println(result.getHypothesis());
    result.getLattice().dumpDot("lattice.dot", "lattice");

   }
}

I highly appreciate the assistance.

Upvotes: 2

Views: 409

Answers (1)

Nikolay Shmyrev
Nikolay Shmyrev

Reputation: 25220

You are trying to use sphinx4 with semi-continuous model. You need to train continuous model to use with sphinx4, see for details

http://cmusphinx.sourceforge.net/wiki/tutorialam

You need to set

$CFG_HMM_TYPE = '.cont.'; # Sphinx 4, Pocketsphinx

Upvotes: 1

Related Questions