text stringclasses 10
values |
|---|
locust==2.37.2 |
fastapi==0.115.12 |
uvicorn[standard]==0.34.2 |
pydantic==2.11.3 |
numpy==1.26.4 |
soundfile==0.13.1 |
loguru==0.7.3 |
huggingface_hub==0.31.1 |
transformers==4.51.3 |
snac==1.2.1 |
YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
- 1) What users get
- 2) API Contract
- 3) Local run (before RunPod)
- 4) RunPod deployment steps
- 4B) RunPod without Docker (recommended if image build is flaky)
- 5) Load testing with Locust
- 6) Suggested test plan
- 7) Key files
- 8) Persistence checklist (before stopping pod)
- 9) Fast recovery setup (if some data is lost)
- 10) Optional backup command
snorTTS Hosting Pipeline (RunPod + Load Testing)
This folder contains a complete starter pipeline for hosting your TTS model with a simple API and testing parallel load.
1) What users get
- A single HTTP endpoint:
POST /v1/tts - Inputs:
utterance,language,user_id - Defaults are server-side tuned.
- Optional options endpoint for dropdowns:
GET /v1/options
2) API Contract
POST /v1/tts
Request body:
{
"utterance": "नमस्ते, आप कैसे हैं?",
"language": "hindi",
"user_id": "159"
}
Response modes:
response_mode=wav(default): returnsaudio/wavresponse_mode=json: returns base64 audio and metadata
Example:
curl -X POST "http://localhost:8000/v1/tts?response_mode=wav" \
-H "Content-Type: application/json" \
-d '{"utterance":"नमस्ते, आप कैसे हैं?","language":"hindi","user_id":"159"}' \
--output out.wav
GET /v1/options
Returns dropdown-compatible language/speaker map and defaults.
GET /health
Simple liveness check.
GET /ready
True once model and decoder are loaded.
3) Local run (before RunPod)
- Copy env:
cp .env.example .env
Set
HF_TOKENin.env.Build image:
docker build -t snortts-api:latest .
- Run container:
docker run --gpus all --env-file .env -p 8000:8000 snortts-api:latest
Optional (only if you want denoise enabled in production image):
# Add these to requirements and rebuild only if needed
pip install librosa==0.11.0 deepfilternet==0.5.6
- Smoke test:
curl http://localhost:8000/ready
4) RunPod deployment steps
- Push image to Docker Hub or GHCR.
- Create RunPod GPU Pod.
- Set container image to your pushed tag.
- Expose port
8000. - Add env vars from
.env.examplein RunPod UI. - Wait for startup, then test
/ready. - Test
/v1/tts.
4B) RunPod without Docker (recommended if image build is flaky)
You can deploy directly on a standard RunPod PyTorch pod without building an image.
- Create a GPU Pod from a PyTorch template (CUDA 12.1 compatible).
- Expose port
8000. - In Pod terminal, clone or upload this
tts_hostingfolder under/workspace/tts_hosting. - Create
.env(copy from.env.example) and set at leastHF_TOKEN. - Run setup once:
cd /workspace/tts_hosting
bash scripts/runpod_setup.sh
Note: setup installs torch and torchaudio from the CUDA 12.8 index for better compatibility with newer GPUs (including RTX 5090-class pods).
- Start API server:
cd /workspace/tts_hosting
bash scripts/runpod_start.sh
- Check readiness from your local machine:
curl http://<runpod-public-ip-or-url>:8000/ready
- Test generation:
curl -X POST "http://<runpod-public-ip-or-url>:8000/v1/tts?response_mode=wav" \
-H "Content-Type: application/json" \
-d '{"utterance":"नमस्ते, आप कैसे हैं?","language":"hindi","user_id":"159"}' \
--output out.wav
Tip: if the pod restarts often, keep code and venv under /workspace so it persists.
5) Load testing with Locust
From this directory:
pip install -r loadtest/requirements.txt
Then run:
locust -f loadtest/locustfile.py --host http://<your-runpod-url>
Or headless:
locust -f loadtest/locustfile.py --host http://<your-runpod-url> \
--users 10 --spawn-rate 2 --run-time 5m --headless
6) Suggested test plan
- Step 1: users 1, 2, 4, 8, 12
- Step 2: record p50, p95, p99 latency
- Step 3: record failure rate and GPU memory usage
- Step 4: choose safe
MAX_INFLIGHT_REQUESTS
7) Key files
app/main.py: FastAPI endpointsapp/runtime.py: model load and synthesis runtimeapp/speaker_map.py: language -> speaker IDs + default speedloadtest/locustfile.py: parallel load test scriptDockerfile: deployable image for RunPod
8) Persistence checklist (before stopping pod)
Use this quick checklist before stopping or recreating your pod:
- Confirm critical artifacts are pushed to Hugging Face:
- model repos
- adapter checkpoints
- sample audio datasets (if needed)
- Confirm runtime config is saved in project files:
.envapp/speaker_map.py
- Keep project under
/workspace/tts_hosting(network volume). - Do not rely on root filesystem paths outside
/workspacefor anything critical.
What usually persists:
/workspace/*- remote artifacts (Hugging Face, Git)
What may not persist across image/pod recreation:
- global apt installs
- global pip installs
- temporary files under root filesystem
9) Fast recovery setup (if some data is lost)
If your environment is partially reset but /workspace/tts_hosting still exists:
- Reinstall runtime deps and venv:
cd /workspace/tts_hosting
bash scripts/runpod_setup.sh
Restore
.envvalues (especiallyHF_TOKENandMODEL_NAME).Start service:
cd /workspace/tts_hosting
bash scripts/runpod_start.sh
- Verify locally:
curl http://127.0.0.1:8000/health
curl http://127.0.0.1:8000/ready
curl http://127.0.0.1:8000/v1/options
- Verify public URL (if HTTP port 8000 is exposed):
curl https://<pod-id>-8000.proxy.runpod.net/health
- Smoke-test synthesis:
curl -X POST "http://127.0.0.1:8000/v1/tts?response_mode=wav" \
-H "Content-Type: application/json" \
-d '{"utterance":"नमस्ते, आप कैसे हैं?","language":"hindi","user_id":"159"}' \
--output out.wav
10) Optional backup command
Create a lightweight backup archive (without virtualenv and cache):
cd /workspace
tar --exclude='.git' --exclude='.venv-tts' --exclude='__pycache__' \
-czf tts_hosting_backup_$(date +%F_%H%M).tar.gz tts_hosting
- Downloads last month
- 16