Skip to content

funasr_onnx: Fsmn_vad_online raises UnboundLocalError when a chunk produces no feature frames (e.g. 10-30 ms chunks) #3821

Closed

Description

@tanishqbaweja

Fsmn_vad_online.__call__ (runtime/python/onnxruntime/funasr_onnx/vad_bin.py) assigns vad_scorer only inside if feats.size != 0:, but always runs param_dict.update({"frontend": frontend, "vad_scorer": vad_scorer}) afterwards. When WavFrontendOnline.extract_fbank returns no feature frames for a call, it raises:

UnboundLocalError: cannot access local variable 'vad_scorer' where it is not associated with a value

This happens on the first call when the first chunk is shorter than 720 samples (45 ms at 16 kHz), so streaming 10, 20 or 30 ms chunks fails at once. It also happens on a later call whose chunk completes no new feature frame, for example a 40-sample packet after 100 ms chunks. The README's 100 ms chunks are not affected, and the failing path never reaches the ONNX session.

Repro: run the streaming example for Fsmn_vad_online with step = 320 (20 ms) instead of 1600. The first model(audio_in=..., param_dict=param_dict) call raises the error above.

It came in with #2528, which moved the scorer into param_dict; before that, a call without features returned [].

Activity

  1. LauraGPT commented on Nov 2, 2026

    @LauraGPT
    Collaborator

    The #3822 fix is now published in standalone funasr-onnx 0.4.4 (2026-11-02). Upgrading only the root funasr package does not replace this wrapper:

    python -m pip install --upgrade funasr-onnx==0.4.4

    For Fsmn_vad_online, a call that produces no feature frames now keeps its frontend/scorer state and returns [] instead of raising UnboundLocalError. The fix also covers short first-and-final streams and empty final flushes after partial chunks, resetting terminal state so a reused param_dict does not carry the previous stream's cache into the next one.

    The release passed exact-head/main CI; official PyPI wheel/sdist downloads match the tested GitHub assets. Runtime evidence includes byte-matched CPU and real L20Z synthetic boundary tests, not pretrained VAD accuracy or a full-suite claim. This addresses the VAD wrapper; the separately noted streaming Paraformer short-first-chunk handling is not part of #3822.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions