speech recognition - How can I display the rule that has been used in my grammar file in sphinx4 java code? -
my code display rules found in grammar file : configuration configuration = new configuration();
configuration .setacousticmodelpath("src/en-us"); configuration .setdictionarypath("src/9256.dic"); configuration .setgrammarpath("src/dialog/"); configuration .setusegrammar(true); configuration .setgrammarname("dialog"); //grammar.loadjsgf(gram_name); //string gram_name = configuration.getgrammarname(); dictionary dictionary=new textdictionary("src/9256.dic","src/en-us/noisedict",null,false, null,new unitmanager()); jsgfgrammar grammar = new jsgfgrammar("src/dialog/", "dialog", false, false, false, false, dictionary); grammar.allocate(); livespeechrecognizer recognizer = new livespeechrecognizer(configuration); recognizer.startrecognition(true); speechresult result; while ((result = recognizer.getresult()) != null) { system.out.format("hypothesis: %s;\n", result.gethypothesis()); system.out.println("****************************************"); system.out.format("used rule is: %s;\n",grammar.getrulegrammar().getrulenames()); } recognizer.stoprecognition();
Comments
Post a Comment