Skip to content

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

Open
txfs19260817 wants to merge 1 commit into
modelscope:mainfrom
txfs19260817:fix/nano-vad-sample-rate
Open

txfs19260817 wants to merge 1 commit into
modelscope:mainfrom
txfs19260817:fix/nano-vad-sample-rate

Conversation

@txfs19260817

Copy link
Copy Markdown

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

This branch has not been deployed

No deployments
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.

1 participant