Skip to main content
Deprecated

PlayHT is shutting down their API on December 31st, 2025. PlayHTTTSService is deprecated and will be removed in a future version.

PlayHT 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

ParameterTypeDefaultDescription
api_keystrRequiredYour PlayHT API key.
user_idstrRequiredYour PlayHT user ID.
voice_urlstrRequiredURL of the voice to use.
voice_enginestr"Play3.0-mini"Voice engine to use.
paramsInputParamsInputParams()Synthesis settings.

InputParams

ParameterTypeDefaultDescription
languageLanguageLanguage.ENLanguage for synthesis.
speedfloat1.0Speech speed multiplier.
seedintNoneRandom 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.