当前位置: 首页>>代码示例>>Java>>正文


Java RuleGrammar类代码示例

本文整理汇总了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");
    }
}
 
开发者ID:alexycruz1,项目名称:LP_Proyecto,代码行数:34,代码来源:Escucha.java

示例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);
    }
}
 
开发者ID:alexycruz1,项目名称:LP_Proyecto,代码行数:25,代码来源:Principal.java

示例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) {
    }
}
 
开发者ID:alexycruz1,项目名称:LP_Proyecto,代码行数:10,代码来源:Principal.java

示例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;
}
 
开发者ID:CognitiveModeling,项目名称:BrainControl,代码行数:6,代码来源:RuleParser.java

示例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;
}
 
开发者ID:glaudiston,项目名称:project-bianca,代码行数:16,代码来源:DialogManager.java


注:本文中的javax.speech.recognition.RuleGrammar类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。