If you wish to use an SRGS grammar for decode, you need to activate it. Activating a grammar puts it in the multi-grammar grammarset called LV_ACTIVE_GRAMMAR_SET. The grammars that were activated can then be used for a decode by specifying LV_ACTIVE_GRAMMAR_SET as the grammarset parameter in a call to Decode, or by setting the STREAM_PARM_GRAMMAR_SET equal to the LV_ACTIVE_GRAMMAR_SET before calling StreamStart. The reason for this mechanism is to maintain backward compatibility with previous APIs.
When ActivateGrammar is called, first the grammar is searched for among the grammars in the speech port's loaded grammars. If it can not be found there, the collection of application level grammars is searched.
- int LV_SRE_ActivateGrammar(HPORT hport, const char* gram_name)
The handle of the speech port for which you are activating the grammar.
The identifier for the grammar being activated.This is the same identifier that was given to the grammar when it was loaded.
No errors; this grammar is now active.
This grammar could not be activated, because it was not found in the speech port's set of loaded grammars.
The input hport is not a valid one.
An exception occurred while processing the request.
Detailed error and warning messages are sent to the speech port's logging callback function at priorities 0 and 1, respectively.
// Below is an example of a subroutine that loads and activates a grammar.
void LoadGrammar(char *grammar_name, char *grammar_file)
printf("Loading the grammar and activating it.\n");
error code = LV_SRE_LoadGrammar(hport, grammar_name, grammar_file);
// Once you load up a grammar you can activate and deactivate it
// at any point during the call flow.
error code = LV_SRE_ActivateGrammar(hport, grammar_name);
error code = LV_SRE_StreamSetParameter(hport, STREAM_PARM_GRAMMAR_SET,