Browse
 
Tools
Rss Categories

LVSpeechPort::LoadGlobalGrammarFromObject (Deprecated)

Reference Number: AA-00798 Views: 7218 0 Rating/ Voters

Loads a grammar specified as a reference to an LVGrammar object 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

  • static int LoadGlobalGrammarFromObject(const char* gram_name, LVGrammar &gram;_obj)

Parameters

gram_name

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

gram_obj

An LVGrammar object

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_obj 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 that the C++ version of LV_SRE_ReturnGrammarErrorString (ReturnGrammarErrorString) does not support querying status description for global grammars.

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