--- title: IndicF5 API emoji: 🎙️ colorFrom: blue colorTo: indigo sdk: gradio sdk_version: "4.44.0" app_file: app.py pinned: false --- # IndicF5 TTS API Space A Gradio Space wrapping [ai4bharat/IndicF5](https://huggingface.co/ai4bharat/IndicF5) with a FastAPI `/synthesize` endpoint for CodeVoice. **Free tier — Gradio SDK, 2 vCPU / 16 GB RAM, no Docker required.** ## API Endpoints | Method | Path | Description | |--------|------|-------------| | GET | `/health` | Liveness check | | POST | `/synthesize` | Zero-shot TTS synthesis | ### POST /synthesize | Field | Type | Description | |-------|------|-------------| | `text` | string | Text to synthesize | | `ref_text` | string | Transcript of the reference audio | | `language` | string | e.g. `malayalam`, `hindi`, `tamil`, `english` | | `ref_audio` | file | Reference WAV (5–10 seconds) | Returns `audio/wav` bytes. ## Supported Languages Malayalam, Hindi, Tamil, Telugu, Kannada, Bengali, Gujarati, Marathi, Punjabi, Odia, Assamese, Urdu, English --- ## Setup Guide ### Step 1 — Create the Space 1. Go to [huggingface.co/new-space](https://huggingface.co/new-space) 2. Space name: `indicf5-api` 3. Select **Gradio** as the SDK (free, no Docker needed) 4. Hardware: **CPU basic** (free — 2 vCPU / 16 GB RAM) 5. Visibility: **Public** ### Step 2 — Push files Clone the Space repo and push the two files: ```bash git clone https://huggingface.co/spaces/YOUR_USERNAME/indicf5-api cd indicf5-api # Copy from your CodeVoice repo cp /path/to/codevoice/huggingface_space/app.py . cp /path/to/codevoice/huggingface_space/requirements.txt . cp /path/to/codevoice/huggingface_space/README.md . git add . && git commit -m "init indicf5 api" && git push ``` > No `Dockerfile` needed — Gradio SDK handles the server automatically. ### Step 3 — Wait for build First build installs deps and downloads the IndicF5 model (~1.4 GB). Takes **5–10 minutes**. Watch logs in the Space UI under **Logs** tab. ### Step 4 — Test the endpoint ```bash # Health check curl https://YOUR_USERNAME-indicf5-api.hf.space/health # Synthesis test curl -X POST https://YOUR_USERNAME-indicf5-api.hf.space/synthesize \ -F "text=नमस्ते, मेरा नाम अर्जुन है" \ -F "ref_text=Hello, this is my reference audio" \ -F "language=hindi" \ -F "ref_audio=@/path/to/reference.wav" \ --output output.wav ``` ### Step 5 — Connect to CodeVoice Add to `backend/.env`: ``` INDICF5_URL=https://YOUR_USERNAME-indicf5-api.hf.space INDICF5_TIMEOUT=120 ``` Restart the CodeVoice backend. Done. ### Step 6 — Keep-Alive cron (recommended) Free Spaces sleep after ~15 min of inactivity. Add this to your server's crontab: ```bash # crontab -e */10 8-22 * * * curl -s https://YOUR_USERNAME-indicf5-api.hf.space/health > /dev/null ``` --- ## How the URL works Your Space URL pattern: `https://YOUR_USERNAME-indicf5-api.hf.space` - `/` → Gradio demo UI (browser) - `/health` → JSON liveness (CodeVoice keep-alive) - `/synthesize` → multipart POST (CodeVoice backend calls this) ## Limitations - Cold start after sleep: 50–90 seconds - No concurrency (CodeVoice's Redis/RQ queue handles this automatically) - ~20–35 seconds per synthesis on CPU - Reference WAV (~250 KB) sent on every request - Not suitable for real-time voice agents