XTTS (Local)
The XTTSService integrates with a locally running Coqui XTTS streaming server. It is ideal for applications requiring local voice cloning and absolute data privacy.
Installation
- Run the XTTS Docker container:
docker run --gpus=all -e COQUI_TOS_AGREED=1 --rm -p 8000:80 ghcr.io/coqui-ai/xtts-streaming-server:latest-cuda121 - Install the SDK:
pip install piopiy-ai
Configuration
XTTSService Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
voice_id | str | Required | ID of the speaker to use. |
base_url | str | Required | URL of the local XTTS server. |
language | Language | Language.EN | Language for synthesis. |
Usage
Basic Setup
import aiohttp
from piopiy.services.xtts.tts import XTTSService
async with aiohttp.ClientSession() as session:
tts = XTTSService(
voice_id="female_voice",
base_url="http://localhost:8000",
aiohttp_session=session
)
Notes
- Voice Cloning: You can load different speakers by passing their IDs retrieved from the
/studio_speakersendpoint. - Performance: XTTS generates audio at 24kHz; the SDK automatically resamples it to your desired rate.
- Privacy: Since it runs locally in Docker, no audio data or text is sent to an external service.