RecognizedAudio.Duration 属性

定义

获取已识别音频的输入音频流的持续时间。

public:
 property TimeSpan Duration { TimeSpan get(); };
public TimeSpan Duration { get; }
member this.Duration : TimeSpan
Public ReadOnly Property Duration As TimeSpan

属性值

可识别的音频开始的输入音频流中的持续时间。

示例

以下示例处理 SpeechRecognitionEngine.SpeechRecognizedSpeechRecognizer.SpeechRecognized 事件,并将有关与识别结果关联的已识别音频的信息输出到控制台。

// 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.  
}  

适用于

另请参阅