Pocketsphinx 中的段时间戳

Ada*_*m_G 1 speech-recognition cmusphinx

我正在尝试使用 Pocketsphinx 提取每个段的开始和结束时间戳。下面的代码用于提取单词标记。如何访问时间戳?

我试过在这里查看文档http://cmusphinx.sourceforge.net/doc/pocketsphinx/index.html但找不到方法

#!/usr/bin/env python
import os

import sphinxbase as sb
import pocketsphinx as ps

MODELDIR = 'deps/pocketsphinx/model'
DATADIR = 'deps/pocketsphinx/test/data'

# Create a decoder with certain model
config = ps.Decoder.default_config()
config.set_string('-hmm', os.path.join(MODELDIR, 'en-us/en-us'))
config.set_string('-lm', os.path.join(MODELDIR, 'en-us/en-us.lm.bin'))
config.set_string('-dict', os.path.join(MODELDIR, 'en-us/cmudict-en-us.dict'))
decoder = ps.Decoder(config)

# Decode streaming data.
decoder.start_utt()
stream = open(os.path.join(DATADIR, 'goforward.raw'), 'rb')
while True:
    buf = stream.read(1024)
    if buf:
        decoder.process_raw(buf, False, False)
    else:
        break
decoder.end_utt()
stream.close()
print('Best hypothesis segments:', [seg.word for seg in decoder.seg()])
Run Code Online (Sandbox Code Playgroud)

Nik*_*rev 6

您可以在 ipython 中探索段

 print('Best hypothesis segments:', [(seg.word, seg.start_frame, seg.end_frame) for seg in decoder.seg()])
Run Code Online (Sandbox Code Playgroud)

帧大小为 1/100 秒。