我有一點與獅身人面像4在Java中的一個問題。我波紋管的實現代碼:獅身人面像4 - 控制檯
package test.ionut;
import edu.cmu.sphinx.frontend.util.Microphone;
import edu.cmu.sphinx.recognizer.Recognizer;
import edu.cmu.sphinx.result.Result;
import edu.cmu.sphinx.util.props.ConfigurationManager;
public class Test {
/**
* @param args
*/
public static void main(String[] args) {
ConfigurationManager manager;
if(args.length > 0){
manager=new ConfigurationManager(args[0]);
}else{
manager=new ConfigurationManager(Test.class.getResource("test.config.xml"));
}
Recognizer recognizer=(Recognizer)manager.lookup("recognizer");
recognizer.allocate();
Microphone mic=(Microphone)manager.lookup("microphone");
if(!mic.startRecording()){
System.out.println("Mic not identified.");
recognizer.deallocate();
System.out.println(1);
System.out.println("Say: (Good morning | Hello | Hi | Welcome) (Dipayan | Paul | Philip | Rita | Will)");
while(true){
System.out.println("Start speaking. Press Ctrl-C to quit.\n");
Result result = recognizer.recognize();
if(result != null) {
String resultText = result.getBestFinalResultNoFiller();
// System.out.println((new StringBuilder()).append("You said: ").append(resultText).append('\n').toString());
System.out.println("You said: "+resultText+"...");
} else {
System.out.println("I can't hear what you said.\n");
}
}
}
}
}
this is the grammar file:
***#JSGF V1.0;***
***grammar hello;***
***public <greet>= (Good morning | Hello | Hi | Welcome) (Paul | Philip | Rita | Will);***
and in the xml file i have modified so that the program knows what to do with the gram file.
Bellow is the part of the code where i modified the xml:
<!-- ******************************************************** -->
<!-- The Grammar configuration -->
<!-- ******************************************************** -->
<component name="jsgfGrammar" type="edu.cmu.sphinx.jsgf.JSGFGrammar">
<property name="dictionary" value="dictionary"/>
<property name="grammarLocation"
value="resource:/test/ionut/"/>
<property name="grammarName" value="mydict"/>
<property name="logMath" value="logMath"/>
</component>
Any help is appreciated.
的問題是,當我編譯的代碼,我沒有錯誤,但控制檯不顯示任何東西,甚至不是第一個打印。如果我通過添加不在字典中的單詞來修改克文件,然後點擊運行,控制檯會向我顯示該單詞是字典中已知單詞的錯誤。刪除單詞後,點擊運行,然後再次顯示:控制檯沒有顯示任何內容。另外我已經用-mx256m參數添加了額外的堆內存。
我一直在試圖整天跟這一點,因爲我要實現我自己的語言的話有獅身人面像4。但現在,我只是做了一些測試,得到與它一起使用。
很抱歉的壞編輯,不知道爲什麼的問題已發佈這樣的。如果你閱讀滾動窗格中的文本,你就會明白我在說什麼。再次,對不起... – Myself 2013-02-13 18:37:50