Used with StreamStartListening to register an SRGS grammar for use with a stream before it has been loaded with LoadGrammar. This is useful in several contexts and required for some. See Remarks, below, for more details.
- int RegisterGrammarForPendingStream(const char* gram_name)
The identifier for the grammar that will be loaded later.
The grammar was successfully deactivated.
An exception occurred while processing the request.
Added in LumenVoxversion 10.5, RegisterGrammarForPendingStream allows an application toinform the LumenVox streaming mechanism about a grammar before it isloaded. The benefit of informing the streaming mechanism about eachgrammar that will be loaded before calling StreamStartListening is that it allowsthe streaming mechanism to collect audio data, but hold off on processing ituntil the meta-tags in all the registered grammars have been processed.
In practical terms, calling RegisterGrammarForPendingStreamon each grammar allows an application to then spawn parallel grammar loadthreads, each of which can load and activate a grammar. Before or at the sametime, StreamStartListening can be called to capture audio data while grammarsare still loading. As soon as the first stage of grammar loading is done i.e.processing the meta-tags, the streamer starts processing the audio with thesettings that were applied in those meta-tags.
Note that you must still call ActivateGrammar on each grammar as normal, and likewise DeactivateGrammar when you are finished with it. RegisterGrammarForPendingStream just ensures that a grammar is loaded before audio is processed; it does not affect whether that grammar is active or not.
The list of registered grammars is cleared at the end of each stream, so grammars may need to be registered again during the next stream. There is no requirement to load a grammar again in the next stream, but users with dynamic grammars may wish to load the grammar again just to be safe (our grammar caching helps to ensure that loading a grammar again is fast if the grammar hasn't changed).
Though registering grammars before a stream is optional, it is our strong recommendation that anyone using the streaming interface use StreamStartListening and register the grammars prior to each stream to avoid situations where settings from all grammars are not loaded entirely before a stream begins processing. It also allows safe parallel loading of grammars, which can help optimize the speed of a speech application.
The use of RegisterGrammarForPendingStream is required for applications that make use of our Call Progress Analysis product to change the behavior of voice activity detection (e.g. to put it into tone detection mode or CPA mode). Using RegisterGrammarForPendingStream with StreamStartListening means that the LumenVox streaming mechanism will evaluate the meta tags of each grammar file before processing audio, ensuring that the voice activity detector is in the correct mode(s) before any audio data is processed.