"""Configuration for the audiobook converter. Edit these values to change voices and processing behavior. Everything else (voice mode names, languages, speaker names, model ids, folders, file formats) is fixed in the code where it is used. """ # Server endpoints. Voice clone needs the Base-model demo, which is a # separate server from the CustomVoice demo (that one only exposes # /run_instruct); the faster backend is the OpenAI-compatible server from # the faster-qwen3-tts repository. 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 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 = 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 LANGUAGE = "English" SEED = -1 CUSTOM_VOICE_SPEAKER = "Vivian" CUSTOM_VOICE_INSTRUCT = "Speak naturally and clearly, as if reading a dramatic book to an adult audience." VOICE_CLONE_USE_XVECTOR_ONLY = False # Must match a key in the faster server's voices.json ("default" when the # server was launched with --ref-audio). The server silently falls back to # its first voice for unknown names. FASTER_TTS_VOICE = "default" AUDIO_FORMAT = "m4b" # Default output container AUDIO_BITRATE = "128k"