Skip to content

fix(nano): avoid duplicate fs and preserve audio loading errors - #3778

Merged
LauraGPT merged 1 commit into
modelscope:mainfrom
txfs19260817:fix/nano-vad-sample-rate
Oct 18, 2026
Merged

LauraGPT merged 1 commit into
modelscope:mainfrom
txfs19260817:fix/nano-vad-sample-rate

Conversation

@txfs19260817

Copy link
Copy Markdown
Contributor

Summary

Type of change

  • Bug fix
  • Documentation
  • Example or demo
  • Runtime or deployment
  • Benchmark or evaluation
  • Model/training change

Validation

Tested on Windows with Python 3.12, using CPU tensors without model weights.

python -m pytest -q tests/test_fun_asr_nano_train_opts.py -k audio_loading
# 12 passed

python -m pytest -q tests/test_fun_asr_nano_train_opts.py -k "not torch_compile_wraps_cuda"
# 19 passed, 2 deselected

python -m compileall -q funasr examples tests
  • python -m compileall funasr examples tests
  • Docs or links checked
  • Runtime/deployment command tested

User impact

The initial error occurs because fs is supplied both explicitly and through kwargs:

[ERROR] Loading wav failed! funasr.utils.load_utils.load_audio_text_image_video() got multiple values for keyword argument 'fs'

Traceback (most recent call last):
  File ".../funasr/models/fun_asr_nano/model.py", line 551, in data_load_speech
    data_src = load_audio_text_image_video(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: funasr.utils.load_utils.load_audio_text_image_video() got multiple values for keyword argument 'fs'

The handler logs this exception but continues into feature extraction with data_src unassigned, producing a second error that masks the original cause:

Traceback (most recent call last):
  File ".../transcribe.py", line 225, in transcribe_file
    result = model.generate(**generate_kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../funasr/auto/auto_model.py", line 887, in generate
    results = self.inference_with_vad(
              ^^^^^^^^^^^^^^^^^^^^^^^
  File ".../funasr/auto/auto_model.py", line 1109, in inference_with_vad
    results = self.inference(
              ^^^^^^^^^^^^^^^
  File ".../funasr/auto/auto_model.py", line 957, in inference
    res = model.inference(**batch, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../funasr/models/fun_asr_nano/model.py", line 807, in inference
    return self.inference_llm(
           ^^^^^^^^^^^^^^^^^^^
  File ".../funasr/models/fun_asr_nano/model.py", line 967, in inference_llm
    inputs_embeds, contents, batch, source_ids, meta_data = self.inference_prepare(
                                                          ^^^^^^^^^^^^^^^^^^^^^^^
  File ".../funasr/models/fun_asr_nano/model.py", line 657, in inference_prepare
    output = self.data_load_speech(contents, tokenizer, frontend, meta_data=meta_data, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../funasr/models/fun_asr_nano/model.py", line 560, in data_load_speech
    data_src,
    ^^^^^^^^
UnboundLocalError: cannot access local variable 'data_src' where it is not associated with a value

This restores Nano audio loading through the VAD pipeline when fs is forwarded.

Notes for reviewers

The duplicate-keyword pattern dates to the initial Nano integration in 3e2c4c4 (December 2025). Explicit VAD-to-ASR fs forwarding in 9d61129 (October 2026) exposed it in the default VAD path

@LauraGPT LauraGPT left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Validated exact head 2117b036496e2d3dba2d1e8f8a0cd4d50eb2bfc5 against current main a4ab3b9d204f9c8b14cd6d6846abaa29ffff4f7a and synthetic merge be212d45ef3376e56efddd93b39dff3d8fc97988.

  • Recursive tree reconciliation found exactly the two Nano model copies and the submitted test file; changed blobs match the head and every other blob matches current main.
  • The drifted synthetic merge passes the submitted audio-loading cases (12/12), adjacent Nano option tests (19/19), and changed-file compileall.
  • On a real NVIDIA H100 with Torch 2.8.0+cu128/CUDA 12.8, the existing official zh.mp3 through the existing Fun-ASR-Nano-2512 + FSMN-VAD weights reproduces the masked UnboundLocalError(data_src) on current main. The exact synthetic merge returns one non-empty result. CUDA hooks observed 2,691 ASR and 12 VAD Linear calls; both model components and tensors were on cuda:0.

This is a focused one-recording, batch-size-1 regression and hardware validation, not a full model/language/accuracy suite. Within that scope, the fix preserves the forwarded sampling-rate contract and surfaces loader errors instead of continuing with an unbound value.

@LauraGPT
LauraGPT merged commit 879a219 into modelscope:main Oct 18, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants