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
-
New Internship未關閉new_internship
難度 2/5 1-3 小時 新手友好度 68/100
-
get_graph warns that the oneway column is missing when no way has a oneway tag可能已有人在做 @HTenkanen 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 75/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
-
fix: security 🔐 style: article/section 📝 system: data-mgmt 🗃️ system: security 🔐 system: software 💻
難度 2/5 1-3 小時 新手友好度 65/100
uabrc/uabrc.github.io#1267 ·
-
Bot Type: Bug Type: Documentation
難度 2/5 1-3 小時 新手友好度 70/100
維護者通常 1 天內回覆