我在cmusphinx的预训练模型上遇到错误:java.lang.IndexOutOfBoundsException?

时间:2020-11-11 16:13:31

标签: java maven speech-to-text cmusphinx

我正在尝试使用CmuSphinx在Java应用程序中获取语音输入(文本)。 我在Google和文档上进行了搜索,但没有找到任何内容。

是否有更好的模型或有效的[SpeechToText]? 我在几乎空白的Java项目中将IntelliJ与Maven结合使用。

import edu.cmu.sphinx.api.Configuration;
import edu.cmu.sphinx.api.LiveSpeechRecognizer;
import edu.cmu.sphinx.api.SpeechResult;
import edu.cmu.sphinx.result.WordResult;

public class LiveSTT {

    public static void main(String[] args) throws Exception {
        final Configuration configuration = new Configuration();

        configuration.setAcousticModelPath(
"model/cmusphinx-ptm-voxforge-de-r20171217/model_parameters/voxforge.cd_ptm_5000/" //<---there----
        );

        configuration.setDictionaryPath("de.dic");

        configuration.setLanguageModelPath("de.lm.bin");

        configuration.setSampleRate(8000);

        final LiveSpeechRecognizer recognizer = new LiveSpeechRecognizer(configuration);

        recognizer.startRecognition(true);

        SpeechResult result = recognizer.getResult();

        while ((result = recognizer.getResult()) != null) {
            System.out.println(result.getHypothesis());
            
            for (final WordResult r : result.getWords()) {
                System.out.println(r);
            }
        }
        recognizer.stopRecognition();
    }
}

Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 25728, Size: 25728
    [...]
edu.cmu.sphinx.decoder.search.WordPruningBreadthFirstSearchManager.newProperties(WordPruningBreadthFirstSearchManager.java:213)
    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 test.development.LiveSTT.main(LiveSTT.java:24)

0 个答案:

没有答案