PHPackages                             crazy-goat/piper-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. crazy-goat/piper-php

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

crazy-goat/piper-php
====================

Text-to-speech in PHP using Piper via FFI

v0.1.8(3mo ago)023MITPHPPHP &gt;=8.2CI passing

Since Mar 30Pushed 3mo agoCompare

[ Source](https://github.com/crazy-goat/piper-php)[ Packagist](https://packagist.org/packages/crazy-goat/piper-php)[ RSS](/packages/crazy-goat-piper-php/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (6)Dependencies (10)Versions (10)Used By (0)

Piper PHP
=========

[](#piper-php)

Text-to-speech in PHP using [Piper](https://github.com/OHF-Voice/piper1-gpl) via FFI.

[![PHP Version](https://camo.githubusercontent.com/d840cef9807c8f76051ad687841d67f4d830c84e0d83236968e53124ef6742d5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344382e322d3838393242462e737667)](https://php.net/)[![License](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](LICENSE)

Fast, local text-to-speech synthesis without external services. Piper runs entirely on your machine using ONNX Runtime.

Features
--------

[](#features)

- 🚀 **Fast** - Local synthesis, no network latency
- 🔊 **High quality** - Uses Piper neural TTS models
- 📦 **Easy installation** - Composer package with FFI
- 🎯 **Simple API** - Load model once, synthesize many times
- ⚡ **Warm-up support** - Avoid first-chunk delay in production
- 🔄 **Streaming** - Generate audio chunk by chunk for real-time playback

Requirements
------------

[](#requirements)

- PHP &gt;= 8.2 with FFI extension enabled
- Piper library (libpiper.so) and ONNX Runtime
- Voice models (.onnx files)

Installation
------------

[](#installation)

```
composer require crazy-goat/piper-php

# Download pre-built libraries
vendor/bin/piper-tts install-deps
```

This will download and extract to `vendor/crazy-goat/piper-php/libs/`:

- `libpiper.so` - Piper library
- `libonnxruntime.so` - ONNX Runtime
- `espeak-ng-data/` - Phoneme data

### Manual Download

[](#manual-download)

If you prefer to download manually or need a specific version:

```
# Download individual libraries
wget https://github.com/crazy-goat/piper-php/releases/latest/download/libpiper-linux-x86_64.tar.gz
wget https://github.com/crazy-goat/piper-php/releases/latest/download/libonnxruntime-linux-x86_64.tar.gz
wget https://github.com/crazy-goat/piper-php/releases/latest/download/espeak-ng-data.tar.gz

# Extract
tar -xzf libpiper-linux-x86_64.tar.gz
tar -xzf libonnxruntime-linux-x86_64.tar.gz
tar -xzf espeak-ng-data.tar.gz
```

### Building from Source

[](#building-from-source)

If you prefer to build from source or need a different architecture:

```
# Clone with submodules
git clone --recursive https://github.com/crazy-goat/piper-php.git
cd piper-php

# Or initialize submodules if already cloned
git submodule update --init --recursive

# Build libpiper and copy to libs/ (like composer does)
make build-libs

# Or build everything including espeakbridge
make build-piper1
```

The build will create:

- `libs/libpiper.so` - Piper library (copied to project root)
- `libs/libonnxruntime.so` - ONNX Runtime (with all versioned files)
- `libs/espeak-ng-data/` - Phoneme data

### Running Examples Locally

[](#running-examples-locally)

If you're developing locally (not via composer), build libraries and run examples:

```
# Build libraries and copy to libs/ directory
make examples

# Download a voice model
./bin/piper-tts download en_US-lessac-medium ./models

# Run example
php examples/speak.php "Hello world"
```

This is equivalent to running `vendor/bin/piper-tts install-deps` for composer users.

### Downloading Voice Models

[](#downloading-voice-models)

Use the included CLI tool to download voices from HuggingFace:

```
# List available voices
./bin/piper-tts list

# Filter by language
./bin/piper-tts list --language=pl

# Download a voice
./bin/piper-tts download en_US-lessac-medium ./models

# List installed voices
./bin/piper-tts installed ./models
```

Or download manually from [HuggingFace](https://huggingface.co/rhasspy/piper-voices/tree/main).

Quick Start
-----------

[](#quick-start)

```
