This function can be called to load an SRGS grammar into the ASR from a specified Uniform Resource Identifier (URI) along with an optional list of MRCP-style headers. This function serves to facilitate the loading of grammars when being passed grammar loading parameters in an MRCP or HTTP environment. It is also useful for specifying grammar load parameters that cannot be stored in the grammar itself, such as Fetch-Timeout and Cache-control parameters.
Function
- int LoadGrammarWithParameters(const char* UniformResourceIdentifier,
const char* ParameterList)
Parameters
UniformResourceIdentifier
The URI describing the location or identity of the source grammar to be loaded.
ParameterList
A character buffer containing a list of key-value pairs delimited by "\r\n"
e.g. LV_SRE_LoadGrammarWithParameters(PortHandle, "http://localhost/mygram.gram", "Content-Id: 1\r\nCache-Control: no-cache\r\n");
Return Values
LV_SUCCESS
No errors; this grammar was loaded successfully from the URI and is now ready to use. This can be accessed using either the URI or optionally using the Content-Id specified in the parameter list.
LV_GRAMMAR_SYNTAX_WARNING
The grammar was successfully loaded from the URI provided, however was not fully conforming, but it was understandable and is now ready for use. The warning should be checked in the log file.
LV_INVALID_HPORT
The specified hport parameter is not a valid one.
LV_FAILURE
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.
LV_LICENSES_EXPIRED
The license associated with the port has been invalidated.
LV_GRAMMAR_LOADING_ERROR
The specified grammar failed to load for some reason other than the grammar's contents. The most common reason for this error is that the grammar is not accessible at the specified location.
LV_LOAD_GRAMMAR_TIMEOUT
Grammar failed to load within the time specified by the GRAMMAR_LOAD_TIMEOUT configuration value.
LV_GRAMMAR_SYNTAX_ERROR
Either the tag-format specified in the grammar is not supported or the grammar provided was not understandable to the grammar compiler. Grammar failed to load due to invalid grammar syntax. This can usually be fixed by modifying the contents of the grammar.
LV_NO_SERVER_AVAILABLE
There are no ASR servers available to load and compile the grammar.
LV_ACTIVE_GRAMMAR_INVALID_LANGUAGE
The connected ASR server(s) do not support the language of the grammar being loaded.
LV_EXCEPTION
An exception occurred while processing the request.
Remarks
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.
See Also