Note

Please see Azure Cognitive Services for Speech documentation for the latest supported speech solutions.

RecognizedAudio Class

Represents audio input that is associated with a RecognitionResult.

Inheritance Hierarchy

System.Object
  Microsoft.Speech.Recognition.RecognizedAudio

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

Syntax

'Declaration
<SerializableAttribute> _
Public Class RecognizedAudio
'Usage
Dim instance As RecognizedAudio
[SerializableAttribute]
public class RecognizedAudio

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.

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

Important

A recognition result produced by emulated speech recognition does not contain recognized audio. For such a recognition result, its Audio property returns a null reference (Nothing in Visual Basic). For more information about emulated speech recognition, see the EmulateRecognize() and EmulateRecognizeAsync() methods of the SpeechRecognitionEngine class.

Examples

In the example below, an application first determines whether recognition operation has been emulated by determining if the RecognizedAudio object received is not a null reference (Nothing in Visual Basic). If the RecognizedAudio object is not a null reference (Nothing in Visual Basic), information about the recognized audio is written to a Label for display.

if (result != null) 
{ // Clear
  RecognizedAudio resultRecognizedAudio = result.Audio;
  if (resultRecognizedAudio == null) 
  {
    label.Text += String.Format(
            "  Emulated input\n");
  } else 
  {
    label.Text += String.Format(
        "  Candidate Phrase at:       {0} mSec\n" +
        "  Phrase Length:             {1} mSec\n" +
        "  Input State Time:          {2}\n" +
        "  Input Format:              {3}\n",
        resultRecognizedAudio.AudioPosition.TotalMilliseconds,
        resultRecognizedAudio.Duration.TotalMilliseconds,
        resultRecognizedAudio.StartTime.ToShortTimeString(),
        resultRecognizedAudio.Format.EncodingFormat.ToString());
  }

Thread Safety

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

See Also

Reference

RecognizedAudio Members

Microsoft.Speech.Recognition Namespace

SpeechRecognitionEngine

RecognitionEventArgs

SpeechHypothesizedEventArgs

SpeechRecognizedEventArgs

SpeechRecognitionRejectedEventArgs

SpeechHypothesized

SpeechRecognized

SpeechRecognitionRejected

SpeechHypothesized

SpeechRecognized

SpeechRecognitionRejected

SpeechRecognized

EmulateRecognize

EmulateRecognizeAsync