Zdieľať cez


RecognitionResult Class

Definition

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

public ref class RecognitionResult sealed : System::Speech::Recognition::RecognizedPhrase, System::Runtime::Serialization::ISerializable
public sealed class RecognitionResult : System.Speech.Recognition.RecognizedPhrase, System.Runtime.Serialization.ISerializable
[System.Serializable]
public sealed class RecognitionResult : System.Speech.Recognition.RecognizedPhrase, System.Runtime.Serialization.ISerializable
type RecognitionResult = class
    inherit RecognizedPhrase
    interface ISerializable
[<System.Serializable>]
type RecognitionResult = class
    inherit RecognizedPhrase
    interface ISerializable
Public NotInheritable Class RecognitionResult
Inherits RecognizedPhrase
Implements ISerializable
Inheritance
RecognitionResult
Attributes
Implements

Examples

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

Remarks

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.

Properties

Alternates

Gets the collection of possible matches for input to the speech recognizer.

Audio

Gets the audio associated with the recognition result.

Confidence

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

(Inherited from RecognizedPhrase)
Grammar

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

(Inherited from RecognizedPhrase)
HomophoneGroupId

Gets the identifier for the homophone group for the phrase.

(Inherited from RecognizedPhrase)
Homophones

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

(Inherited from RecognizedPhrase)
ReplacementWordUnits

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

(Inherited from RecognizedPhrase)
Semantics

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

(Inherited from RecognizedPhrase)
Text

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

(Inherited from RecognizedPhrase)
Words

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

(Inherited from RecognizedPhrase)

Methods

ConstructSmlFromSemantics()

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

(Inherited from RecognizedPhrase)
Equals(Object)

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

(Inherited from Object)
GetAudioForWordRange(RecognizedWordUnit, RecognizedWordUnit)

Gets a section of the audio that is associated with a specific range of words in the recognition result.

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)

Explicit Interface Implementations

ISerializable.GetObjectData(SerializationInfo, StreamingContext)

Populates a SerializationInfo instance with the data needed to serialize the target object.

Applies to

See also