aboutsummaryrefslogtreecommitdiff
path: root/converter/config.py
diff options
context:
space:
mode:
authorhistoria <historiavg@proton.me>2026-08-19 04:45:28 -0400
committerhistoria <historiavg@proton.me>2026-08-19 04:45:28 -0400
commit9d4d7ef806c17387af9778725cd65a5e7ed10e39 (patch)
treef43ab42b6945f031b202f8c36994ba629b131228 /converter/config.py
parent87e5216cd287f411b2ffab04dbc435f48c1d4aae (diff)
downloadtts-audiobook-generator-9d4d7ef806c17387af9778725cd65a5e7ed10e39.tar.gz
fix: limit chunk size to 250
Diffstat (limited to 'converter/config.py')
-rw-r--r--converter/config.py29
1 files changed, 25 insertions, 4 deletions
diff --git a/converter/config.py b/converter/config.py
index eb01462..a19ac63 100644
--- a/converter/config.py
+++ b/converter/config.py
@@ -13,14 +13,35 @@ QWEN_API_URL = "http://127.0.0.1:7860" # CustomVoice demo
VOICE_CLONE_API_URL = "http://127.0.0.1:7861" # Base-model demo
FASTER_TTS_API_URL = "http://127.0.0.1:8000" # faster-qwen3-tts server
-# Words per TTS generation request. Each API call is ONE model generation:
-# long generations lose prosody and can degrade into garbled audio.
-CHUNK_SIZE_WORDS = 40
+# Words per TTS generation request. Each request is ONE model generation:
+# the voice is re-sampled per request (every chunk boundary can drift
+# slightly), while over-long generations lose prosody and can turn garbled.
+# ~250 words is ~1.5-2 minutes of speech: few voice boundaries while
+# staying inside both servers' generation caps.
+CHUNK_SIZE_WORDS = 250
+
+# Hard ceiling on words per request, regardless of CHUNK_SIZE_WORDS. 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
+
+# Duration sanity check: a response whose audio is far shorter than its
+# word count implies is treated as silently truncated, fails the request,
+# and goes through the normal retry logic. 150 wpm is a typical spoken
+# pace; the ratio is set low (0.5) so only gross truncation trips it.
+ESTIMATED_WORDS_PER_MINUTE = 150
+MIN_AUDIO_DURATION_RATIO = 0.5
+MIN_WORDS_FOR_DURATION_CHECK = 10
+
VOICE_CLONE_MAX_CHUNK_CHARS = 200 # Server-side re-chunking limit for clone requests
VOICE_CLONE_CHUNK_GAP = 0 # Pause (seconds) between server-side clone chunks
+
MIN_DELAY_BETWEEN_CHUNKS = 0 # Pause between API calls (rate-limit protection; local servers need none)
-API_TIMEOUT = 300 # Seconds before an API call times out
+API_TIMEOUT = 600 # Seconds before an API call times out (a ~250-word request can take minutes on the Gradio demo)
MAX_RETRIES = 3 # Attempts per chunk request
HEARTBEAT_INTERVAL_SECONDS = 30 # Print "still working" this often during a chunk