sentence_info text drifts away from its timestamps/speakers: Chinese VAD chunks are joined without a space before timestamp_sentence splits on spaces
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 72/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
调研方向
从 funasr/auto/auto_model.py 中的 _join_vad_texts 和 funasr/utils/timestamp_tools.py 中的 timestamp_sentence 开始;追踪 inference_with_vad 如何向句子分割器提供文本和时间戳。使用 issue 中的两个中文片段复现问题,并检查每个句子的文本是否仍与其时间戳和说话人对应,标点是否仍然正确。
由索引模型根据 Issue 内容生成。
描述
Summary
With vad_model + punc_model (+ spk_model), the text of each sentence_info entry is shifted relative to its start/end/timestamp/spk. The shift grows by one unit at every VAD chunk boundary where two Chinese chunks meet, so on long audio the sentence text ends up far ahead of the time range and speaker it is attached to. The top-level text (punctuated) is correct; only sentence_info[*].text is wrong.
Version
- funasr 1.4.16 (same code in 1.4.17 and current main)
AutoModel(model="paraformer-zh", vad_model="fsmn-vad", punc_model="ct-punc", spk_model="cam++"), Python 3.12, macOS, CPU
Minimal reproduction (no audio needed)
from funasr.auto.auto_model import _join_vad_texts
from funasr.utils.timestamp_tools import timestamp_sentence
chunks = ["今 天 天 气 很 好", "我 们 去 公 园 吧"] # two VAD chunks
punc_input_text = _join_vad_texts(chunks)
print(repr(punc_input_text)) # '今 天 天 气 很 好我 们 去 公 园 吧' ("好我" fused)
timestamps = [[i * 200, i * 200 + 200] for i in range(12)]
punc = [1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 3] # "," after 好, "。" after 吧
print(len(punc_input_text.split()), "text units vs", len(timestamps), "timestamps")
for s in timestamp_sentence(punc, timestamps, punc_input_text):
print(s["text"], s["start"], s["end"])
Output:
11 text units vs 12 timestamps
今天天气很好我, 0 1200
们去公园吧。 1200 2400
Expected 今天天气很好, / 我们去公园吧。.
Real-world impact
On a 19.5-minute Mandarin recording: 5299 timestamps and 5299 punctuation ids, but punc_input_text.split() yields only 5082 units (217 fused boundaries). Sentence text drifts up to ~217 characters (~50 s of speech) ahead of its timestamps, so:
- sentences are cut 1–N characters off (e.g.
然,/后用于…) - since speakers are distributed by time, text is attributed to the wrong speaker, often switching speaker mid-sentence
Cause
In AutoModel.inference_with_vad, punc_input_text = _join_vad_texts(...) intentionally joins Chinese chunks without a space (fine for the punctuation model, whose tokenizer splits CJK into characters, so punc_array length still matches). But the same string is then used as timestamp_text, and timestamp_sentence pairs units with timestamps via text_postprocessed.split(). The fused boundary units shift every following unit. The existing check punc_length != len(sentence_timestamps) doesn't catch it because the number of text units is never compared.
Suggested fix
Use a space-joined version of the chunk texts for timestamp_text (or have timestamp_sentence consume one unit per timestamp), and/or assert that the number of text units equals the number of timestamps.
Workaround we use for now: call generate(..., return_raw_text=True) and rebuild each sentence's text by taking len(sentence["timestamp"]) units from result["raw_text"].split() in order, keeping the trailing punctuation from sentence["text"]. With that, sentence boundaries and speaker turns line up correctly.
- 主要语言
- Python
- 星标
- 20.9k
- 派生
- 2.1k
- 平均合并
- 1 天 3 小时
- 30 天内合并 PR
- 46
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
modelscope/FunASR 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 76/100
modelscope/FunASR#3796 · 3 条评论 ·
维护者通常 1 天内回复
-
`SentencepiecesTokenizer.ids2tokens` ignores `token_list` - root cause of the paraformer-en gibberish in #3040可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
modelscope/FunASR#3780 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
modelscope/FunASR#3762 · 1 条评论 ·
维护者通常 1 天内回复
-
Bug: blank lines in wav.scp / jsonl file lists crash prepare_data_iterator (IndexError / JSONDecodeError)可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭needs feedback
难度 2/5 1-3 小时 新手友好度 85/100
modelscope/FunASR#3757 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 88/100
modelscope/FunASR#3730 · 2 条评论 ·
维护者通常 1 天内回复
查看 modelscope/FunASR 的全部 Issue
相似的 Issue
-
area:cli bug difficulty:1
难度 1/5 1-3 小时 新手友好度 87/100
MakazhanAlpamys/Soup#2491 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
microsoft/onnxscript#3155 ·
维护者通常 4 天内回复
-
IFEval nth-paragraph checker reads the wrong paragraph when a blank separator is present可能已有人在做 @chetana1410 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 82/100
EleutherAI/lm-evaluation-harness#4530 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 84/100
维护者通常 1 天内回复
-
sv_SE vat_id() has 14 digits: the "16" organisation number prefix is kept可能已有人在做 @kevin9327 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 19 天内回复