2014-09-02 44 views
2

我創建了Sphinx4(語言模型,字典和聲學模型)所需的所有模型。我在Eclipse中創建了一個Maven項目並下載了所有的庫,但是當我運行程序(如官方網站所示)時,會出現一個異常。嘗試Sphinx4時IndexOutOfBound

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) 

,我正在運行的源代碼如下:

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"); 

    } 
} 

我高度讚賞援助。

回答

1

您正在嘗試將sphinx4與半連續模型一起使用。你需要訓練連續模型sphinx4使用,詳見

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

您需要設置

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

連續和半連續式兩種類型的CMUSphinx支持的聲學模型。它們不同於模型的內部結構。連續模型更精確,半連續模型更快,更緊湊,但不夠精確。 Sphinx4僅支持連續模式。 Pocketsphinx支持連續和半連續模式。 – 2014-09-02 18:02:34

+0

非常感謝,但是如果您可以詳細說明可以設置上述參數的文件? – coding4fun 2014-09-02 18:04:20

+0

當您訓練聲學模型時,在etc/sphinx_train.cfg中。 – 2014-09-02 18:06:58