funasr_onnx streaming Paraformer returns inconsistent structures for empty results

クローズ 初心者向け
#3,791 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@ychy7001 がすでに取り組んでいます。

2026年10月24日 から。

  • #3792 @ychy7001 による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
68/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python
領域
api

調査の方向性

funasr_onnx/paraformer_online_bin.py を読んでください。特に、結果が res = {} にマージされる 172-186 行目あたりの最終呼び出しのチャンク分割と、最終呼び出しでない infer パスと単一チャンクの最終パスの空結果の返り値を比較してください。issue には無音入力と chunk_size=[5, 10, 5] を使った再現スクリプトが既に含まれているので、実行して 3 つの返り値の形式をすべて確認してください。正確な返り値の契約はまだメンテナーによって確認されていないため(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時間
マージ済み PR(30日)
46

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

modelscope/FunASR のほかの issue

modelscope/FunASR の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。