fix(kokoro): trim trailing silence and run-on noise on short prompt synthesis (#960)

This commit is contained in:
devangkantharia
2026-10-04 00:01:24 +00:00
committed by capy-ai-staging[bot]
parent b788dc383c
commit 615aeaeb35
3 changed files with 72 additions and 2 deletions
+1
View File
@@ -369,6 +369,7 @@ def _get_non_qwen_tts_configs() -> list[ModelConfig]:
engine="kokoro",
hf_repo_id="hexgrad/Kokoro-82M",
size_mb=350,
needs_trim=True,
languages=["en", "es", "fr", "hi", "it", "pt", "ja", "zh"],
),
]
+5 -2
View File
@@ -288,7 +288,10 @@ class KokoroTTSBackend:
# Return 1 second of silence as fallback
return np.zeros(KOKORO_SAMPLE_RATE, dtype=np.float32), KOKORO_SAMPLE_RATE
audio = np.concatenate(audio_chunks)
return audio.astype(np.float32), KOKORO_SAMPLE_RATE
audio = np.concatenate(audio_chunks).astype(np.float32)
from ..utils.audio import trim_tts_output
audio = trim_tts_output(audio, sample_rate=KOKORO_SAMPLE_RATE)
return audio, KOKORO_SAMPLE_RATE
return await asyncio.to_thread(_generate_sync)