Skip to main content

Overview

PlayHT provides high-quality text-to-speech synthesis with two service implementations: PlayHTTTSService (WebSocket-based) for real-time streaming with ultra-low latency, and PlayHTHttpTTSService (HTTP-based) for simpler synthesis. PlayHTTTSService is recommended for interactive applications requiring low latency and advanced interruption handling.
PlayHT shut down their API on December 31st, 2025. Both PlayHTTTSService and PlayHTHttpTTSService are deprecated and will be removed in a future version.

Installation

To use PlayHT services, install the required dependencies:
pip install "pipecat-ai[playht]"

Prerequisites

PlayHT Account Setup

Before using PlayHT TTS services, you need:
  1. PlayHT Account: Sign up at PlayHT Dashboard
  2. API Credentials: Get your User ID and API Key from the dashboard
  3. Voice Selection: Choose from standard voices or create custom cloned voices

Required Environment Variables

  • PLAY_HT_USER_ID: Your PlayHT user ID
  • PLAY_HT_API_KEY: Your PlayHT API key for authentication

Configuration

PlayHTTTSService

api_key
str
required
PlayHT API key for authentication.
user_id
str
required
PlayHT user ID for authentication.
voice_url
str
required
URL of the voice to use for synthesis.
voice_engine
str
default:"Play3.0-mini"
Voice engine to use for synthesis.
sample_rate
int
default:"None"
Output audio sample rate in Hz. When None, uses the pipeline’s configured sample rate.
output_format
str
default:"wav"
Audio output format.
params
InputParams
default:"None"
Runtime-configurable voice and generation settings. See InputParams below.

PlayHTHttpTTSService

api_key
str
required
PlayHT API key for authentication.
user_id
str
required
PlayHT user ID for authentication.
voice_url
str
required
URL of the voice to use for synthesis.
voice_engine
str
default:"Play3.0-mini"
Voice engine to use for synthesis.
output_format
str
default:"wav"
Audio output format.
sample_rate
int
default:"None"
Output audio sample rate in Hz. When None, uses the pipeline’s configured sample rate.
params
InputParams
default:"None"
Runtime-configurable voice and generation settings. See InputParams below.

InputParams

Both WebSocket and HTTP services share the same InputParams structure.
ParameterTypeDefaultDescription
languageLanguageLanguage.ENLanguage for synthesis. Supports 30+ languages.
speedfloat1.0Speech speed multiplier.
seedintNoneRandom seed for voice consistency.

Usage

Basic Setup (WebSocket)

from pipecat.services.playht import PlayHTTTSService

tts = PlayHTTTSService(
    api_key=os.getenv("PLAY_HT_API_KEY"),
    user_id=os.getenv("PLAY_HT_USER_ID"),
    voice_url="s3://voice-cloning-zero-shot/...",
)

HTTP Service

from pipecat.services.playht import PlayHTHttpTTSService

tts = PlayHTHttpTTSService(
    api_key=os.getenv("PLAY_HT_API_KEY"),
    user_id=os.getenv("PLAY_HT_USER_ID"),
    voice_url="s3://voice-cloning-zero-shot/...",
    params=PlayHTHttpTTSService.InputParams(
        speed=1.2,
        seed=42,
    ),
)

Notes

  • Deprecated: PlayHT shut down their API on December 31st, 2025. Both services are deprecated and will be removed in a future version.
  • WebSocket vs HTTP: The WebSocket service handles persistent connections with interruption support. The HTTP service is simpler and creates a new request per TTS call.

Event Handlers

PlayHT WebSocket TTS supports the standard service connection events:
EventDescription
on_connectedConnected to PlayHT WebSocket
on_disconnectedDisconnected from PlayHT WebSocket
on_connection_errorWebSocket connection error occurred
@tts.event_handler("on_connected")
async def on_connected(service):
    print("Connected to PlayHT")