Deprecated
PlayHT is shutting down their API on December 31st, 2025. PlayHTTTSService is deprecated and will be removed in a future version.
PlayHT
The PlayHTTTSService provides real-time text-to-speech synthesis using PlayHT's WebSocket API. It supports high-quality voice clones and a variety of pre-trained models.
Installation
pip install "piopiy-ai[playht]"
Prerequisites
- A PlayHT account, API key, and User ID (Get yours here).
- Set your credentials in your environment:
export PLAYHT_API_KEY="your_api_key"
export PLAYHT_USER_ID="your_user_id"
Configuration
PlayHTTTSService Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
api_key | str | Required | Your PlayHT API key. |
user_id | str | Required | Your PlayHT user ID. |
voice_url | str | Required | URL of the voice to use. |
voice_engine | str | "Play3.0-mini" | Voice engine to use. |
params | InputParams | InputParams() | Synthesis settings. |
InputParams
| Parameter | Type | Default | Description |
|---|---|---|---|
language | Language | Language.EN | Language for synthesis. |
speed | float | 1.0 | Speech speed multiplier. |
seed | int | None | Random seed for consistency. |
Usage
Basic Setup
import os
from piopiy.services.playht.tts import PlayHTTTSService
tts = PlayHTTTSService(
api_key=os.getenv("PLAYHT_API_KEY"),
user_id=os.getenv("PLAYHT_USER_ID"),
voice_url="s3://voice-cloning-zero-shot/..."
)
Notes
- WebSocket Connection: This service maintains a persistent connection for low-latency streaming.
- HTTP Alternative: For non-streaming use cases, you can use
PlayHTHttpTTSService.