RecognizedPhrase Class


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Contains detailed information, generated by the speech recognizer, about the recognized input.

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


public class RecognizedPhrase


Gets a value, assigned by the recognizer, that represents the likelihood that a RecognizedPhrase matches a given input.


Gets the Grammar that the speech recognizer used to return the RecognizedPhrase.


Gets the identifier for the homophone group for the phrase.


Gets a collection of the recognition alternates that have the same pronunciation as this recognized phrase.


Gets information about the text that the speech recognizer changed as part of speech-to-text normalization.


Gets the semantic information that is associated with the recognized phrase.


Gets the normalized text generated by a speech recognizer from recognized input.


Gets the words generated by a speech recognizer from recognized input.


Returns a semantic markup language (SML) document for the semantic information in the RecognizedPhrase object.


Determines whether the specified object is equal to the current object.(Inherited from Object.)


Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)


Serves as the default hash function. (Inherited from Object.)


Gets the Type of the current instance.(Inherited from Object.)


Creates a shallow copy of the current Object.(Inherited from Object.)


Returns a string that represents the current object.(Inherited from Object.)

This class contains detailed information about words and phrases processed during speech recognition operations, including the following:

  • The Grammar property references the Grammar that the recognizer used to identify the input.

  • The Text property contains the normalized text for the phrase.

  • The Semantics property references the semantic information contained in the result. The semantic information is a dictionary of the key names and associated semantic data.

  • The Words property contains an ordered collection of RecognizedWordUnit objects that represent each recognized word in the input. Each word unit contains display format, lexical format, and pronunciation information for the corresponding word.

  • The ReplacementWordUnits property contains information about specialized word substitution.

  • The Homophones and HomophoneGroupId properties contain information about recognition alternates that have the same or similar pronunciation.

  • The value of the Confidence property indicates the degree of certainty, assigned by the speech recognizer, that a recognized phrase matches the input.

The speech recognizer returns recognition results in a RecognitionResult object, which inherits from RecognizedPhrase. The recognition result Alternates property contains an ordered collection of RecognizedPhrase objects, each of which is a possible match for the input to the recognizer.

The following example shows a handler for a SpeechRecognitionEngine.SpeechRecognized, SpeechRecognizer.SpeechRecognized, or Grammar.SpeechRecognized event and some of the information associated with the RecognitionResult object. The RecognitionResult class derives from the RecognizedPhrase class.

void SpeechRecognizedHandler(object sender, SpeechRecognizedEventArgs e)
  if (e.Result == null) return;

  // Add event handler code here.

  // The following code illustrates some of the information available
  // in the recognition result.
  Console.WriteLine("Recognition result summary:");
    "  Recognized phrase: {0}\n" + 
    "  Confidence score {1}\n" + 
    "  Grammar used: {2}\n", 
    e.Result.Text, e.Result.Confidence, e.Result.Grammar.Name);

  // Display the semantic values in the recognition result.
  Console.WriteLine("  Semantic results:");
  foreach (KeyValuePair<String, SemanticValue> child in e.Result.Semantics)
    Console.WriteLine("    The {0} city is {1}",
      child.Key, child.Value.Value ?? "null");

  // Display information about the words in the recognition result.
  Console.WriteLine("  Word summary: ");
  foreach (RecognizedWordUnit word in e.Result.Words)
      "    Lexical form ({1})" +
      " Pronunciation ({0})" +
      " Display form ({2})",
      word.Pronunciation, word.LexicalForm, word.DisplayAttributes);

  // Display information about the audio in the recognition result.
  Console.WriteLine("  Input audio summary:\n" +
    "    Candidate Phrase at:       {0} mSec\n" +
    "    Phrase Length:             {1} mSec\n" +
    "    Input State Time:          {2}\n" +
    "    Input Format:              {3}\n",

  // Display information about the alternate recognitions in the recognition result.
  Console.WriteLine("  Alternate phrase collection:");
  foreach (RecognizedPhrase phrase in e.Result.Alternates)
    Console.WriteLine("    Phrase: " + phrase.Text);
    Console.WriteLine("    Confidence score: " + phrase.Confidence);

.NET Framework
Available since 3.0

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

Return to top