Hello,
the following code produces only one RuleGrammar instance:
Recognizer rec; <init ...>
RuleGrammar gram1 = rec.loadJSGF(new URL(baseURL), grammarName1);
RuleGrammar gram2 = rec.loadJSGF(new URL(baseURL), grammarName2);
But gram1 and gram2 are the same object, and the rules of gram1 are overwritten by the rules of gram2.
Why is this? (Also commiting changed before loading the seconds grammar does not help)
Here's the code how I initialize the recognizer (omitting exception handling):
EngineModeDesc desc = new EngineModeDesc(Locale.GERMANY);
rec = Central.createRecognizer(desc);
rec.allocate();
rec.waitEngineState(Engine.ALLOCATED);
RecognizerProperties props = rec.getRecognizerProperties();
props.setIncompleteTimeout(2);
props.setNumResultAlternatives(3);
props.setResultAudioProvided(true);
props.setConfidenceLevel(0.8f);
props.setSpeedVsAccuracy(1f);
rec.requestFocus();
rec.resume();
rec.waitEngineState(Engine.RESUMED);
|