RecognitionResult.Audio Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets the audio associated with the recognition result.
public:
property System::Speech::Recognition::RecognizedAudio ^ Audio { System::Speech::Recognition::RecognizedAudio ^ get(); };
public System.Speech.Recognition.RecognizedAudio Audio { get; }
member this.Audio : System.Speech.Recognition.RecognizedAudio
Public ReadOnly Property Audio As RecognizedAudio
Property Value
The audio associated with the recognition result or null
if the recognizer generated the result from a call to the EmulateRecognize
or EmulateRecognizeAsync
methods of a SpeechRecognitionEngine or SpeechRecognizer instance.
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 information about the words in the recognition result.
foreach (RecognizedWordUnit word in e.Result.Words)
{
RecognizedAudio audio = e.Result.GetAudioForWordRange(word, word);
Console.WriteLine(" {0,-10} {1,-10} {2,-10} {3} ({4})",
word.Text, word.LexicalForm, word.Pronunciation,
audio.Duration, word.DisplayAttributes);
}
// Display the recognition alternates for the result.
foreach (RecognizedPhrase phrase in e.Result.Alternates)
{
Console.WriteLine(" alt({0}) {1}", phrase.Confidence, phrase.Text);
}
}
Remarks
To get a section of the audio that is associated with a specific range of words in the recognition result, use the GetAudioForWordRange method.
Applies to
See also
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기