Share via


Note

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

RecognitionResult.Audio Property

Gets the audio associated with the recognition result.

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

Syntax

'Declaration
Public ReadOnly Property Audio As RecognizedAudio
    Get
'Usage
Dim instance As RecognitionResult
Dim value As RecognizedAudio

value = instance.Audio
public RecognizedAudio Audio { get; }

Property Value

Type: Microsoft.Speech.Recognition.RecognizedAudio
The audio associated with the recognition result or a null reference (Nothing in Visual Basic) if the recognizer generated the result from a call to the EmulateRecognize() or EmulateRecognizeAsync() methods.

Examples

The following example shows a handler for the SpeechRecognized event and some of the information about the associated RecognitionResult.

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

  // Add event handler code here.

  // The following code illustrates some of the information available
  // in the recognition result.
      Console.WriteLine("Grammar({0}): {1}", e.Result.Grammar.Name, e.Result.Text);
      Console.WriteLine("Audio for result:");
      Console.WriteLine("  Start time: "+ e.Result.Audio.StartTime);
      Console.WriteLine("  Duration: " + e.Result.Audio.Duration);
      Console.WriteLine("  Format: " + e.Result.Audio.Format.EncodingFormat);

  // Display the semantic values in the recognition result.
  foreach (KeyValuePair<String, SemanticValue> child in e.Result.Semantics)
  {
    Console.WriteLine(" {0} key: {1}",
      child.Key, child.Value.Value ?? "null");
  }
  Console.WriteLine();

  // Display the recognition alternates for the result.
  foreach (RecognizedPhrase phrase in e.Result.Alternates)
  {
    Console.WriteLine(" alt({0}) {1}", phrase.Confidence, phrase.Text);
  }
}

See Also

Reference

RecognitionResult Class

RecognitionResult Members

Microsoft.Speech.Recognition Namespace

RecognitionResult

RecognizedAudio