Piper
Local text to speech for @micdrop/server, driving the Piper binary as a subprocess.
Piper voices are small VITS models, a few dozen megabytes each, covering around forty languages including French. They generate much faster than real time even on a modest CPU, which makes Piper the option to reach for outside English. In English itself, Kokoro sounds better, and English is all it speaks in Micdrop.
Installation
Install the package:
npm install @micdrop/piperInstall the binary:
pip install piper-ttsThen download a voice. It comes as a pair of files that have to sit next to each other:
mkdir -p voices && cd voicesBASE=https://huggingface.co/rhasspy/piper-voices/resolve/main/fr/fr_FR/siwis/mediumcurl -LO $BASE/fr_FR-siwis-medium.onnxcurl -LO $BASE/fr_FR-siwis-medium.onnx.jsonPiper ships a download_voices module, but calling it means finding the exact
interpreter pip installed it under, which is rarely the python3 in your
path. Downloading the two files is shorter and gives the same result.
Usage
import { PiperTTS } from '@micdrop/piper'import { MicdropServer } from '@micdrop/server'
const tts = new PiperTTS({ modelPath: './voices/fr_FR-siwis-medium.onnx',})
// Use with MicdropServernew MicdropServer(socket, { tts, // ... other options})Options
| Option | Type | Default | Description |
|---|---|---|---|
modelPath | string | Required | Path to the .onnx voice file |
configPath | string | <modelPath>.json | Voice configuration |
binaryPath | string | 'piper' in PATH | Piper executable |
speaker | number | Optional | Speaker index, for voices with several speakers |
lengthScale | number | Optional | Duration multiplier, above 1 to slow the voice down |
noiseScale | number | Optional | Variability of the generated speech |
noiseWidth | number | Optional | Variability of the phoneme durations |
sentenceSilence | number | Optional | Silence added after each sentence, in seconds |
Voices
Voices are named after their language, their speaker and their quality, such as
fr_FR-siwis-medium or en_GB-alba-medium. The
voice samples page lets you listen
to them before downloading.
Each voice ships as <name>.onnx and <name>.onnx.json. The JSON file gives
the sample rate the model generates at, and Micdrop reads that file at startup
so the audio reaches the client at the rate it expects.
One process per sentence
The exit of each Piper process marks the end of a sentence’s audio, and killing it makes an interruption immediate. Loading a voice costs on the order of a hundred milliseconds, paid while the client is still playing the previous sentence.
The whole answer is usually ready before the user has finished hearing its first sentence.
Documentation
Read the guide on running Micdrop with local models to see how Piper fits with a local LLM and local speech to text.
License
Piper is released under the MIT license, and each voice under its own permissive license.