From 94ddbb0634022a6e5209b5221c057228ec3d1418 Mon Sep 17 00:00:00 2001 From: historia Date: Wed, 19 Aug 2026 05:13:36 -0400 Subject: feat: reuse one seed per run for consistent voice across chunks --- converter/chunking.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'converter/chunking.py') diff --git a/converter/chunking.py b/converter/chunking.py index 425765f..1ce69a3 100644 --- a/converter/chunking.py +++ b/converter/chunking.py @@ -8,11 +8,19 @@ from . import config logger = logging.getLogger(__name__) +# Hard ceiling on words per request, regardless of the configured chunk +# size. Both TTS servers silently truncate audio when a single generation +# exceeds its cap (~2.5 min for the faster backend's static KV cache, +# ~11 min for the Gradio demo) without reporting any error, so larger +# requests are always split client-side. Keep a margin below ~300 words +# to survive slow narration on the faster backend. +MAX_REQUEST_WORDS = 250 -def split_into_chunks(text: str, max_words: int = config.CHUNK_SIZE_WORDS) -> List[str]: + +def split_into_chunks(text: str, max_words: int = config.CHUNK_SIZE) -> List[str]: """Split text into chunks of at most ``max_words`` words. - ``max_words`` is clamped to ``config.MAX_REQUEST_WORDS``: requests + ``max_words`` is clamped to ``MAX_REQUEST_WORDS``: requests beyond that ceiling are silently truncated by the TTS servers (no error is reported), so chunks larger than the ceiling are never produced regardless of configuration. @@ -25,13 +33,13 @@ def split_into_chunks(text: str, max_words: int = config.CHUNK_SIZE_WORDS) -> Li at word boundaries as a last resort: individual tokens stay intact, but whitespace between them is normalized. """ - if max_words > config.MAX_REQUEST_WORDS: + if max_words > MAX_REQUEST_WORDS: logger.warning( "Requested chunk size of %d words exceeds the %d-word request ceiling; " "larger requests are silently truncated by the TTS servers, so the " - "size is clamped to %d words (see MAX_REQUEST_WORDS in converter/config.py)", - max_words, config.MAX_REQUEST_WORDS, config.MAX_REQUEST_WORDS) - max_words = config.MAX_REQUEST_WORDS + "size is clamped to %d words (see MAX_REQUEST_WORDS in converter/chunking.py)", + max_words, MAX_REQUEST_WORDS, MAX_REQUEST_WORDS) + max_words = MAX_REQUEST_WORDS if max_words < 1: max_words = 1 -- cgit v1.2.3