共用方式為


RecognitionResult.Audio 屬性

定義

取得與便是結果相關聯的音訊。

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

屬性值

RecognizedAudio

與辨識結果相關聯的音訊,如果辨識器是透過呼叫 SpeechRecognitionEngineSpeechRecognizer 執行個體的 nullEmulateRecognize 方法來產生結果則為 EmulateRecognizeAsync

範例

下列範例顯示 SpeechRecognized 事件的處理常式,以及相關聯的部分資訊 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);  
  }  
}  

備註

若要取得與辨識結果中特定文字範圍相關聯的音訊區段,請使用 GetAudioForWordRange 方法。

適用於

另請參閱