为什么我的Sphinx4识别能力差?

时间:2015-06-23 18:03:12

标签: eclipse speech-recognition cmusphinx sphinx4 language-model

我正在学习如何使用Eclipse的Maven插件来使用Sphinx4。

我在GitHub上找到了转录演示并对其进行了修改以处理我自己的文件。音频文件是16位,单声道,16khz。大约13秒。我注意到它听起来像是慢动作。

文件中的文字是,“还要确保您可以轻松访问录制文件,以便在收到问题时上传文件”。

我正在尝试转录该文件,我的结果非常糟糕。我试图找到彻底解释如何改进结果的论坛帖子或链接,或者我没有正确做的事情让我无处可去。

我希望加强转录的准确性,但是由于我当前项目必须处理的数据类型的差异,我希望避免自己培训模型。这是不可能的,是我正在使用的代码吗?

代码

(注意:音频文件位于https://instaud.io/8qv

public class App {

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:/edu/cmu/sphinx/models/en-us/en-us");

    // You can also load model from folder
    // configuration.setAcousticModelPath("file:en-us");

    configuration
            .setDictionaryPath("resource:/edu/cmu/sphinx/models/en-us/cmudict-en-us.dict");
    configuration
            .setLanguageModelPath("resource:/edu/cmu/sphinx/models/en-us/en-us.lm.dmp");

    StreamSpeechRecognizer recognizer = new StreamSpeechRecognizer(
            configuration);
    FileInputStream stream = new FileInputStream(new File("/home/tmscanlan/workspace/example/vocaroo_test_revised.wav"));
   // stream.skip(44); I commented this out due to the short length of my file

    // Simple recognition with generic model
    recognizer.startRecognition(stream);
    SpeechResult result;

    while ((result = recognizer.getResult()) != null) {
        // I added the following print statements to get more information
        System.out.println("\ngetWords() before loop: " + result.getWords());
        System.out.format("Hypothesis: %s\n", result.getHypothesis());
        System.out.print("\nThe getResult(): " + result.getResult() 
                + "\nThe getLattice(): " + result.getLattice()); 

        System.out.println("List of recognized words and their times:");
        for (WordResult r : result.getWords()) {
            System.out.println(r);
        }

        System.out.println("Best 3 hypothesis:");
        for (String s : result.getNbest(3))
            System.out.println(s);

    }
    recognizer.stopRecognition();

    // Live adaptation to speaker with speaker profiles


    stream = new FileInputStream(new File("/home/tmscanlan/workspace/example/warren_test_smaller.wav"));
   // stream.skip(44); I commented this out due to the short length of my file

    // Stats class is used to collect speaker-specific data
    Stats stats = recognizer.createStats(1);
    recognizer.startRecognition(stream);
    while ((result = recognizer.getResult()) != null) {
        stats.collect(result);
    }
    recognizer.stopRecognition();

    // Transform represents the speech profile
    Transform transform = stats.createTransform();
    recognizer.setTransform(transform);

    // Decode again with updated transform
    stream = new FileInputStream(new File("/home/tmscanlan/workspace/example/warren_test_smaller.wav"));
   // stream.skip(44); I commented this out due to the short length of my file
    recognizer.startRecognition(stream);
    while ((result = recognizer.getResult()) != null) {
        System.out.format("Hypothesis: %s\n", result.getHypothesis());
    }
    recognizer.stopRecognition();


    System.out.println("...Printing is done..");
}
}

这是输出(我拍摄的相册):http://imgur.com/a/Ou9oH

1 个答案:

答案 0 :(得分:1)

正如Nikolay所说,音频听起来很奇怪,可能是因为你没有以正确的方式重新采样。 要将音频从原始22050 Hz下采样到所需的16kHz,您可以运行以下命令:

sox Vocaroo.wav -r 16000 Vocaroo16.wav

Vocaroo16.wav听起来会好得多,它会(可能)给你更好的ASR结果。