RecognizedAudio Class

RecognizedAudio Class


Represents audio input that is associated with a RecognitionResult.

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


public class RecognizedAudio


Gets the location in the input audio stream for the start of the recognized audio.


Gets the duration of the input audio stream for the recognized audio.


Gets the format of the audio processed by a recognition engine.


Gets the system time at the start of the recognition operation.


Determines whether the specified object is equal to the current object.(Inherited from Object.)


Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)


Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetRange(TimeSpan, TimeSpan)

Selects and returns a section of the current recognized audio as binary data.


Gets the Type of the current instance.(Inherited from Object.)


Creates a shallow copy of the current Object.(Inherited from Object.)


Returns a string that represents the current object.(Inherited from Object.)


Writes the entire audio to a stream as raw data.


Writes audio to a stream in Wave format.

A speech recognizer generates information about the audio input as part of the recognition operation. To access the recognized audio, use the Audio property or the GetAudioForWordRange method of the RecognitionResult.

A recognition result can be produced by the following events and methods of the SpeechRecognizer and SpeechRecognitionEngine classes:


A recognition result produced by emulated speech recognition does not contain recognized audio. For such a recognition result, its Audio property returns null and its GetAudioForWordRange method throws an exception. For more information about emulated speech recognition, see the EmulateRecognize and EmulateRecognizeAsync methods of the SpeechRecognizer and SpeechRecognitionEngine classes.

The following example handles the SpeechRecognitionEngine.SpeechRecognized, SpeechRecognizer.SpeechRecognized, or Grammar.SpeechRecognized event and outputs to the console information about the recognized audio that is associated with the recognition result.

// Handle the SpeechRecognized event. 
void SpeechRecognizedHandler(object sender, SpeechRecognizedEventArgs e)
  if (e.Result == null) return;

  RecognitionResult result = e.Result;

  Console.WriteLine("Grammar({0}): {1}",
    result.Grammar.Name, result.Text);

  if (e.Result.Audio != null)
    RecognizedAudio audio = e.Result.Audio;

    Console.WriteLine("   start time: {0}", audio.StartTime);
    Console.WriteLine("   encoding format: {0}", audio.Format.EncodingFormat);
    Console.WriteLine("   position: {0}, duration: {1}",
      audio.AudioPosition, audio.Duration);

  // Add event handler code here.

.NET Framework
Available since 3.0

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

Return to top
© 2015 Microsoft