Skip to content

fix(cli): validate audio paths before loading models - #3939

Merged
LauraGPT merged 1 commit into
modelscope:mainfrom
thzon:fix/cli-validate-inputs-before-model
Nov 23, 2026
Merged

LauraGPT merged 1 commit into
modelscope:mainfrom
thzon:fix/cli-validate-inputs-before-model

Conversation

@thzon

@thzon thzon commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Summary

The CLI checks audio paths only after constructing AutoModel. A typo or directory argument can therefore trigger model initialization/downloads (or fail there) before the existing file-not-found error is reached.

Validate every audio path just after argument parsing. The same error message and exit status are retained. For a batch with a missing later file, fail before loading a model, transcribing earlier files or creating the output directory.

Found through source inspection; reproduced with the existing CLI test harness.

Type of change

  • Bug fix

Validation

  • python -m compileall -q funasr examples tests passes. Python emitted two existing invalid-escape SyntaxWarnings in the untouched examples/industrial_data_pretraining/fun_asr_nano/tools/format5res.py.
  • Docs or links checked: this moves the existing local-file validation and adds no options.
  • Runtime/deployment command tested.
# New cases on unchanged main 16174e20:
.venv/bin/python -m pytest tests/test_cli.py -k rejects_invalid_audio_paths -q
3 failed, 28 deselected
# Each failure shows AutoModel called before input rejection.

# With the fix:
.venv/bin/python -m pytest tests/test_cli.py -q
31 passed

# Installed CLI, with paths in a fresh temporary directory:
.venv/bin/funasr <temp>/missing.wav -o <temp>/transcripts
Error: file not found: <temp>/missing.wav
exit: 1
output_created: False

Validated on macOS, Python 3.12.13, PyTorch/torchaudio 2.10.0, CPU. Tests substitute the model loader; no model weights were downloaded and no inference-accuracy claim is made. The full repository suite, GPU and native Windows were not run. git diff --check passes.

User impact

CLI callers with missing files or directory arguments receive the existing actionable error without starting model work or partially processing a batch.

Notes for reviewers

The three parameterized cases cover a missing file, a directory and a missing later input; they also check that no model is constructed and no output directory appears.

Prepared and verified with Codex assistance. No independent human review is claimed.

@LauraGPT
LauraGPT merged commit ee46df3 into modelscope:main Nov 23, 2026
2 checks 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