2016-02-22 48 views
3

我正在嘗試CMUSphinx,但我很難。我已經包括coredata罐子在Eclipse項目我從here在CMUSphinx4中禁用控制檯混亂

我試圖做直播語音識別提到in the tutorial但是當我嘗試運行它,控制檯充滿了某種錯誤等下載The dictionary is missing a phonetic transcription for the word '....'和許多。

代碼:

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 */ 

我已經下載推薦的罐子和包括它在project.So有什麼錯呢?他們沒有提供字典嗎?我可以添加缺少的phonetic transcription嗎?如果是,請提供鏈接。最後,我如何禁用所有的控制檯警告等,只有我提供的輸出。

回答

6

我有同樣的問題,我只使用的類是StreamSpeechRecognizer和配置。查看了ConfigurationManagerUtils的sphinx源代碼之後,我設法在自己的類中獲得了下面的代碼,以禁用edu.cmu.sphinx包中的所有控制檯日誌記錄。在實例化識別器之前放置此代碼。

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"); 
    } 

幾乎優雅,但它爲我工作,除非有人通過獅身人面像的配置/上下文類在運行禁用日誌記錄一個更清潔的方式。

與任何第三方軟件包我需要在我自己的項目來消費,我有直接在代碼中這樣做的正當理由,因爲1 /我不在乎暴露任何第三方的日誌記錄和2 /我不」不希望爲第三方代碼提供自定義日誌配置文件。