Browse
 
Tools
Rss Categories

LV_SRE_LoadGlobalGrammar (Deprecated)

Reference Number: AA-00709 Views: 7242 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.

Function

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

Parameters

gram_name

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

gram_uri

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

LV_SUCCESS

No errors; this grammar is now ready to use.

LV_GRAMMAR_SYNTAX_WARNING

The grammar file was not fully conforming, but it was understandable and is now ready for use.

LV_GRAMMAR_LOADING_ERROR

Either gram_name or gram_uri, or both are NULL; or gram_uri points to an invalid location.

LV_LOAD_GRAMMAR_TIMEOUT

Sending the grammar to the ASR server timed out.

LV_GRAMMAR_SYNTAX_ERROR

Either the tag-format specified in the grammar is not supported or the grammar file was not understandable to the grammar compiler.

LV_FAILURE

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

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