Skip to main content

Overview

PiperTTSService provides high-quality neural text-to-speech synthesis through a self-hosted HTTP server. The service offers complete privacy and control with no external API dependencies, making it ideal for on-premise deployments and applications requiring data sovereignty.

Installation

To use Piper services, no additional Pipecat dependencies are required:
pip install "pipecat-ai"  # Base installation is sufficient

Prerequisites

Piper Server Setup

Before using PiperTTSService, you need:
  1. Piper TTS Server: Set up a running Piper TTS server following the HTTP server documentation
  2. Voice Models: Download and configure voice models for your target languages
  3. Server Configuration: Configure server endpoint and voice selection

Required Configuration

  • Server URL: Configure the Piper server endpoint in your service initialization
  • Voice Models: Ensure required voice models are available on the server
Piper runs entirely locally, providing complete privacy and eliminating API key requirements.

Configuration

Piper offers two service implementations: PiperTTSService for local inference and PiperHttpTTSService for HTTP server-based synthesis.

PiperTTSService

Runs Piper locally, automatically downloading voice models as needed.
voice_id
str
required
Piper voice model identifier (e.g. en_US-ryan-high).
download_dir
Path
default:"None"
Directory for storing voice model files. Defaults to the current working directory.
force_redownload
bool
default:"False"
Re-download the voice model even if it already exists locally.
use_cuda
bool
default:"False"
Use CUDA for GPU-accelerated inference.

PiperHttpTTSService

Connects to a running Piper HTTP TTS server.
base_url
str
required
Base URL for the Piper TTS HTTP server.
aiohttp_session
aiohttp.ClientSession
required
An aiohttp session for HTTP requests.
voice_id
str
default:"None"
Piper voice model identifier (e.g. en_US-ryan-high).

Usage

Local Inference

from pipecat.services.piper import PiperTTSService

tts = PiperTTSService(
    voice_id="en_US-ryan-high",
)

HTTP Server

Start the Piper HTTP server first:
uv pip install "piper-tts[http]"
uv run python -m piper.http_server -m en_US-ryan-high
Then connect to it:
import aiohttp
from pipecat.services.piper import PiperHttpTTSService

async with aiohttp.ClientSession() as session:
    tts = PiperHttpTTSService(
        base_url="http://localhost:5000",
        aiohttp_session=session,
        voice_id="en_US-ryan-high",
    )

Notes

  • Local execution: PiperTTSService runs entirely locally with no network requests. Voice models are automatically downloaded on first use.
  • GPU acceleration: Set use_cuda=True for GPU-accelerated inference with PiperTTSService (requires CUDA-compatible hardware).
  • Audio resampling: Audio output is automatically resampled to match the pipeline’s configured sample rate.
  • No API key required: Piper is open-source and runs locally, so no API credentials are needed.