RecognizedPhrase.Confidence Property

Returns the measure of certainty for a RecognizedPhrase returned by a recognition engine.

Namespace: System.Speech.Recognition
Assembly: System.Speech (in system.speech.dll)

public float Confidence { get; }
/** @property */
public float get_Confidence ()

public function get Confidence () : float

Not applicable.

Property Value

Returns a float a relative measure of the certainty of correct recognition for the phrase information returned in the current RecognizedPhrase instance.

The values returned by Confidence are purely relative and unique to each recognition engine.

There is no definition how confidence values between two different recognition engines compare.

The values are used to rank alternative candidate phrases returned by the Alternates property on RecognitionResult objects.

The example below show a display function which provides information about a recognized phrase from an instance of RecognizedPhrase to a user interface.

The use of Confidence in the code below is highlighted.

internal static void DisplayBasicPhraseInfo(Label label, RecognizedPhrase result, SpeechRecognizer recognizer) {
    if (result != null && label != null) {// Blank
        if (recognizer != null) { //Clear
            label.Text += String.Format(
                    "  Recognizer currently at:   {0} mSec\n" +
                    "  Audio Device currently at: {1} mSec\n",

        if (result != null) { //Clear
            RecognitionResult recResult = result as RecognitionResult;
            if (recResult != null) {
                RecognizedAudio resultRecognizedAudio = recResult.Audio;
                if (resultRecognizedAudio == null) {
                    label.Text += String.Format(
                        "  Emulated input\n");
                } else {
                    label.Text += String.Format(
                    "  Candidate Phrase at:       {0} mSec\n" +
                    "  Phrase Length:             {1} mSec\n" +
                    "  Input State Time:          {2}\n" +
                    "  Input Format:              {3}\n",

            label.Text += String.Format("  Confidence Level:          {0}\n", result.Confidence);
            if (result.Grammar != null) {
                label.Text += String.Format(
                                  "  Recognizing Grammar:       {0}\n" +
                                  "  Recognizing Rule:          {1}\n",
                                   ((result.Grammar.Name != null) ? (result.Grammar.Name) : "None"),
                                    ((result.Grammar.RuleName != null) ? (result.Grammar.RuleName) : "None"));

            if (result.ReplacementWordUnits.Count != 0) {
                label.Text += String.Format("  Replacement text:\n");
                foreach (ReplacementText rep in result.ReplacementWordUnits) {
                    label.Text += String.Format("      At index {0} for {1} words. Text: {2}\n",
                        rep.FirstWordIndex, rep.CountOfWords, rep.Text);



Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions