本文整理汇总了Java中javax.speech.recognition.RuleGrammar类的典型用法代码示例。如果您正苦于以下问题:Java RuleGrammar类的具体用法?Java RuleGrammar怎么用?Java RuleGrammar使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RuleGrammar类属于javax.speech.recognition包,在下文中一共展示了RuleGrammar类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resultAccepted
import javax.speech.recognition.RuleGrammar; //导入依赖的package包/类
public void resultAccepted(ResultEvent re) {
try {
Result res = (Result) (re.getSource());
ResultToken tokens[] = res.getBestTokens();
String args[] = new String[1];
args[0] = "";
for (int i = 0; i < tokens.length; i++) {
gst = tokens[i].getSpokenText();
args[0] += gst + " ";
System.out.print(gst);
}
Temp.setGst(gst);
System.out.println();
if (gst.equals("Exit")) {
recognizer.deallocate();
args[0] = "Hasta la proxima!";
System.out.println(args[0]);
System.exit(0);
} else {
recognizer.suspend();
recognizer.resume();
}
FileReader grammar1 = new FileReader("e:/Proyectos/LP_Proyecto/VoiceRecognizer/Gramatica.txt");
RuleGrammar rg = recognizer.loadJSGF(grammar1);
rg.setEnabled(true);
} catch (Exception ex) {
System.out.println("Palabra captada");
}
}
示例2: Recognizer
import javax.speech.recognition.RuleGrammar; //导入依赖的package包/类
public void Recognizer() {
try {
recognizer = Central.createRecognizer(new EngineModeDesc(Locale.ROOT));
recognizer.allocate();
FileReader grammar1 = new FileReader("e:/Proyectos/LP_Proyecto/VoiceRecognizer/Gramatica.txt");
RuleGrammar rg = recognizer.loadJSGF(grammar1);
rg.setEnabled(true);
System.out.println(GPalabra.getGst());
recognizer.addResultListener(new Escucha(GPalabra));
System.out.println("Empieze Dictado");
recognizer.commitChanges();
recognizer.requestFocus();
recognizer.resume();
} catch (Exception e) {
System.out.println("Exception en " + e.toString());
e.printStackTrace();
System.exit(0);
}
}
示例3: RecargarGramatica
import javax.speech.recognition.RuleGrammar; //导入依赖的package包/类
public void RecargarGramatica() {
try {
FileReader grammar1 = new FileReader("e:/Proyectos/LP_Proyecto/VoiceRecognizer/Gramatica.txt");
RuleGrammar rg = recognizer.loadJSGF(grammar1);
rg.setEnabled(true);
} catch (Exception e) {
}
}
示例4: getRuleParse
import javax.speech.recognition.RuleGrammar; //导入依赖的package包/类
private RuleParse getRuleParse(String resultText) throws GrammarException {
RuleGrammar ruleGrammar = new BaseRuleGrammar(jsapiRecognizer, grammar.getRuleGrammar());
RuleParse ruleParse = ruleGrammar.parse(resultText, null);
return ruleParse;
}
示例5: getRuleParse
import javax.speech.recognition.RuleGrammar; //导入依赖的package包/类
/**
* Retrieves the rule parse for the given result
*
* @param the
* recognition result
* @return the rule parse for the result
* @throws GrammarException
* if there is an error while parsing the result
*/
RuleParse getRuleParse(Result result) throws GrammarException {
String resultText = result.getBestFinalResultNoFiller();
RuleGrammar ruleGrammar = (RuleGrammar) getGrammar().getRuleGrammar(); // FIXME
RuleParse ruleParse = ruleGrammar.parse(resultText, null);
return ruleParse;
}