Skip to content

fix(auto-model): preserve the resampled rate for speaker inference - #3763

Open
hulkbig wants to merge 1 commit into
modelscope:mainfrom
hulkbig:codex/funasr-sample-rate-20261005
Open

hulkbig wants to merge 1 commit into
modelscope:mainfrom
hulkbig:codex/funasr-sample-rate-20261005

Conversation

@hulkbig

@hulkbig hulkbig commented Oct 5, 2026

Copy link
Copy Markdown

Summary

When generate(..., fs=8000) or fs=48000 runs with VAD and a speaker model, speaker inference receives the original source rate even though its input segments have already been resampled. CAMPPlus then resamples them a second time. A padded 1.5-second, 16 kHz segment contains 24,000 samples; passing fs=48000 changes it to 8,000 samples before feature extraction.

Pass the actual segment rate to speaker inference, matching the existing ASR boundary. Add regressions for arrays and explicit PCM, single and batched inputs, constructor/per-call precedence, conflicting speaker configuration, subsequent default calls, and caller-owned config preservation. This completes the speaker boundary left outside the VAD→ASR rate fix in #3751.

Related issue: #3762

Type of change

  • Bug fix

Validation

  • Same new regressions: unchanged main 66d7a4c264a5993a2a63ed00c1f402c296ee521a 21 failed / 8 passed; fixed source 29 passed.
  • Independent weights-free AutoModel.generate → CAMPPlus reproduction: 8,000 samples before / 24,000 samples after for a 48 kHz source.
  • python -m compileall funasr examples tests
  • Targeted Ruff checks (E9,F63,F7,F82) and git diff --check pass.
  • Full PCM/source-rate, audio-byte loading, submodel config, API signature and API-doc contract suites: 122 passed, 0 failed/skipped (includes the 29 new cases).
  • Broader 8-file check: 139 passed / 2 failed, with 26 additional unittest subtests passed. Both failures were independently reproduced on unchanged main in the same environment: a Linux-only CPU benchmark reads /proc/self/stat on macOS, and an existing frontend STFT path reports Window size mismatch: 512 != 400. No checks were skipped or dependency declarations changed to bypass them.
  • python -m build --no-isolation: sdist and wheel built successfully; the packaged auto_model.py in both archives matches the tested fixed file byte-for-byte.
  • First module/build-dependency attempts encountered local disk exhaustion. Those logs were retained and only affected checks were rerun after space recovery.

User impact

Preserves the waveform duration and content entering speaker feature extraction when callers provide non-16 kHz source audio, or when speaker config contains a conflicting source rate.

Notes for reviewers

Production change is one line. Tests use synthetic 440 Hz waves or silence and lightweight VAD/ASR/embedding stand-ins, with real input conversion/resampling, VAD slicing, speaker chunking, and CAMPPlus inference orchestration. The matrix captures the feature boundary; the constructor/config test also runs real speaker feature extraction. No weights are downloaded. Acoustic recognition quality, diarization quality, accelerator execution and arbitrary ASR frontend rates were not evaluated. Tested frontend rate is 16 kHz.

Prepared with AI assistance; all stated local results are from the current source checkout.

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