2014-12-18 73 views
0

我試圖關注this tutorial,並且它在啓動後崩潰了很多字典和模型的問題,例如。sphinx-4 NullPointerException在startRecognition

The dictionary is missing a phonetic transcription for the word 'humphrey'

Dec 18, 2014 1:14:50 PM edu.cmu.sphinx.linguist.lextree.HMMTree addPronunciation SEVERE: Missing HMM for unit T with lc=N rc=EH1 13:14:50.601 SEVERE lexTreeLinguist Bad HMM Unit: EH1

我裝this dictionary並得到了their SourceForge page

語言和聲學模型隨後,應用此崩潰:

Exception in thread "main" java.lang.NullPointerException 
    at edu.cmu.sphinx.linguist.lextree.HMMNode.getBaseUnit(HMMTree.java:506) 
    at edu.cmu.sphinx.linguist.lextree.HMMNode.<init>(HMMTree.java:484) 
    at edu.cmu.sphinx.linguist.lextree.Node.addSuccessor(HMMTree.java:165) 
    at edu.cmu.sphinx.linguist.lextree.HMMTree$EntryPoint.createEntryPointMap(HMMTree.java:1163) 
    at edu.cmu.sphinx.linguist.lextree.HMMTree$EntryPointTable.createEntryPointMaps(HMMTree.java:1021) 
    at edu.cmu.sphinx.linguist.lextree.HMMTree.compile(HMMTree.java:795) 
    at edu.cmu.sphinx.linguist.lextree.HMMTree.<init>(HMMTree.java:716) 
    at edu.cmu.sphinx.linguist.lextree.LexTreeLinguist.generateHmmTree(LexTreeLinguist.java:433) 
    at edu.cmu.sphinx.linguist.lextree.LexTreeLinguist.compileGrammar(LexTreeLinguist.java:420) 
    at edu.cmu.sphinx.linguist.lextree.LexTreeLinguist.allocate(LexTreeLinguist.java:337) 
    at edu.cmu.sphinx.decoder.search.WordPruningBreadthFirstSearchManager.allocate(WordPruningBreadthFirstSearchManager.java:232) 
    at edu.cmu.sphinx.decoder.AbstractDecoder.allocate(AbstractDecoder.java:92) 
    at edu.cmu.sphinx.recognizer.Recognizer.allocate(Recognizer.java:167) 
    at edu.cmu.sphinx.api.LiveSpeechRecognizer.startRecognition(LiveSpeechRecognizer.java:46) 
    at com.test.sphinxtest.App.main(App.java:25) 

這是我的代碼。

package com.test.sphinxtest; 

import java.io.IOException; 

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

/** 
* Hello world! 
* 
*/ 
public class App 
{ 
    public static void main(String[] args) 
    { 
     Configuration configuration = new Configuration(); 

     configuration.setAcousticModelPath("models/acousticmodel/en-us"); 
     configuration.setDictionaryPath("dictionary/cmudict-0.6d"); 
     configuration.setLanguageModelPath("models/languagemodel/en-us.lm"); 

     try { 
      LiveSpeechRecognizer recognizer = new LiveSpeechRecognizer(configuration); 
      recognizer.startRecognition(true); 
      SpeechResult result = recognizer.getResult(); 
      recognizer.stopRecognition(); 
      while ((result = recognizer.getResult()) != null) { 
       System.out.println(result.getHypothesis()); 
      } 
     } catch (IOException e) { 
      // TODO Auto-generated catch block 
      e.printStackTrace(); 
     } 
    } 
} 

回答

1

正確的字典不應該有壓力的痕跡,你可以從這裏下載:

https://raw.githubusercontent.com/cmusphinx/pocketsphinx/master/model/en-us/cmudict-en-us.dict

+0

是什麼意思了一本字典是「正確」?我如何知道哪些是「正確的」,哪些是「不正確的」? – Houseman

+0

詞典手機必須匹配聲學模型的手機。如果它匹配字典是正確的,否則不正確,你會得到類似上面的錯誤。這個問題在教程中介紹。 –

+0

本教程涵蓋了哪些問題?也許我正在看錯誤的教程,或者按順序或其他方式遵循它。 – Houseman