{"id":49351502,"url":"https://github.com/nikita-popov/tts-api","last_synced_at":"2026-04-27T10:03:31.442Z","repository":{"id":325450044,"uuid":"1101214558","full_name":"nikita-popov/tts-api","owner":"nikita-popov","description":"Kokoro based TTS API","archived":false,"fork":false,"pushed_at":"2026-04-24T15:46:26.000Z","size":27,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-04-24T16:47:19.542Z","etag":null,"topics":["kokoro-tts","tts","tts-api"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nikita-popov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-11-21T11:02:25.000Z","updated_at":"2026-04-24T15:46:29.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/nikita-popov/tts-api","commit_stats":null,"previous_names":["nikita-popov/tts-api"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/nikita-popov/tts-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikita-popov%2Ftts-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikita-popov%2Ftts-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikita-popov%2Ftts-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikita-popov%2Ftts-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nikita-popov","download_url":"https://codeload.github.com/nikita-popov/tts-api/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikita-popov%2Ftts-api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32331306,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-26T23:26:28.701Z","status":"online","status_checked_at":"2026-04-27T02:00:06.769Z","response_time":128,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["kokoro-tts","tts","tts-api"],"created_at":"2026-04-27T10:03:13.497Z","updated_at":"2026-04-27T10:03:31.425Z","avatar_url":"https://github.com/nikita-popov.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TTS API\n\nText-to-speech service with three engines:\n- **[Silero TTS v4](https://github.com/snakers4/silero-models)** — Russian, high quality, 48 kHz\n- **[Kokoro-ONNX](https://github.com/thewh1teagle/kokoro-onnx)** — English, Japanese and other languages\n- **[Piper](https://github.com/rhasspy/piper)** — Russian fallback (`ru-piper`)\n\nExposes two interfaces: a **REST API** (Flask/Gunicorn) and an **MCP server** (stdio, JSON-RPC 2.0).\n\n## Features\n\n- Multi-engine routing — language determines the engine automatically\n- Sequential request processing — thread-safe lock ensures clean audio output\n- Multiple voices — gender-diverse voice options per language\n- Speed control — `speed` parameter (0.5 slow … 2.0 fast)\n- REST API — JSON endpoints with Swagger UI (`/apidocs`)\n- MCP server — native stdio transport, works with any MCP-compatible LLM client\n- Configuration via ENV variables — no hardcoded paths or defaults\n- Lazy engine loading — engines initialise on first use\n\n## Engine routing\n\n| Language | Code | Engine | Voices | Hz |\n|---|---|---|---|---|\n| English | `en`, `br` | Kokoro | af_heart, af_bella, … | 24000 |\n| Japanese | `ja` | Kokoro | jf_alpha, jm_kumo, … | 24000 |\n| Russian | `ru` | **Silero v4** | aidar, baya, kseniya, xenia, random | 48000 |\n| Russian (fallback) | `ru-piper` | Piper | irina | 22050 |\n\n## Requirements\n\n- Python 3.8+\n- PortAudio (`libportaudio2`)\n- espeak-ng (required by Piper phonemiser, used for `ru-piper`)\n- Audio output device\n\n\u003e **Note:** Silero model is downloaded automatically via `torch.hub` on first run\n\u003e and cached in `~/.cache/torch/hub`. Internet access is required once.\n\n## Installation\n\n### 1. System dependencies\n\n```bash\nsudo apt-get install libportaudio2 espeak-ng\n```\n\n### 2. Download model files\n\nSee [`models/README.md`](models/README.md) for download instructions.\n\n### 3. Python environment\n\n```bash\npython3 -m venv venv\nsource venv/bin/activate\npip install -r requirements.txt\n```\n\n## Configuration\n\n| Variable | Default | Description |\n|---|---|---|\n| `TTS_MODEL_PATH` | `models/kokoro-v1.0.onnx` | Kokoro ONNX model |\n| `TTS_VOICES_PATH` | `models/voices-v1.0.bin` | Kokoro voices binary |\n| `TTS_VOCAB_PATH` | `models/config.json` | Kokoro vocabulary config |\n| `TTS_SAMPLE_RATE` | `24000` | Kokoro audio sample rate |\n| `PIPER_MODEL_PATH` | `models/ru_RU-irina-medium.onnx` | Piper ONNX model |\n| `PIPER_CONFIG_PATH` | `models/ru_RU-irina-medium.onnx.json` | Piper model config |\n| `TTS_LANG` | `ru` | Default language code |\n| `TTS_VOICE` | `xenia` | Default voice ID |\n| `TTS_OUTPUT` | `playback` | Output mode: `playback` or `file` |\n\n## Running\n\n### REST API\n\n```bash\nsource venv/bin/activate\ngunicorn -w 1 -b 0.0.0.0:5000 run:app\n```\n\nSingle worker (`-w 1`) is required to avoid audio device conflicts.  \nSwagger UI: `http://localhost:5000/apidocs`\n\n```bash\n# Russian — Silero v4 (default)\ncurl -X POST http://localhost:5000/v1/speak \\\n  -H 'Content-Type: application/json' \\\n  -d '{\"text\": \"Привет, мир!\"}'\n\n# Russian — slower speech\ncurl -X POST http://localhost:5000/v1/speak \\\n  -H 'Content-Type: application/json' \\\n  -d '{\"text\": \"Привет!\", \"speed\": 0.85}'\n\n# Russian — Piper fallback\ncurl -X POST http://localhost:5000/v1/speak \\\n  -H 'Content-Type: application/json' \\\n  -d '{\"lang\": \"ru-piper\", \"text\": \"Привет, мир!\"}'\n\n# English — Kokoro\ncurl -X POST http://localhost:5000/v1/speak \\\n  -H 'Content-Type: application/json' \\\n  -d '{\"lang\": \"en\", \"text\": \"Hello, world!\", \"voice\": \"af_heart\"}'\n```\n\n#### Request parameters\n\n| Parameter | Type | Default | Description |\n|---|---|---|---|\n| `text` | string | **required** | Text to synthesize |\n| `lang` | string | `ru` | Language code |\n| `voice` | string | `xenia` | Voice ID |\n| `output` | string | `playback` | `playback` or `file` |\n| `speed` | float | `1.0` | Speed multiplier (0.5 … 2.0) |\n\n### MCP server\n\n```bash\nsource venv/bin/activate\npython server.py\n```\n\nConfigure your MCP client:\n\n```json\n{\n  \"mcpServers\": {\n    \"tts\": {\n      \"command\": \"/path/to/tts-api/venv/bin/python\",\n      \"args\": [\"/path/to/tts-api/server.py\"]\n    }\n  }\n}\n```\n\n#### Available MCP tools\n\n| Tool | Arguments | Description |\n|---|---|---|\n| `tts_speak` | `text`, `lang?`, `voice?`, `output?`, `speed?` | Synthesize and play speech |\n| `tts_list_voices` | `lang?` | List voices for a language |\n| `tts_list_languages` | — | List supported language codes and engines |\n\n## Systemd (REST API)\n\n```ini\n[Service]\nUser=your_username\nWorkingDirectory=/path/to/tts-api\nExecStart=/path/to/tts-api/venv/bin/gunicorn -w 1 -b 0.0.0.0:5000 run:app\nRestart=on-failure\n```\n\n```bash\nsudo cp tts.service /etc/systemd/system/\nsudo systemctl daemon-reload\nsudo systemctl enable --now tts.service\n```\n\n## License\n\nSource code: MIT.  \nKokoro-82M model: Apache 2.0 — see [official repository](https://huggingface.co/hexgrad/Kokoro-82M).  \nSilero models: MIT — see [snakers4/silero-models](https://github.com/snakers4/silero-models).  \nPiper voices: various open licenses — see individual model cards on [Hugging Face](https://huggingface.co/rhasspy/piper-voices).\n\n## Credits\n\n- [Silero TTS](https://github.com/snakers4/silero-models) — high-quality Russian TTS by snakers4\n- [Kokoro-82M](https://huggingface.co/hexgrad/Kokoro-82M) — TTS model by hexgrad\n- [kokoro-onnx](https://github.com/thewh1teagle/kokoro-onnx) — ONNX runtime implementation\n- [Piper](https://github.com/rhasspy/piper) — fast local TTS by rhasspy\n- [espeak-ng](https://github.com/espeak-ng/espeak-ng) — phonemisation backend\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnikita-popov%2Ftts-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnikita-popov%2Ftts-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnikita-popov%2Ftts-api/lists"}