Skip to content

fix(auto): preserve speaker dependency import failures - #3788

Open
monsterlag wants to merge 1 commit into
modelscope:mainfrom
monsterlag:fix/issue-2546-ccb9
Open

monsterlag wants to merge 1 commit into
modelscope:mainfrom
monsterlag:fix/issue-2546-ccb9

Conversation

@monsterlag

Copy link
Copy Markdown

Note

AI-generated, not reviewed by a human. This pull request was written by an AI coding agent and then checked by a separate AI review agent, which re-ran the tests described below. No human has reviewed the code. It is submitted by @monsterlag, who runs these agents. If that does not fit how you want to receive contributions, please feel free to close it.

Summary

  • Related to 创建模块对象使用的是spk_model="cam++"方式报错了,请大佬们帮忙看看,感谢 #2546: optional speaker-helper import failures were silently discarded, so requesting spk_model="cam++" could raise NameError: name 'ClusterBackend' is not defined instead of showing the dependency problem.
  • Preserve the original exception and raise an actionable, chained ImportError before constructing the speaker model. Check the resolved configuration so this works for both constructor arguments and config.yaml; ASR-only construction remains available.
  • Add fresh-process regressions for missing dependencies and initialization failures in both speaker import paths, plus successful backend construction, using local stand-in models without checkpoint downloads.

Type of change

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

Validation

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

Linux aarch64, Python 3.11.2, torch/torchaudio 2.10.0+cpu, NumPy 2.4.6. From the repository root with the development environment activated:

export PYTHONDONTWRITEBYTECODE=1 PYTHONPATH="$PWD"
export HF_HUB_OFFLINE=1 MODELSCOPE_OFFLINE=1
export OMP_NUM_THREADS=1 MKL_NUM_THREADS=1 NUMBA_NUM_THREADS=1
python -m pytest -p no:cacheprovider -q \
  tests/test_speaker_optional_dependency.py tests/test_top_level_import.py \
  tests/test_auto_model.py tests/test_submodel_device.py \
  tests/test_numpy_cluster_compatibility.py tests/test_cluster_backend.py \
  tests/test_campplus_utils.py tests/test_pcm_input_format.py \
  tests/test_punc_model_none.py -k 'not test_merge_thr_in_cb_model'
python -m compileall funasr examples tests
python -m black --check --line-length 100 tests/test_speaker_optional_dependency.py
git diff --check

Results: 179 passed, 1 deselected, 10 subtests passed. Compilation, test-file formatting and whitespace checks passed. The deselected existing test downloads pretrained models. The four config-supplied dependency-failure cases reproduce the NameError with the earlier constructor-only guard; all ten speaker regressions pass with the resolved-configuration check.

Validation limitations:

  • python -m pytest -p no:cacheprovider -q tests/test_auto_model_ncpu.py reports 4 failed, 3 passed on both this change and the untouched baseline. This ARM environment reports mixed BLAS thread counts; no BLAS code was changed.
  • Whole-file Black checking of auto_model.py fails on existing formatting. The changed import and guard blocks pass Black 24.4.0 at 100 columns separately; unrelated formatting is untouched.
  • No configured Python typecheck command was found. Existing NumPy and scikit-learn warnings remain.

User impact

Users requesting speaker diarization can see the original dependency failure rather than an undefined-name error, including when the speaker model is selected through configuration. Users not requesting speaker support are unaffected.

Notes for reviewers

This fixes diagnostic masking, not the unidentified dependency failure in the reporter's Windows installation. Tests exercise real configuration resolution and backend construction with local stand-in models; no Windows, GPU, real-checkpoint inference or diarization-quality validation is claimed. The original issue still needs reporter-environment confirmation.

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