RecognizedAudio Class
Represents audio input that is associated with a RecognitionResult.
Assembly: System.Speech (in System.Speech.dll)
The RecognizedAudio type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | 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. |
| Name | Description | |
|---|---|---|
![]() | Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) |
![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) |
![]() | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) |
![]() | GetRange | 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 | Writes the entire audio to a stream as raw data. |
![]() | WriteToWaveStream | 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:
Events:
SpeechRecognitionEngine::SpeechHypothesized and SpeechRecognizer::SpeechHypothesized
SpeechRecognitionEngine::SpeechRecognitionRejected and SpeechRecognizer::SpeechRecognitionRejected
SpeechRecognitionEngine::SpeechRecognized and SpeechRecognizer::SpeechRecognized
SpeechRecognitionEngine::EmulateRecognizeCompleted and SpeechRecognizer::EmulateRecognizeCompleted
Methods:
Important |
|---|
A recognition result produced by emulated speech recognition does not contain recognized audio. For such a recognition result, its Audio property returns nullptr 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. }
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.
