我有一点与狮身人面像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