Del via


RecognizedPhrase Class

Definition

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

public ref class RecognizedPhrase
public class RecognizedPhrase
[System.Serializable]
public class RecognizedPhrase
type RecognizedPhrase = class
[<System.Serializable>]
type RecognizedPhrase = class
Public Class RecognizedPhrase
Inheritance
RecognizedPhrase
Derived
Attributes

Examples

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:");  
  Console.WriteLine(  
    "  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");  
  }  
  Console.WriteLine();  

  // Display information about the words in the recognition result.  
  Console.WriteLine("  Word summary: ");  
  foreach (RecognizedWordUnit word in e.Result.Words)  
  {  
    Console.WriteLine(  
      "    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",  
    e.Result.Audio.AudioPosition,  
    e.Result.Audio.Duration,  
    e.Result.Audio.StartTime,  
    e.Result.Audio.Format.EncodingFormat);  

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

Remarks

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.

Properties

Confidence

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

Grammar

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

HomophoneGroupId

Gets the identifier for the homophone group for the phrase.

Homophones

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

ReplacementWordUnits

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

Semantics

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

Text

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

Words

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

Methods

ConstructSmlFromSemantics()

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

Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ToString()

Returns a string that represents the current object.

(Inherited from Object)

Applies to

See also