gpt4 book ai didi

python - pocketsphinx python 给出错误的时间戳

转载 作者:太空宇宙 更新时间:2023-11-04 05:08:43 25 4
gpt4 key购买 nike

我正在使用 pocketsphinx 将音频转换为文本。它工作正常。现在我想获取每个单词的时间戳。这是我的代码:

import speech_recognition as sr

r = sr.Recognizer()
framerate = 100
with sr.AudioFile("1.wav") as source:

audio = r.record(source)

decoder = r.recognize_sphinx(audio, show_all=False)

print ([(seg.word, seg.start_frame/framerate)for seg in decoder.seg()])

根据他们的文档,默认帧率为 100。我得到了每个单词的开始时间。但是,这是不正确的。相差2秒,有时甚至超过3秒。

这是已知问题还是我遗漏了什么?

最佳答案

我在某处读到比率是 1/100 因此,在我的项目中,我不小心将 1/10 而不是 1/100 但结果实际上对我所做的来说还不错。我建议除以 0.10.01,看看能为您提供什么。

因此对于您的代码,只需尝试这些变量:

framerate = .1 

framerate = .01

关于python - pocketsphinx python 给出错误的时间戳,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43634243/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com