Browse
 
Tools
Rss Categories

LV_SRE_LoadGlobalGrammarFromObject (Deprecated)

Reference Number: AA-00711 Views: 6911 0 Rating/ Voters

Loads a grammar identified by an HGRAMMAR handle 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_LoadGlobalGrammarFromObject(const char* gram_name, HGRAMMAR gram_handle)

Parameters

gram_name

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

gram_handle

An HGRAMMAR handle created by LVGrammar_Create and subsequently initialized with either LVGrammar_LoadGrammar or LVGrammar_LoadGrammarFromBuffer.

Return Values

LV_SUCCESS

No errors; this grammar is now ready to use.

LV_GRAMMAR_SYNTAX_WARNING

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

LV_GRAMMAR_LOADING_ERROR

Either gram_name is NULL or gram_handle is invalid.

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