Skip to content

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

Merged
LauraGPT merged 1 commit into
modelscope:mainfrom
hulkbig:codex/funasr-sample-rate-20261005
Oct 8, 2026
Merged

LauraGPT merged 1 commit into
modelscope:mainfrom
hulkbig:codex/funasr-sample-rate-20261005

Conversation

@hulkbig

@hulkbig hulkbig commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

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.

@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.

Reviewed 74bb9b50e26ad81667f04b098f8d4a40aef32bb6. No blocking correctness issue found in the changed speaker-inference boundary.

I independently reproduced the new regression matrix against the current main implementation (66d7a4c): 21 failed / 8 passed. With the PR implementation, the PCM/input conversion, byte loading and submodel configuration checks passed 106 tests, including all 29 new speaker cases; the API signature checks passed another 6 tests. Four unittest subtests also passed. The initial signature setup errors were missing files in my review export; restoring the exact generator and CSS from the reviewed commit resolved them without changing the PR or tests.

The one-line override uses the rate of the waveform already loaded for VAD/ASR, and matches the existing ASR call. The tests exercise real conversion, resampling and CAMPPlus preprocessing orchestration, including constructor/per-call precedence and preservation of caller-owned configuration. This validates the 16 kHz segment path with non-16 kHz source input. It does not measure acoustic recognition or diarization quality, accelerator execution, or arbitrary frontend rates.

Validation ran on Linux, Python 3.12, NumPy 1.26 and CPU Torch, with model downloads disabled. This is source-level review evidence; no package release or full inference evaluation was performed.

@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.

The resampled speaker boundary and independent regression results are covered in review #5451919683. After approving the held fork workflows, MOSS, KWS and both NumPy compatibility lanes have completed successfully.

@LauraGPT
LauraGPT merged commit d98f6ee into modelscope:main Oct 8, 2026
4 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