如何使用 Sphinx 获取说出某个单词的时间戳

How to get the timestamp of when a word was said using Sphinx

我目前正在尝试获取使用 CMU Sphinx 检测到的单词的时间戳。

while ((result = recognizer.getResult()) != null) {
    for(WordResult w : result.getWords()){
        if(w.getWord() != Word.UNKNOWN){
            System.out.println(w.getTimeFrame().getStart());
            System.out.println(w.getWord() + " " + (w.getTimeFrame().getStart()/100)/60 + ":" + (w.getTimeFrame().getStart()/100 % 60));
        }
    }
}

是我目前拥有的代码。我认为这是因为 sample/framerate 不是上面逻辑中规定的每秒 100。

上面的代码显然不准确,因为整个文件只有 8 分钟长,而帧到时间计算器输出的时间戳超过一小时?

是否有任何方法可以从 WordResult 获取时间戳或找到 Sphinx 使用的 sample/frame 速率的方法?

我在网上四处寻找,但未能找到有关 TimeFrame 的任何文档 class。

正如 Nikolay Shmyrev 提到的 ,事实证明 TimeFrame 以毫秒为单位。我以前试过这个,但是因为有太多的结果我被抛弃了并且认为它是不正确的(我相信这只是因为模型需要调整)。

更正后的代码为:

System.out.println(w.getWord() + " " + (w.getTimeFrame().getStart()/1000)/60 + ":" + (w.getTimeFrame().getStart()/1000 % 60));