funasr_onnx streaming Paraformer returns inconsistent structures for empty results
维护者通常 1 天内回复
评估
调研方向
阅读 funasr_onnx/paraformer_online_bin.py,尤其是第 172-186 行附近将结果合并到 res = {} 的最终调用分块逻辑,并比较非最终 infer 路径和单 chunk 最终路径的空结果返回。该 issue 已经附带了使用静音输入和 chunk_size=[5, 10, 5] 的复现脚本;运行它以查看所有三种返回结构。注意,确切的返回契约尚未得到维护者确认(issue 中已提出),因此在提交带有回归测试的 PR 之前,先发评论确认目标结构([])是安全完成任务的路径。
由索引模型根据 Issue 内容生成。
描述
Description
funasr_onnx.paraformer_online_bin.Paraformer.__call__ returns different structures when there is no recognition result, depending on which path is taken:
| case | return value |
|---|---|
non-final call, no tokens (infer → asr_res = []) |
[] |
| final call handled as one chunk, decoder runs but text is empty | [{'preds': ['', []]}] |
final call split into two chunks, neither chunk has a result (lines 172-186 merge into res = {}) |
[{}] |
The last case means callers that read res[0]["preds"] after checking if res: hit KeyError: 'preds'; they have to check for an empty dict as well.
Reproduction
main (fbbfe01), iic/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-online v2.0.5 exported to ONNX, onnxruntime 1.20.1, CPU. Silence is enough to trigger it; chunk_size=[5, 10, 5] (the package default) is used, so this is unrelated to #3789.
import numpy as np
from funasr_onnx.paraformer_online_bin import Paraformer
model = Paraformer(model_dir, batch_size=1, chunk_size=[5, 10, 5], quantize=False)
for n_final in (9600, 16000):
cache = {}
r1 = model(np.zeros(9600, np.float32), param_dict={"cache": cache, "is_final": False})
r2 = model(np.zeros(n_final, np.float32), param_dict={"cache": cache, "is_final": True})
print(n_final, r1, r2)
Output:
9600 [] [{'preds': ['', []]}]
16000 [] [{}]
Question
What is the intended return value when there is no result? Returning [] in the split-final path, consistent with the non-final path, looks simplest, but I am not sure whether existing callers rely on [{}] or on [{'preds': ['', []]}]. If you confirm the expected contract, I can send a small PR with a regression test.
- 主要语言
- 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 小时 新手友好度 72/100
modelscope/FunASR#3801 · 3 条评论 ·
维护者通常 1 天内回复
-
难度 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 天内回复
查看 modelscope/FunASR 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 82/100
unionai-oss/pandera#2640 ·
维护者通常 2 天内回复
-
enhancement
难度 2/5 1-3 小时 新手友好度 72/100
JdeRobot/RoboticsInfrastructure#843 ·
维护者通常 1 天内回复
-
automated endpoint-dead needs-curation
难度 2/5 1-3 小时 新手友好度 62/100
almanac-data/climate-almanac#122 ·
维护者通常 1 天内回复
-
area:harness enhancement
难度 2/5 1-3 小时 新手友好度 75/100
evarness-ai/iris-harness#420 ·
-
难度 2/5 1-3 小时 新手友好度 85/100
suitenumerique/find#206 ·
维护者通常 2 天内回复