Repository navigation
fix: scale Qwen3 forced aligner timestamps to the input sample rate (#1147) - #1148
Conversation
…xShug0#1147) parse_timestamps converted the model's millisecond predictions with assets_->config.sample_rate (16 kHz), while audio_frames, the clamp bounds and the JSON seconds all live in the uploaded audio's sample domain. Every span was compressed by model_rate/input_rate: on a 24 kHz take the last word landed at 27.89 s instead of 41.84 s, and clamp_timestamps_to_audio became a no-op because the compressed spans never reach audio_frames. Pass request.audio_input->sample_rate, the same rescale the MMS forced aligner and the ASR chunk merge already do. Adds a processor unit test pinning the sample-domain contract: 2000 ms is 48000 samples at 24 kHz, and the zero-length-span repair and clamp bounds use that rate. Verified on a 42 s 24 kHz take, mean sentence-boundary error against ground truth drops from 8557 ms to 30 ms, identical to the 16 kHz run.
|
@m-abs Thanks! Could you also update the Qwen3 ASR integration in this PR? The aligner now returns timestamps in the input sample rate, but ASR’s chunk merger still expects 16 kHz positions. Please convert timestamps back to 16 kHz in the ASR caller before merging. E.g., Main 162 words → PR: 111 words |
…xShug0#1147) The aligner now returns word spans in the uploaded audio's sample domain, but the Qwen3 ASR chunk loop still told append_chunk_word_timestamps() that the timestamps were at assets_->config.sample_rate (16 kHz). The merge then scaled every span by 24000/16000 before testing it against the keep window, so words past two thirds of each chunk fell outside it and were dropped. On a 42 s 24 kHz take with fixed 12 s chunks: 66 of 105 words survived, the last kept word ending at 28.0 s instead of 41.88 s. Passing audio.sample_rate keeps all 105, and the merged spans stay in the domain the JSON seconds are computed from, so no extra conversion is needed. Same correction in the outetts reference alignment, which handed the aligner the model rate instead of the audio rate; align_reference() no longer needs the aligner assets, so the unused parameter is dropped. Adds a chunking unit test: 24 kHz audio, four 12 s chunks, eight words, out-of-window spans dropped and in-window spans left untouched. Verified on the 42 s 24 kHz take: 105 words, last word at 41.88 s, matching the 16 kHz run.
Of course.
My bot disagreed with that solution and recommended this solution instead. This is its explanation: What was happening
The Qwen3 ASR loop passed
That explains both halves of your number: 162 → 111 words (only the first two thirds Why I didn't convert back to 16 kHz in the callerThree reasons, in order of weight:
Net change is four arguments — two merges and the two diagnostics calls — and the Verification42.06 s, 24 kHz WAV, Qwen3-ASR-1.7B q8_0 + ForcedAligner-0.6B f16,
Per-chunk Also touched
Test
|
Passing audio.sample_rate as both source and timestamp rate is the identity rescale, and the chunker already has an overload without rate arguments for spans that are already in the uploaded audio's sample domain. Behaviour is unchanged: 105 words on the 42 s 24 kHz take, last word at 41.88 s.
|
I pushed another small change.
|
|
@m-abs Thanks! Yes your solution is better. PR merged! |
Conflicts: the Qwen3 aligner's sample rate — upstream's fix (0xShug0#1148) is ours, so its two files are upstream's again; Qwen3-TTS's CustomVoice base assets kept beside upstream's talker backend; our CustomVoice clone test under upstream's ENGINE_BUILD_MODEL_TESTS (0xShug0#1182). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01PFJ4wux8AZfMeuyaL63Fca
parse_timestamps converted the model's millisecond predictions with
assets_->config.sample_rate (16 kHz), while audio_frames, the clamp
bounds and the JSON seconds all live in the uploaded audio's sample
domain.
Every span was compressed by model_rate/input_rate: on a 24 kHz take
the last word landed at 27.89 s instead of 41.84 s, and
clamp_timestamps_to_audio became a no-op because the compressed spans
never reach audio_frames.
Pass request.audio_input->sample_rate, the same rescale the MMS forced
aligner and the ASR chunk merge already do.
Adds a processor unit test pinning the sample-domain contract:
2000 ms is 48000 samples at 24 kHz, and the zero-length-span repair
and clamp bounds use that rate. Verified on a 42 s 24 kHz take, mean
sentence-boundary error against ground truth drops from 8557 ms to 30 ms,
identical to the 16 kHz run.
Fixes #1147