Loads a grammar specified as a string buffer 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.
- static int LoadGlobalGrammarFromBuffer(const char* gram_name, const char* gram_buffer)
The identifier for the grammar being loaded. Whenever you activate, deactivate, or unload, this is the identifier you will use.
A NULL-terminated string containing the contents of a valid SRGS grammar.
No errors; this grammar is now ready to use.
The grammar provided was not fully conforming, but it was understandable and is now ready for use.
Either gram_name or gram_buffer, or both are NULL.
Sending the grammar to the ASR server timed out.
Either the tag-format specified in the grammar is not supported or the grammar provided 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 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)