ElevenLabs
The ElevenLabsTTSService provides the highest quality AI voices with emotional range and personality. It's the recommended TTS provider for premium, high-fidelity voice applications.
Installation
To use ElevenLabs, install the required dependencies:
pip install "piopiy-ai[elevenlabs]"
Prerequisites
- An ElevenLabs account and API key (Get yours here).
- Set your API key in your environment:
export ELEVENLABS_API_KEY="your_api_key_here"
Configuration
ElevenLabsTTSService Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
api_key | str | Required | Your ElevenLabs API key. |
voice_id | str | "pNInz6obpgmqMHCicJ4A" | Voice ID (e.g., "Rachel"). |
model | str | "eleven_turbo_v2_5" | Model ID for synthesis. |
output_format | str | "pcm_16000" | Audio format (e.g., "pcm_16000"). |
Usage
Basic Setup
import os
from piopiy.services.elevenlabs.tts import ElevenLabsTTSService
tts = ElevenLabsTTSService(
api_key=os.getenv("ELEVENLABS_API_KEY"),
voice_id="pNInz6obpgmqMHCicJ4A", # Rachel
model="eleven_turbo_v2_5"
)
Notes
- Latency:
eleven_turbo_v2_5is recommended for real-time voice agents due to its optimized latency and high quality. - Custom Voices: You can use your own cloned voices by providing their unique
voice_id. - WebSocket Streaming: This service uses ElevenLabs' WebSocket API to stream audio as it's generated.