Skip to content

fix(auto): preserve Paraformer token alignment across VAD segments - #3793

Open
phoenixray2000 wants to merge 1 commit into
modelscope:mainfrom
phoenixray2000:codex-fix-paraformer-token-alignment
Open

phoenixray2000 wants to merge 1 commit into
modelscope:mainfrom
phoenixray2000:codex-fix-paraformer-token-alignment

Conversation

@phoenixray2000

Copy link
Copy Markdown
Contributor

Summary

Paraformer returns space-delimited ASR tokens with matching timestamps. When adjacent Chinese VAD chunks are joined for punctuation, their boundary separator is removed: 客 户 + 需 求 becomes 客 户需 求. Sentence segmentation then pairs three text units with four unchanged timestamps and punctuation labels. On long recordings this shifts words into earlier sentence timestamps and speaker turns, and can leave punctuation-only sentences at the end.

Use the original ASR token text as the default input to timestamp segmentation. Keep the existing cleaned punctuation input and explicit words alignment paths for SenseVoice and other surface-text backends. The regression exercises both sentence timestamps and speaker punctuation segmentation, checking text, raw token text, timestamp intervals, and speaker labels.

Type of change

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

Validation

  • python -m compileall -q funasr examples tests
  • Both new regression subcases fail before the fix and pass afterward.
  • python -m pytest -q tests/test_punc_model_none.py tests/test_timestamp_tools.py tests/test_sensevoice_word_timestamps.py: 41 passed, 10 subtests passed, including the existing SenseVoice tag, word-alignment, English surface-text, and malformed-metadata cases.
  • Extended local suite covering the upstream NumPy CI selection plus submodel devices, clustering, Paraformer timestamp contracts, and WER helpers: 247 passed, 22 subtests passed, 1 deselected.
  • Black 24.4.0 with the repository's 100-character line length on the added test range; git diff --check.
  • Offline full-recording replay on Windows, Python 3.13.1, PyTorch 2.6.0+cu124, RTX 4070 SUPER: the same 616-second, 16 kHz mono Chinese recording, cached models, VAD settings, and hotwords. All 306 sentence texts and intervals match the pre-regression baseline; punctuation-only sentences fall from 27 to 0. Raw recognition text, token timestamps, and speaker cluster labels remain unchanged.
  • Docs/links and service deployment checks: not applicable to this Python alignment fix.

User impact

Restores the correspondence between recognized tokens, sentence timestamps, and speaker turns in multi-segment Paraformer transcription. Recognition accuracy and automatic speaker-count estimation remain unchanged.

Notes for reviewers

The local Windows run deselects TestLoadAudioBytes::test_decodes_no_id3_mp3_consistently_with_file_path: its still-open NamedTemporaryFile cannot be reopened by the audio decoder on Windows (Permission denied). The same failure was reproduced in a clean checkout of upstream fbbfe018; the test remains selected by the upstream Linux workflow. Optional CI dependencies were installed in a separate test environment, leaving the production environment intact.

The real recording is private. The checked-in reproduction is synthetic and requires no model weights. This PR contains only the alignment change and its regression test.

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