Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

RecognitionResult Class

Contains detailed information about input that was recognized by instances of SpeechRecognitionEngine or SpeechRecognizer.

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

Namespace:  System.Speech.Recognition
Assembly:  System.Speech (in System.Speech.dll)
[SerializableAttribute]
public sealed class RecognitionResult : RecognizedPhrase, 
	ISerializable

The RecognitionResult type exposes the following members.

  NameDescription
Public propertyAlternatesGets the collection of possible matches for input to the speech recognizer.
Public propertyAudioGets the audio associated with the recognition result.
Public propertyConfidenceGets a value, assigned by the recognizer, that represents the likelihood that a RecognizedPhrase matches a given input. (Inherited from RecognizedPhrase.)
Public propertyGrammarGets the Grammar that the speech recognizer used to return the RecognizedPhrase. (Inherited from RecognizedPhrase.)
Public propertyHomophoneGroupIdGets the identifier for the homophone group for the phrase. (Inherited from RecognizedPhrase.)
Public propertyHomophonesGets a collection of the recognition alternates that have the same pronunciation as this recognized phrase. (Inherited from RecognizedPhrase.)
Public propertyReplacementWordUnitsGets information about the text that the speech recognizer changed as part of speech-to-text normalization. (Inherited from RecognizedPhrase.)
Public propertySemanticsGets the semantic information that is associated with the recognized phrase. (Inherited from RecognizedPhrase.)
Public propertyTextGets the normalized text generated by a speech recognizer from recognized input. (Inherited from RecognizedPhrase.)
Public propertyWordsGets the words generated by a speech recognizer from recognized input. (Inherited from RecognizedPhrase.)
Top
  NameDescription
Public methodConstructSmlFromSemanticsReturns a semantic markup language (SML) document for the semantic information in the RecognizedPhrase object. (Inherited from RecognizedPhrase.)
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 methodGetAudioForWordRangeGets a section of the audio that is associated with a specific range of words in the recognition result.
Public methodGetHashCodeServes as a hash function for a particular type. (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
  NameDescription
Explicit interface implemetationPrivate methodISerializable.GetObjectDataPopulates a SerializationInfo instance with the data needed to serialize the target object.
Top

This class derives from RecognizedPhrase and provides detailed information about speech recognition, including the following:

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

  • The Text property contains the normalized text for the phrase. For more information about text normalization, see ReplacementText.

  • 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 Alternates property contains a collection of RecognizedPhrase objects that represent other candidate interpretations of the audio input. See Alternates for additional information.

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

Certain members of the SpeechRecognitionEngine, SpeechRecognizer, and Grammar classes can generate a RecognitionResult. For more information, see the following methods and events.

For more information about recognition events, see Using Speech Recognition Events.

The following example shows a handler for the SpeechRecognized event of a SpeechRecognitionEngine or SpeechRecognizer object, and some of the information about the associated RecognitionResult.


// Handle the SpeechRecognized event. 
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("Grammar({0}), {1}: {2}",
    e.Result.Grammar.Name, e.Result.Audio.Duration, e.Result.Text);

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

  // Display information about the words in the recognition result.
  foreach (RecognizedWordUnit word in e.Result.Words)
  {
    RecognizedAudio audio = e.Result.GetAudioForWordRange(word, word);
    Console.WriteLine(" {0,-10} {1,-10} {2,-10} {3} ({4})",
      word.Text, word.LexicalForm, word.Pronunciation,
      audio.Duration, word.DisplayAttributes);
  }

  // Display the recognition alternates for the result.
  foreach (RecognizedPhrase phrase in e.Result.Alternates)
  {
    Console.WriteLine(" alt({0}) {1}", phrase.Confidence, phrase.Text);
  }
}

.NET Framework

Supported in: 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

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.
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.