gpt4 book ai didi

java - 如何使用 CMU Sphinx 将音频文件转换为文本

转载 作者:太空宇宙 更新时间:2023-11-04 14:37:08 25 4
gpt4 key购买 nike

我正在尝试转换音频文件,下面是我的代码

public class test {
public static void main(String[] args) throws Exception {
System.out.println("Loading models...");

Configuration configuration = new Configuration();

// Load model from the jar
configuration.setAcousticModelPath("resource:/WSJ_8gau_13dCep_16k_40mel_130Hz_6800Hz");
configuration.setDictionaryPath("resource:/WSJ_8gau_13dCep_16k_40mel_130Hz_6800Hz/dict/cmudict.0.6d");
configuration.setLanguageModelPath("models/language/en-us.lm.dmp");

StreamSpeechRecognizer recognizer = new StreamSpeechRecognizer(configuration);


URL audioUrl = new URL("file:///C:/Sound1.wav");
recognizer.startRecognition(audioUrl.openStream());

SpeechResult result;

while ((result = recognizer.getResult()) != null) {
System.out.format("Hypothesis: %s\n",
result.getHypothesis());
}

System.out.println("Stop Recognition..");
recognizer.stopRecognition();
}
}

但我在 while ((result = recognizer.getResult()) != null) 行遇到以下异常: ;

Exception in thread "main" java.lang.NegativeArraySizeException
at edu.cmu.sphinx.frontend.feature.LiveCMN.initMeansSums(LiveCMN.java:130)
at edu.cmu.sphinx.frontend.feature.LiveCMN.getData(LiveCMN.java:161)

请建议我如何解决这个问题。

最佳答案

此问题已在修订版 12586 中的 Subversion 中得到修复。

关于java - 如何使用 CMU Sphinx 将音频文件转换为文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25426187/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com