RecognizedPhrase Class

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

Inheritance Hierarchy


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


<SerializableAttribute> _
Public Class RecognizedPhrase
Dim instance As RecognizedPhrase
public class RecognizedPhrase


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

Thread Safety

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

See Also


RecognizedPhrase Members

Microsoft.Speech.Recognition Namespace