Browse
 
Tools
Rss Categories

LVSpeechPort::SwitchToNBestAlternative

Reference Number: AA-00825 Views: 1681 0 Rating/ Voters

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

  1. int nbest_total = port.GetNumberOfNBestAlternatives(voice_channel);

  2. int nbest_index;
  3. for (nbest_index = 0; nbest_index < nbest_total; ++nbest_index)
  4. {
  5. int ret_val = port.SwitchToNBestAlternative(voice_channel, nbest_index);
  6. if (ret_val != LV_SUCCESS)
  7. {
  8. // handle error, and possibly break out
  9. }

  10. int interp_total = port.GetNumberOfInterpretations(voice_channel);

  11. int interp_index;
  12. for (interp_index = 0; interp_index < interp_total; ++interp_index)
  13. {
  14. LVInterpretation interpretation = port.GetInterpretation(voice_channel, interp_index);

  15. // do something with the interpretation
  16. }
  17. }

See Also