funasr_onnx streaming Paraformer returns inconsistent structures for empty results

已關閉 適合新手
#3,791 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

@ychy7001 已經在處理了。

開始於 2026年10月24日。

  • #3792 來自 @ychy7001 —— 未關閉

評估

難度
2/5
預估耗時
1-3 小時
新手友好度
68/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
python
領域
api

研究方向

閱讀 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

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

modelscope/FunASR 的其他 Issue

查看 modelscope/FunASR 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。