Add configurable WORKERS env var, default to 1 for GPU models

This commit is contained in:
russell@unturf.com 2026-01-26 13:16:44 -05:00
parent f299b43f1a
commit 0159f1f216
3 changed files with 14 additions and 1 deletions

View file

@ -77,6 +77,11 @@ owned_by = "UncloseAI"
- `sample.env` - Default environment (commit this) - `sample.env` - Default environment (commit this)
- `speech.env` - Runtime environment (created automatically by Makefile) - `speech.env` - Runtime environment (created automatically by Makefile)
**Key environment variables:**
- `WORKERS` - Number of uvicorn workers (default: 1 for GPU models like Qwen3-TTS)
- Use 1 for GPU-bound models to avoid VRAM duplication across workers
- Increase for CPU-bound models like Piper (e.g., WORKERS=4)
**Never view or log secrets** - source them and use them. **Never view or log secrets** - source them and use them.
### 4. Git Commit Guidelines ### 4. Git Commit Guidelines

View file

@ -1,5 +1,10 @@
TTS_HOME=voices TTS_HOME=voices
HF_HOME=voices HF_HOME=voices
# Worker processes (default: 1 for GPU models like Qwen3-TTS)
# Increase for CPU-bound models like Piper
WORKERS=1
#PRELOAD_MODEL=xtts #PRELOAD_MODEL=xtts
#PRELOAD_MODEL=xtts_v2.0.2 #PRELOAD_MODEL=xtts_v2.0.2
#EXTRA_ARGS=--log-level DEBUG --unload-timer 300 #EXTRA_ARGS=--log-level DEBUG --unload-timer 300

View file

@ -2,6 +2,9 @@
[ -f speech.env ] && . speech.env [ -f speech.env ] && . speech.env
# Default to 1 worker for GPU models (Qwen3-TTS)
WORKERS=${WORKERS:-1}
echo "First startup may download ~3GB of Qwen3-TTS model. Please wait." echo "First startup may download ~3GB of Qwen3-TTS model. Please wait."
# Pre-download Qwen3-TTS model (default engine) # Pre-download Qwen3-TTS model (default engine)
@ -11,4 +14,4 @@ python -c "from qwen_tts import Qwen3TTSModel; Qwen3TTSModel.from_pretrained('Qw
# bash download_voices_tts-1.sh # bash download_voices_tts-1.sh
# bash download_voices_tts-1-hd.sh $PRELOAD_MODEL # bash download_voices_tts-1-hd.sh $PRELOAD_MODEL
python speech.py ${PRELOAD_MODEL:+--preload $PRELOAD_MODEL} $EXTRA_ARGS $@ python speech.py --workers $WORKERS ${PRELOAD_MODEL:+--preload $PRELOAD_MODEL} $EXTRA_ARGS $@