禁用CMUSphinx4中的控制台乱 [英] Disable console mess in CMUSphinx4

查看:152
本文介绍了禁用CMUSphinx4中的控制台乱的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试CMUSphinx,但我很难过。我已将 core 数据 jars包含在Eclipse中的项目中,我从这里

I'm trying CMUSphinx but I'm having a hard time. I have included core and data jars to the project in Eclipse which I have downloaded from here

我试着做现场语音识别正如在教程中所提到的那样但是当我尝试运行它时,控制台上充满了某种形式的像这样的错误字典缺少'....'这个词的拼音转录。

I tried to do Live speech recognition as mentioned in the tutorial but when I try to run it, the console is filled with some kind of errors like The dictionary is missing a phonetic transcription for the word '....' and many.

代码:

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

public class Hello {       

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


    configuration.setAcousticModelPath("resource:/edu/cmu/sphinx/models/en-us/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.bin");
    LiveSpeechRecognizer recognizer = new LiveSpeechRecognizer(configuration);

    while(true)
    {
    System.out.println("Start speaking...");
    recognizer.startRecognition(true);
    SpeechResult result = recognizer.getResult();
    System.out.println("result: "+result.getHypothesis());

    recognizer.stopRecognition();
    }

}
}

控制台:

23:15:07.552 INFO unitManager          CI Unit: *+NSN+
23:15:07.556 INFO unitManager          CI Unit: *+SPN+
23:15:07.556 INFO unitManager          CI Unit: AA
23:15:07.556 INFO unitManager          CI Unit: AE
23:15:07.556 INFO unitManager          CI Unit: AH
23:15:07.556 INFO unitManager          CI Unit: AO
...
...     /* Similar to above messages */
...
...
23:15:08.447 INFO autoCepstrum         Cepstrum component auto-configured as follows: autoCepstrum {MelFrequencyFilterBank, Denoise, DiscreteCosineTransform2, Lifter}
2016-02-22 23:15:08.649 java[68475:2340128] 23:15:08.649 WARNING:  140: This application, or a library it uses, is using the deprecated Carbon Component Manager for hosting Audio Units. Support for this will be removed in a future release. Also, this makes the host incompatible with version 3 audio units. Please transition to the API's in AudioComponent.h.
Start speaking... /* My Output */
23:15:08.653 INFO dictionary           Loading dictionary from: jar:file:/Users/sriharish/Java/sphinx4-data-5prealpha-20151218.160017-5.jar!/edu/cmu/sphinx/models/en-us/cmudict-en-us.dict
23:15:08.786 INFO dictionary           Loading filler dictionary from: jar:file:/Users/sriharish/Java/sphinx4-data-5prealpha-20151218.160017-5.jar!/edu/cmu/sphinx/models/en-us/en-us/noisedict
23:15:08.786 INFO acousticModelLoader  Loading tied-state acoustic model from: jar:file:/Users/sriharish/Java/sphinx4-data-5prealpha-20151218.160017-5.jar!/edu/cmu/sphinx/models/en-us/en-us
23:15:08.787 INFO acousticModelLoader  Pool means Entries: 16128
23:15:08.787 INFO acousticModelLoader  Pool variances Entries: 16128
23:15:08.787 INFO acousticModelLoader  Pool transition_matrices Entries: 42
23:15:08.787 INFO acousticModelLoader  Pool senones Entries: 5126
23:15:08.787 INFO acousticModelLoader  Gaussian weights: mixture_weights. Entries: 15378
23:15:08.787 INFO acousticModelLoader  Pool senones Entries: 5126
23:15:08.787 INFO acousticModelLoader  Context Independent Unit Entries: 42
23:15:08.788 INFO acousticModelLoader  HMM Manager: 137095 hmms
23:15:08.788 INFO acousticModel        CompositeSenoneSequences: 0
23:15:08.789 INFO trieNgramModel       Loading n-gram language model from: jar:file:/Users/sriharish/Java/sphinx4-data-5prealpha-20151218.160017-5.jar!/edu/cmu/sphinx/models/en-us/en-us.lm.bin
23:15:09.821 INFO dictionary           The dictionary is missing a phonetic transcription for the word '3-d'
23:15:09.821 WARNING trieNgramModel    The dictionary is missing a phonetic transcription for the word '3-d'
23:15:09.830 INFO dictionary           The dictionary is missing a phonetic transcription for the word 'adjustors'
23:15:09.830 WARNING trieNgramModel    The dictionary is missing a phonetic transcription for the word 'adjustors'
...
...    /* Similar to above messages */
...

23:15:11.231 INFO lexTreeLinguist      Max CI Units 43
23:15:11.232 INFO lexTreeLinguist      Unit table size 79507
23:15:11.234 INFO speedTracker         # -----------------------------         Timers----------------------------------------
23:15:11.235 INFO speedTracker         # Name               Count   CurTime   MinTime   MaxTime   AvgTime   TotTime   
23:15:11.237 INFO speedTracker         Compile              1       1.1360s   1.1360s   1.1360s   1.1360s   1.1360s   
23:15:11.238 INFO speedTracker         Load Dictionary      1       0.1330s   0.1330s   0.1330s   0.1330s   0.1330s   
23:15:11.238 INFO speedTracker         Load AM              1       2.0880s   2.0880s   2.0880s   2.0880s   2.0880s   
23:15:11.238 INFO speedTracker         Load LM              1       1.3080s   1.3080s   1.3080s   1.3080s   1.3080s   
23:15:16.674 INFO speedTracker            This  Time Audio: 0.37s  Proc: 4.12s  Speed: 11.14 X real time
23:15:16.676 INFO speedTracker            Total Time Audio: 0.37s  Proc: 4.12s 11.14 X real time
23:15:16.676 INFO memoryTracker           Mem  Total: 738.00 Mb  Free: 378.28 Mb
23:15:16.676 INFO memoryTracker           Used: This: 359.72 Mb  Avg: 359.72 Mb  Max: 359.72 Mb
23:15:16.676 INFO trieNgramModel       LM Cache Size: 870 Hits: 153862 Misses: 870
result: none /* My Output */

我已下载推荐罐子并将其包含在项目中。那么它有什么问题?他们没提供字典吗?我可以添加缺少的拼音吗?如果是,请提供链接。最后,我如何禁用所有控制台警告等,并且只有我提供的输出。

I have downloaded recommended jars and included it in the project.So what is wrong with it? Did they failed to provide a dictionary? Can I add the missing phonetic transcription? If yes, provide a link please. And finally how can I disable all the console warnings etc and only have output that I provide.

推荐答案

我遇到同样的问题我正在使用的唯一类是StreamSpeechRecognizer和Configuration。在查看了用于ConfigurationManagerUtils的sphinx源代码后,我设法在我自己的类中获取以下代码,以禁用来自edu.cmu.sphinx软件包的所有控制台日志记录。在实例化识别器之前放置此代码。

I have the same problem where the only classes I'm using are StreamSpeechRecognizer and Configuration. After looking through the sphinx source for ConfigurationManagerUtils I've managed to get the follow code in my own classes to disable all console logging from edu.cmu.sphinx packages. Place this code before instantiating the recognizer.

  Logger cmRootLogger = Logger.getLogger("default.config");
  cmRootLogger.setLevel(java.util.logging.Level.OFF);
  String conFile = System.getProperty("java.util.logging.config.file");
  if (conFile == null) {
        System.setProperty("java.util.logging.config.file", "ignoreAllSphinx4LoggingOutput");
  }

非常优雅,但它适用于我,除非有人有更清洁的方法来禁用通过sphinx配置/上下文类登录运行时

Hardly elegant but it works for me, unless someone has a cleaner approach for disabling logging at runtime through the sphinx configuration/context classes.

与我需要在自己的项目中使用的任何第三方软件包一样,我有直接在代码中执行此操作的正当理由,因为1 /我不关心任何第三方日志记录和2 /我不希望为第三方代码提供自定义日志记录配置文件。

As with any third party packages I need to consume in my own project, I have a valid reason for doing this directly in code because 1/ I don't care to expose any third party logging and 2/ I don't wish to ship customised logging configuration files for third party code.

这篇关于禁用CMUSphinx4中的控制台乱的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆