Skip to main content

Piper Piper (Local)

The PiperTTSService provides integration with Piper, a fast, local neural text-to-speech engine. It is designed to run on low-power devices while maintaining high-quality output without any cloud costs.

Installation

  1. Install and run a Piper HTTP server (e.g., piper-http).
  2. Install the SDK:
    pip install piopiy-ai

Configuration

PiperTTSService Parameters

ParameterTypeDefaultDescription
base_urlstrRequiredURL of the Piper HTTP server.
aiohttp_sessionClientSessionRequiredShared aiohttp session.
sample_rateintNoneOutput sample rate (defaults to model's native rate).

Usage

Basic Setup

import aiohttp
from piopiy.services.piper.tts import PiperTTSService

async with aiohttp.ClientSession() as session:
tts = PiperTTSService(
base_url="http://localhost:5000",
aiohttp_session=session
)

Notes

  • Model Dependency: The sample rate and voice quality depend entirely on the model file loaded by the Piper server.
  • WAV Handling: The service automatically strips WAV headers returned by the Piper server to provide raw PCM data.
  • Latency: Being local, Piper offers extremely low latency, often faster than real-time even on basic hardware.