【问题标题】:how to convert audio file into text using CMU Sphinx如何使用 CMU Sphinx 将音频文件转换为文本
【发布时间】:2014-08-21 12:18:22
【问题描述】:

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

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)

请告诉我如何解决这个问题。

【问题讨论】:

  • 确保输入文件格式正确 - 16khz 16bit 单声道 PCM 文件。
  • 它只适用于这种格式????
  • 是的,如果您有不同的样品,您可以使用 sox 重新取样。
  • 这个文件也出现同样的错误 test_mono_16000Hz_16bit_PCM.wav 它有 16khz 16bit 单声道 PCM 格式
  • 对不起,直到现在我试图转换一个只有音乐曲目的音频文件,这可能是错误的原因。

标签: java cmusphinx audio-converter


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2012-11-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-02
    • 1970-01-01
    • 2011-09-25
    • 2021-10-05
    • 1970-01-01
    相关资源
    最近更新 更多