MaxAlternates Property

Microsoft Speech Platform SDK 11

Collapse imageExpand ImageCopy imageCopyHover image

Gets or sets the maximum number of alternate recognition results that the SpeechRecognitionEngine returns for each recognition operation.

Namespace:  Microsoft.Speech.Recognition
Assembly:  Microsoft.Speech (in Microsoft.Speech.dll)

Syntax

Visual Basic (Declaration)
Public Property MaxAlternates As Integer
	Get
	Set
Visual Basic (Usage)
Dim instance As SpeechRecognitionEngine
Dim value As Integer

value = instance.MaxAlternates

instance.MaxAlternates = value
C#
public int MaxAlternates { get; set; }

Property Value

Type: System..::..Int32

The number of alternate results to return.

Remarks

The Alternates property of the RecognitionResult class contains the collection of RecognizedPhrase objects that represent possible interpretations of the input.

The default value for MaxAlternates is 10.

Examples

The example below shows a handler for a TextChanged()()()() event that allows end user to update the value of MaxAlternates.

 Copy imageCopy Code
private void _maxAltsInput_TextChanged(object sender, EventArgs e) 
{
  int newMax;
  newMax = _recognizer.MaxAlternates;
  try 
  {
    newMax = int.Parse(_maxAltsInput.Text, System.Globalization.NumberStyles.Integer);
  }
  catch (Exception exception) 
  {
    MessageBox.Show(string.Format(
         "Invalid Input:   {0}\n Error Message:   {1}",
        _maxAltsInput.Text, exception.Message));
  }
  _recognizer.MaxAlternates = newMax;
  _maxAltsInput.Text = _recognizer.MaxAlternates.ToString();
}

See Also