RecognizedAudio RecognizedAudio RecognizedAudio RecognizedAudio Class


Represents audio input that is associated with a RecognitionResult.

public ref class RecognizedAudio
public class RecognizedAudio
type RecognizedAudio = class
Public Class RecognizedAudio


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.  


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.


AudioPosition AudioPosition AudioPosition AudioPosition

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

Duration Duration Duration Duration

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

Format Format Format Format

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

StartTime StartTime StartTime StartTime

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


Equals(Object) Equals(Object) Equals(Object) Equals(Object)

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

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetRange(TimeSpan, TimeSpan) GetRange(TimeSpan, TimeSpan) GetRange(TimeSpan, TimeSpan) GetRange(TimeSpan, TimeSpan)

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

GetType() GetType() GetType() GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

Returns a string that represents the current object.

(Inherited from Object)
WriteToAudioStream(Stream) WriteToAudioStream(Stream) WriteToAudioStream(Stream) WriteToAudioStream(Stream)

Writes the entire audio to a stream as raw data.

WriteToWaveStream(Stream) WriteToWaveStream(Stream) WriteToWaveStream(Stream) WriteToWaveStream(Stream)

Writes audio to a stream in Wave format.

Applies to

See also