[Bugfix] Qwen3-TTS: trim reference audio in no_async_chunk voice clone (#4429)

Signed-off-by: Yueqian Lin <linyueqian@outlook.com>
This commit is contained in:
Yueqian Lin authored and GitHub committed 2026-06-15 18:00:03 +08:00
1 parent 3c62c53f59
commit a693ae67f6
2 files changed
+60 -1

No files matched your search

@@ -526,7 +526,19 @@ def talker2code2wav_full_payload(
audio = torch.cat([ref_code.to(audio.device), audio], dim=0)
codec_codes = audio.transpose(0, 1).to(device="cpu", dtype=torch.long).reshape(-1).contiguous()
meta: dict[str, Any] = {"finished": torch.tensor(True, dtype=torch.bool)}
# Co-locate the Code2Wav trim length with the ref prepend it describes.
# The orchestrator-side ``talker2code2wav_token_only`` channel derives
# left_context_size from the stage-0 RequestOutput ``multimodal_output``,
# which no longer carries the talker codec (ref reads as absent, so it
# emits left_context_size=0). This producer is the authoritative side
# that actually prepends ``ref_code``; if it does not also emit the
# matching ``left_context_size`` the consumer trims nothing and the
# reference audio leaks into the output (issue #4421). Mirrors the
# async-chunk path, which already ships left_context_size in-band.
if ref_code is not None and ref_frames > 0:
meta["left_context_size"] = ref_frames
return {
"codes": {"audio": codec_codes},
"meta": {"finished": torch.tensor(True, dtype=torch.bool)},
"meta": meta,
}