After a decode operation, if multiple n-best alternatives are available, you can use this function to switch to a particular n-best alternative for later viewing by a result retrieval call like GetInterpretation.
The default number of n-best alternatives returned from a decode operation is one. You can increase this value by setting PROP_EX_MAX_NBEST_RETURNED.
Function
- int SwitchToNBestAlternative(int VoiceChannel, int index)
Parameters
VoiceChannel
The channel containing the decoded audio.
index
The index of the n-best alternative to switch to. It can be any value in the range [0, (GetNumberOfNBestAlternatives() - 1)].
Return Values
LV_SUCCESS
The switch to the specified index succeeded.
LV_INVALID_HPORT
The port is not valid (either CreateClient has not been called or DestroyClient has been called prior to this call).
LV_FAILURE
The operation failed because the port was shutting down.
LV_INVALID_INDEX
The input index is out of range.
LV_INVALID_SOUND_CHANNEL
The input VoiceChannel is not valid.
LV_TIME_OUT
Answers are not yet available.
LV_EXCEPTION
An exception occurred while processing the request.
Remarks
Each alternative represents a distinct sentence. However, since some sentences can have multiple interpretations or multiple parses, it is possible that for some alternatives you will have multiple parse tree or interpretation objects returned. For this reason, you should get all results out as follows:
C++ Code
-
int nbest_total = port.GetNumberOfNBestAlternatives(voice_channel);
-
int nbest_index;
-
for (nbest_index = 0; nbest_index < nbest_total; ++nbest_index)
-
{
-
int ret_val = port.SwitchToNBestAlternative(voice_channel, nbest_index);
-
if (ret_val != LV_SUCCESS)
-
{
-
// handle error, and possibly break out
-
}
-
int interp_total = port.GetNumberOfInterpretations(voice_channel);
-
int interp_index;
-
for (interp_index = 0; interp_index < interp_total; ++interp_index)
-
{
-
LVInterpretation interpretation = port.GetInterpretation(voice_channel, interp_index);
-
// do something with the interpretation
-
}
-
}
See Also