Jaa


RecognizedAudio Class

Definition

Represents audio input that is associated with a RecognitionResult.

public ref class RecognizedAudio
public class RecognizedAudio
[System.Serializable]
public class RecognizedAudio
type RecognizedAudio = class
[<System.Serializable>]
type RecognizedAudio = class
Public Class RecognizedAudio
Inheritance
RecognizedAudio
Attributes

Examples

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.  
}  

Remarks

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:

Important

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.

Properties

AudioPosition

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

Duration

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

Format

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

StartTime

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

Methods

Equals(Object)

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

(Inherited from Object)
GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetRange(TimeSpan, TimeSpan)

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

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)
WriteToAudioStream(Stream)

Writes the entire audio to a stream as raw data.

WriteToWaveStream(Stream)

Writes audio to a stream in Wave format.

Applies to

See also