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
- Install and run a Piper HTTP server (e.g., piper-http).
- Install the SDK:
pip install piopiy-ai
Configuration
PiperTTSService Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
base_url | str | Required | URL of the Piper HTTP server. |
aiohttp_session | ClientSession | Required | Shared aiohttp session. |
sample_rate | int | None | Output 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.