RecognizedPhrase Class

Represents detailed information about a candidate phrase found by a recognition engine as matching audio input.

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

<SerializableAttribute> _
Public Class RecognizedPhrase
Dim instance As RecognizedPhrase

/** @attribute SerializableAttribute() */ 
public class RecognizedPhrase
public class RecognizedPhrase
Not applicable.

Instances of RecognizedPhrase allow applications to obtain:

The RecognitionResult object -- which returns recognition engine matches for audio input as detailed information about the best candidate phrases matching phrase, and a list of all candidate matching phrases -- inherits from RecognizedPhrase. Access to the RecognizedPhrase based information about the best matching candidate phrase returned by a recognition engine operations is typically obtained by using the RecognitionResult members inherited from RecognizedPhrase.

The example below show a display function which provides information about a recognized phrase from an instance of RecognizedPhrase to a user interface, (as well as some information about the recognizer state).

In fact care is taken to check if the result argument provided is in fact a RecognitionResult object, which inherits from RecognizedPhrase; if that is the case the addition information on the RecognitionResult object is displayed.

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




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

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