以秒为单位获取已识别单词的位置和持续时间

时间:2014-02-08 01:59:51

标签: c# speech-recognition sapi

我试图在几秒钟内获得一个被识别的单词的位置和持续时间。我的方法

private void _recognizer_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
{
    if (e.Result != null)
    {
        foreach (RecognizedWordUnit word in e.Result.Words)
        {
            try
            {
                if (!word.Text.ToString().Contains("."))
                {
                    RecognizedAudio audio = e.Result.GetAudioForWordRange(word, word);
                    Console.WriteLine(" {0,-30} {1,-10} {2,-10}",
                      word.Text, audio.Duration.TotalSeconds, audio.AudioPosition.TotalSeconds);
                }
            }
            catch (Exception ff)
            {
                //Console.WriteLine(ff.Message);
            }
        }
    }
}

问题是我不知道如何从一开始就获得总秒数。因为输入是波形文件

_recognizer.SetInputToWaveFile(wavefile);

所以我需要这个:

totalseconds the word starts - duration of the word - word

0 个答案:

没有答案