Browse
 
Tools
Rss Categories

LV_SRE_SwitchToNBestAlternative

Reference Number: AA-00736 Views: 6962 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 LV_SRE_CreateInterpretation.

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 LV_SRE_SwitchToNBestAlternative(HPORT hport, int VoiceChannel, int index)

Parameters

hport

The port's handle.

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, (LV_SRE_GetNumberOfNBestAlternatives() - 1)].

Return Values

LV_SUCCESS

The switch to the specified index succeeded.

LV_INVALID_HPORT

The input hport is not a valid one.

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;
  2. int nbest_index;
  3. int interp_total;
  4. int interp_index;
  5. H_SI interpretation;
  6. int ret_val;
  7.  
  8. nbest_total = LV_SRE_GetNumberOfNBestAlternatives(port_handle, voice_channel);
  9. for (nbest_index = 0; nbest_index < nbest_total; ++nbest_index)
  10. {
  11. ret_val = LV_SRE_SwitchToNBestAlternative(port_handle, voice_channel, nbest_index);
  12. if (ret_val != LV_SUCCESS)
  13. {
  14. // handle error, and possibly break out
  15. }
  16.  
  17. interp_total = LV_SRE_GetNumberOfInterpretations(port_handle, voice_channel);
  18.  
  19. for (interp_index = 0; interp_index < interp_total; ++interp_index)
  20. {
  21. interpretation = LV_SRE_CreateInterpretation(port_handle, voice_channel, interp_index);
  22.  
  23. // do something with the interpretation, and don't forget to release it
  24. }
  25. }

See Also