Export (0) Print
Expand All

RecognizedPhrase Class

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

System.Object
  System.Speech.Recognition.RecognizedPhrase
    System.Speech.Recognition.RecognitionResult

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

[SerializableAttribute]
public class RecognizedPhrase

The RecognizedPhrase type exposes the following members.

  NameDescription
Public propertyConfidenceGets a value, assigned by the recognizer, that represents the likelihood that a RecognizedPhrase matches a given input.
Public propertyGrammarGets the Grammar that the speech recognizer used to return the RecognizedPhrase.
Public propertyHomophoneGroupIdGets the identifier for the homophone group for the phrase.
Public propertyHomophonesGets a collection of the recognition alternates that have the same pronunciation as this recognized phrase.
Public propertyReplacementWordUnitsGets information about the text that the speech recognizer changed as part of speech-to-text normalization.
Public propertySemanticsGets the semantic information that is associated with the recognized phrase.
Public propertyTextGets the normalized text generated by a speech recognizer from recognized input.
Public propertyWordsGets the words generated by a speech recognizer from recognized input.
Top

  NameDescription
Public methodConstructSmlFromSemanticsReturns a semantic markup language (SML) document for the semantic information in the RecognizedPhrase object.
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

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:");
  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);
  }
}

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

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