Skip to content
 
 

Repository files navigation

API Server and Wyoming (Home Assistant) to run Silero TTS on CUDA or CPU

Fast as real on GPU , only 550MB VRAM required *** Для русского и украинского языка используется морфинг числительных и конвертация латинницы в кирилицу. Для украинского не тестировалось

Credit goes to the developers of Silero TTS
Silero PyTorch Page
Silero GitHub Page

Installation

pip install silero-api-server

OR

git clone https://github.com/NW15D/silero-api-server.git cd silero-api-server pip install -v -e . --extra-index-url https://download.pytorch.org/whl/cu126 python -m silero_api_server --wyoming-port 10200

Starting Server

Python <= 3.12 is required. python -m silero_api_server will run on default ip and port (0.0.0.0:8001)

usage: silero_api_server [-h] [-o HOST] [-p PORT]

Run Silero within a FastAPI application

options:
  -h, --help            show this help message and exit
  -o HOST, --host HOST
  -p PORT, --port PORT
  -m MODEL, --model MODEL
  --show-models

On first run of server, two operations occur automatically. These may take a minute or two.

  1. The model will be downloaded
  2. Voice samples will be generated.

Deploying server as a container

You can build an image from current source by running docker build -t silero:latest . in the top level of repository. Server can then be deployed as a container with docker run -p 8001:8001 silero:latest.

API Docs

API Docs can be accessed from http://localhost:8001/docs

Default model

By default, the server uses the v5_ru.pt model. You can change the model via command-line options or change it at runtime using POST /tts/model with payload {"id":"model_id"}. List of available models is available via GET /tts/model.

Home Assistant Integration

You can use this server with Home Assistant in two ways:

1. Wyoming Protocol (Recommended for Voice Assistant)

The server supports the Wyoming protocol, which allows it to work seamlessly with Home Assistant's local voice control. To start the server with Wyoming support on port 10200: python -m silero_api_server --wyoming-port 10200 Then, in Home Assistant, add the Wyoming Protocol integration and point it to your server's IP and port 10200.

2. Native TTS Component

A base implementation for a native Home Assistant TTS platform is provided in ha_tts.py. You can use this as a reference to create a custom_component.

OpenAI-Compatible API

The server provides an OpenAI-compatible speech endpoint at /v1/audio/speech.

Supported Parameters

Parameter Type Description Notes
input string Text to synthesize (max 4096 chars) Required
voice string Voice to use: aidar, baya, kseniya, xenia Default: baya
response_format string Output format: mp3, opus, aac, flac, wav, ogg Default: mp3
model string TTS model (e.g., tts-1) Ignored with warning
speed float Speech speed (0.25-4.0) Ignored with warning
instructions string Voice instructions Ignored with warning

Examples

Generate MP3 (default)

curl -X POST http://localhost:8001/v1/audio/speech \
  -H "Content-Type: application/json" \
  -d '{
    "input": "Привет, мир! Это тестовое сообщение.",
    "voice": "baya",
    "response_format": "mp3"
  }' \
  --output output.mp3

Generate Opus

curl -X POST http://localhost:8001/v1/audio/speech \
  -H "Content-Type: application/json" \
  -d '{
    "input": "Здравствуйте! Как дела?",
    "voice": "kseniya",
    "response_format": "opus"
  }' \
  --output output.opus

Generate WAV (original Silero format)

curl -X POST http://localhost:8001/v1/audio/speech \
  -H "Content-Type: application/json" \
  -d '{
    "input": "Привет, мир!",
    "voice": "aidar",
    "response_format": "wav"
  }' \
  --output output.wav

Generate OGG (Telegram voice message format)

curl -X POST http://localhost:8001/v1/audio/speech \
  -H "Content-Type: application/json" \
  -d '{
    "input": "Привет, мир!",
    "voice": "baya",
    "response_format": "ogg"
  }' \
  --output output.ogg

Full OpenAI-compatible request

curl -X POST http://localhost:8001/v1/audio/speech \
  -H "Content-Type: application/json" \
  -d '{
    "model": "tts-1",
    "input": "Тестовое сообщение для проверки совместимости с OpenAI API.",
    "voice": "xenia",
    "response_format": "mp3",
    "speed": 1.0
  }' \
  --output output.mp3

Notes

  • Speed adjustment: Silero TTS does not support speed control. The speed parameter is accepted but ignored with a warning.
  • Model selection: Silero uses its own models. The model parameter is accepted but ignored with a warning.
  • PCM format: Not supported by Silero. Will return WAV with a warning.
  • Instructions: Not supported by Silero. Will be ignored with a warning.
  • OGG format: Optimized for Telegram voice messages (mono, 24kHz, OPUS codec).

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages