From dc7a8da2b1e52028fffcc5258fe0edd9b3f9eef2 Mon Sep 17 00:00:00 2001 From: Kedara Studios Date: Sun, 8 Feb 2026 19:16:34 +0100 Subject: [PATCH] fix: guard chunk trimming against zero blend_samples to prevent full truncation --- qwen_tts/core/models/modeling_qwen3_tts.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qwen_tts/core/models/modeling_qwen3_tts.py b/qwen_tts/core/models/modeling_qwen3_tts.py index cbd885a..5524cd3 100644 --- a/qwen_tts/core/models/modeling_qwen3_tts.py +++ b/qwen_tts/core/models/modeling_qwen3_tts.py @@ -2873,7 +2873,7 @@ class Qwen3TTSForConditionalGeneration(Qwen3TTSPreTrainedModel, GenerationMixin) # Trim END of chunk - this region will be replaced by next chunk's crossfade # Don't trim if chunk would become too small - if len(chunk) > blend_samples * 2: + if blend_samples > 0 and len(chunk) > blend_samples * 2: chunk = chunk[:-blend_samples] total_frames_emitted = len(codes_buffer) # Mark these frames as emitted @@ -3206,7 +3206,7 @@ class Qwen3TTSForConditionalGeneration(Qwen3TTSPreTrainedModel, GenerationMixin) decoded_tails[b] = chunk.copy() - if len(chunk) > blend_samples * 2: + if blend_samples > 0 and len(chunk) > blend_samples * 2: chunk = chunk[:-blend_samples] total_frames_emitted[b] = len(codes_buffers[b])