RecognizedAudio.Duration 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取已识别音频的输入音频流的持续时间。
public:
property TimeSpan Duration { TimeSpan get(); };
public TimeSpan Duration { get; }
member this.Duration : TimeSpan
Public ReadOnly Property Duration As TimeSpan
属性值
可识别的音频开始的输入音频流中的持续时间。
示例
以下示例处理 SpeechRecognitionEngine.SpeechRecognized 或 SpeechRecognizer.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.
}