Rss Categories


Reference Number: AA-01795 Views: 2824 0 Rating/ Voters

Used with LV_SRE_StreamStartListening to register an SRGS grammar for use with a stream before it has been loaded with LV_SRE_LoadGrammar. This is useful in several contexts and required for some. See Remarks, below, for more details.


  • int LV_SRE_RegisterGrammarForPendingStream(HPORT hport, const char* gram_name)



The handle for the speech port.


The identifier for the grammar that will be loaded later.

Return Values


No errors; this grammar is now registered.


An exception occurred while processing the request.


Added in LumenVox version 10.5, LV_SRE_RegisterGrammarForPendingStream allows an application to inform the LumenVox streaming mechanism about a grammar before it is loaded. The benefit of informing the streaming mechanism about each grammar that will be loaded before calling StreamStartListening is that it allows the streaming mechanism to collect audio data, but hold off on processing it until the meta-tags in all the registered grammars have been processed.

In practical terms, calling RegisterGrammarForPendingStream on each grammar allows an application to then spawn parallel grammar load threads, each of which can load and activate a grammar. Before or at the same time, StreamStartListening can be called to capture audio data while grammars are 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 the settings that were applied in those meta-tags.

Note that you must still call LV_SRE_ActivateGrammar on each grammar as normal, and likewise LV_SRE_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.

See Also