Processes the voice channel audio data against the active grammar. This is the manual process of telling the Engine to perform a recognition. The two most common reasons to use this function are to perform off-line decodes on existing audio or to programatically control whether to decode after a streaming process.
- int Decode(int VoiceChannel, int GrammarSet, unsigned int flags = 0)
The audio channel holding the decode audio.
The grammar to use for the decode. When using SRGS grammars this value should be set to LV_ACTIVE_GRAMMAR_SET. This tells the decoder to use every SRGS grammar which has been loaded and activated. Other values indicate the Engine should use a concept/phrase grammar set.
Note: Rather than using concept/phrase grammars, LumenVox encourages the use of SRGS
grammars provide a standards-based method of creating grammars that is more robust and easier to troubleshoot than concept/phrase grammars. See our SRGS
tutorial for more information on working with SRGS
grammars. Concept phrase grammars were deprecated since 10.0
flags (bitwise OR flags to set desired options)
LV_DECODE_BLOCK - Decode will not return until it has finished.
LV_DECODE_SEMANTIC_INTERPRETATION - This flag is deprecated. It tells the Engine to expect SISR in the tags of the SRGS grammar. Without this, the engine will ignore what is contained in tag elements.
A positive number will be returned if you have set LV_DECODE_BLOCK. This number indicates how many interpretations the ASR was able to decode.
LV_SUCCESS will be returned if the LV_DECODE_BLOCK flag was not set. This return indicates that the port was able to successfully communicate with the server.
Indicates that the language specified in the grammar is either invalid or is not available on the ASR server.
Indicates that more than one language was specified in the active grammar set.
Indicates that you do not have the right license type for the decode. Either a Lite license was used when the vocabulary size of the active grammar set exceeded 500, or an SLM decode operation was attempted with a non-SLM license.
Sound sample was < 1/8 of a second.
This grammar could not be activated, because the port was shutting down.
Indicates an error in using an active grammar for the decode operation (eg: there were no words in the compiled grammar).
Indicates License used is not valid.
The grammar could not be loaded due to a license not being available.
The port is not valid (either CreateClient has not been called or DestroyClient has been called prior to this call).
The input VoiceChannel is not a valid one.
Indicates that the license acquired for the decode operation does not permit the use of the current version of the ASR server.
Indicates that no ASR servers were available to perform the decode.
Indicates that the preceeding decode operation timed out.
An exception occurred while processing the request.
Note: that if the number of interpretations against a grammar grows so high that continuing to build parse trees will cause memory issues, the Engine will return no interpretations but the client will not return an error (this is usually caused by improperly designed grammars that feature some sort of recursion). If the Engine returns no interpretations, please check the decode server log to see if the server recorded an error.
When not blocking the function, GetLastDecodeError should be called to check for additional grammar/language issues which may have occurred during the recognition process.
If LV_DECODE_BLOCK is set, Decode will not return until it has finished processing the data.
If LV_DECODE_BLOCK is not set, Decode returns immediately (but continues processing the data on a separate thread); the client application can continue its own work. Calling other LVSpeechPort methods may block until the Decode is finished. Once the client application is ready to check for results, call WaitForEngineToIdle. If any function which requests the results of the decode is called before the result is ready, the function itself will call WaitForEngineToIdle with an infinite timeout.
On an error, call ReturnErrorString with the negative result from Decode to get a description of the error.
Of the error codes listed above, LV_INVALID_SOUND_CHANNEL is returned due to an error in the input to the function.