When loading a global grammar, the grammar will be sent to the server. And all following decode requests only contain global grammar ID's, instead of the actual grammars, to avoid network transportation overhead on large grammars.
A global grammar is associated with the client process that loads that grammar. All speech ports that are belong to that client have access to that global grammar. However, different client processes don't share global grammars with each other.
Generally, the lifetime of a global grammar is controlled by load and unload functions. However, in the case that users terminate client process without unloading global grammars, in order to release un-used global grammars, the server periodically checks if the client process is still alive. Once the server detected that a client process has been inactive for more than 10 minutes, it will remove all grammars associated with that client process.
In multi-threaded program, it is safe to access global grammars in read-only fashion on multiple threads simultaneously. For instance, querying whether a global grammar is loaded, or calling decode with global grammars. In the case that loading or unloading takes place, such as unloading a global grammar while decoding on another thread with that grammar, it is users' responsibility to prevent racing from happening.
static int LoadGlobalGrammar (const char* gram_name, const char* gram_location);
static int LoadGlobalGrammarFromBuffer (const char* gram_name, const char* gram_contents);
static int LoadGlobalGrammarFromObject (const char* gram_name, LVGrammar& gram_obj);
gram_name
The identifier for the grammar being loaded. Whenever you activate, deactivate, or unload, this is the identifier you will use.
gram_location
A file descriptor or 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"
gram_contents
A null terminated string containing the contents of a valid SRGS grammar file.
gram_obj
An LVGrammar object.
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_SYNTAX_ERROR
The grammar file was not understandable to the grammar compiler. You will not be able to decode with this grammar.
LV_GRAMMAR_LOADING_ERROR
The grammar compiler was unable to find the location of the grammar you loaded.
LV_GLOBAL_GRAMMAR_TRANSACTION_ERROR
Fail to send the grammar to all servers.
LV_GLOBAL_GRAMMAR_TRANSACTION_PARTIAL_ERROR
Fail to send the grammar to some of the servers.
Detailed error and warning messages are sent to the LVSpeechPort application-level logging callback function at priorities 0 and 1, respectively.
Users can load the same grammar with different labels. That will only create one instance of that grammar on the server.
LVSpeechPort::LoadGrammar functions
LVSpeechPort::IsGlobalGrammarLoaded functions
LVSpeechPort::UnloadGlobalGrammar functions
LV_SRE_LoadGlobalGrammar functions (C API)
Complete Help Topic List | Speech Engine Product Information