Loads an SRGS grammar into the speech port for later use in a decode, DTMF decode or interpret text operation.
- int LoadGrammar(const char* gram_name, const char* gram_uri)
int LoadGrammar(const char* gram_uri)
The identifier for the grammar being loaded. Whenever you activate, deactivate, or unload, this is the identifier you will use. If LoadGrammar is called without this parameter, use the uri as the label.
A URI that points to a valid SRGS grammar file, such as "c:/grammars/pizza.grxml", "http://www.gramsRus.com/phonenumber.gram", or "builtin:dtmf/boolean?y=1;n=2"
This URI can be a builtin reference, a file system reference, or remote HTTP reference, and as of LumenVox version 11.2.100, users may also specify resources located on secure HTTPS servers
No errors; this grammar is now ready to use.
The grammar file was not fully conforming, but it was understandable and is now ready for use.
The port is not valid (either CreateClient has not been called or DestroyClient has been called prior to this call).
The operation may have failed because the port was shutting down or the vocab size of the grammar is zero. The error also occurs when an internal failure has occurred, may be out of resources.
The license associated with the port has been invalidated.
The grammar could not be loaded due to a license not being available.
Either gram_name or gram_uri, or both are NULL; or gram_uri points to an invalid location.
Sending the grammar to the ASR server timed out.
Either the tag-format specified in the grammar is not supported or the grammar file was not understandable to the grammar compiler.
There are no ASR servers available to load and compile the grammar.
The connected ASR server(s) do not support the language of the grammar being loaded.
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.
It is possible that some of the above return codes may get returned for different underlying reasons. Use ReturnGrammarErrorString to obtain a description of the actual reason for failure.
// 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 = port.LoadGrammar(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 = port.ActivateGrammar(grammar_name);
error code = port.StreamSetParameter(STREAM_PARM_GRAMMAR_SET,