Rss Categories

LV_SRE_LoadGlobalGrammar (Deprecated)

Reference Number: AA-00709 Views: 1838 0 Rating/ Voters

Loads a grammar into the speech client process' global space.

A grammar loaded this way is called a global grammar and is associated with the speech client process that loads it. All speech ports that are created in the client process have access to that global grammar. The scope of the global grammar is limited only to the client process that loads it, different client processes cannot share global grammars with each other.

In multi-threaded program, it is safe to access global grammars in a read-only fashion on multiple threads simultaneously. For instance, querying whether a global grammar is loaded, or performing decode with global grammars. Replacing/reloading and unloading of a global grammar while another thread is using the grammar (say, for a decode operation) results in a race condition and it is the users' responsibility to avoid such situations.


  • int LV_SRE_LoadGlobalGrammar(const char* gram_name, const char* gram_uri)



The identifier for the grammar being loaded.  Whenever you activate, deactivate, or unload, this is the identifier you will use.


A URI that points to a valid SRGS grammar file, such as "c:/grammars/pizza.grxml", "", or "builtin:dtmf/boolean?y=1;n=2"

This URL 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

Return Values


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.


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.


An internal failure has occurred, may be out of resources; or the vocab size of the grammar is zero.


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 LVSpeechPort application-level 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 LV_SRE_ReturnGrammarErrorString (passing NULL for the parameter hport to the call) to obtain a description of the actual reason for failure.

NOTE: As of LumenVox version 12.1, the use of "Global" grammars, and related functions has been deprecated. There is no longer any benefit from using global grammars (assigned at the application level) due to the advanced grammar caching mechanism that has been in place for some time.  Users should adopt the use of port-assigned grammar functions (basically consisting of the same name, but without the 'Grammar' portion)

See Also