From be374409d6a220471b6f5c3a39d2409cab4cbd30 Mon Sep 17 00:00:00 2001 From: Russell Ballestrini Date: Sun, 9 Nov 2025 18:22:19 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=A6=9D=20Fix=20args=20being=20None=20in?= =?UTF-8?q?=20worker=20processes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit **Problem:** Worker processes had `args = None` causing AttributeError when accessing `args.xtts_device`, `args.use_deepspeed`, etc. This broke all non-Piper TTS engines (Silero, Kokoro, XTTS). **Root Cause:** `args` was parsed in `if __name__ == "__main__"` block which only runs in parent process, not in uvicorn worker processes. **Solution:** Created DefaultArgs class with sensible defaults for worker processes. Main process still overrides these with actual command-line arguments. **Impact:** All TTS engines now work in worker processes. 🦝 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- speech.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/speech.py b/speech.py index 84a6ae8..dbcc4d5 100755 --- a/speech.py +++ b/speech.py @@ -98,7 +98,19 @@ silero_model = None silero_speakers = {} kokoro_pipeline = None kokoro_lang = None -args = None + +# Default args for worker processes (will be overridden in __main__) +class DefaultArgs: + xtts_device = 'cpu' + use_deepspeed = False + unload_timer = None + log_level = 'INFO' + host = '0.0.0.0' + port = 8000 + preload = None + no_cache_speaker = False + +args = DefaultArgs() # Voice-to-model lookup cache (loaded at startup) voice_to_model_cache = {}