【问题标题】:WAV Audio recording for Sphinx-4 failSphinx-4 的 WAV 音频录制失败
【发布时间】:2014-02-28 02:08:23
【问题描述】:

我使用 Audacity 录制了一个 wav 文件,用于测试 Sphinx-4 的转录器演示,我按照这篇文章中的说明进行操作:Sphinx4 speech recognition trasncribe demo not working accurately for short wav file

尤其是在这个答案中:

It must be 16khz 16bit mono little-endian file. 

之后我什至降低了噪音。但是当我尝试打印假设时出现空错误,这意味着我的记录存在问题:

Loading models...
Exception in thread "main" java.lang.NullPointerException
at transcriber.Transcriber.main(Transcriber.java:41)
Java Result: 1
BUILD SUCCESSFUL (total time: 2 minutes 14 seconds)

我打印假设的第 41 行。我该怎么做才能让它工作? 谢谢

编辑: 代码是:

package transcriber;

import java.net.URL;

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

/**
 *
 * @author ha
 */
public class Transcriber {

    /**
     * @param args the command line arguments
     */
    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:WAV/Hello.wav");
        recognizer.startRecognition(audioUrl.openStream());

        SpeechResult result = recognizer.getResult();
        System.out.println(recognizer.getResult().getHypothesis());

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

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

【问题讨论】:

  • 你确定这和录音有关吗?可能会发生 NullPointerException,因为您的代码中存在错误(某些内容为 null)。
  • 我很确定这是因为我的录音,因为当我使用演示音频运行它时,它工作得非常好:/
  • 当您询问例外情况时,请务必提供完整的例外情况文本
  • 我确实编辑了这个问题。希望对找到答案有更多帮助。谢谢
  • 我用教程中的转录器演示尝试了你的音频文件,并得到了正确的结果。确保您可以先重现我的结果,然后开始编写自己的代码。

标签: macos audio demo sphinx4 audacity


【解决方案1】:

替换

System.out.println(recognizer.getResult().getHypothesis());

System.out.println(result.getHypothesis());

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-04-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多