SpeechRecognitionEngine.MaxAlternates Property

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

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



Property Value

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.



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) {
string.Format("Invalid Input:   {0}\n Error Message:   {1}",
_maxAltsInput.Text, exception.Message));
    _recognizer.MaxAlternates = newMax;
    _maxAltsInput.Text = _recognizer.MaxAlternates.ToString();

Thread Safety

All public static (Shared in Visual Basic) members of this type are thread-safe. Instance members are not guaranteed to be thread-safe.


Development Platforms

Windows XP Professional with Service Pack 2 (SP2), Windows Server 2003, Windows Vista Ultimate Edition, Windows Vista Business Edition, Windows Vista Enterprise Edition

Target Platforms

See Also


SpeechRecognitionEngine Class
SpeechRecognitionEngine Members
Microsoft.Speech.Recognition Namespace
SpeechRecognitionEngine Class
RecognitionResult.Alternates Property