This topic has not yet been rated - Rate this topic

SpeechRecognitionEngine.MaxAlternates Property

Gets and sets the maximum number of candidate results an instance of SpeechRecognitionEngine is to return.

Namespace:  System.Speech.Recognition
Assembly:  System.Speech (in System.Speech.dll)
public int MaxAlternates { get; set; }

Property Value

Type: System.Int32
Gets and sets an int specifying the maximum number of candidate phrases will be returned by a recognition engine.

Applications obtain a list of all possible results as a collection of RecognizedPhrase instances through the Alternates property on RecognitionResult.

Alternates

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

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();
}

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ