RUNLOCALAIv38
->Will it run?Best GPUCompareTroubleshootStartLearnPulseModelsHardwareToolsBench
Run check
RUNLOCALAI

Independently operated catalog for local-AI hardware and software. Hand-written verdicts. Source-cited claims. Reproducible commands when we have them.

OP·Eruo Fredoline
DIR
  • Models
  • Hardware
  • Tools
  • Benchmarks
TOOLS
  • Will it run?
  • Compare hardware
  • Cost vs cloud
  • Choose my GPU
  • Prompting kits
  • Quick answers
REF
  • All buyer guides
  • Learn local AI
  • Methodology
  • Glossary
  • Errors KB
  • Trust
EDITOR
  • About
  • Author
  • How we make money
  • Editorial policy
  • Contact
LEGAL
  • Privacy
  • Terms
  • Sitemap
MAIL · MONTHLY DIGEST
Get monthly local AI changes
Monthly recap. No spam.
DISCLOSURE

Some links on this site are affiliate links (Amazon Associates and other first-class retailers). When you buy through them, we earn a small commission at no extra cost to you. Affiliate links do not influence our verdicts — there are cards we rate highly that we don't have affiliate relationships with, and cards that sell well that we refuse to recommend. Read more →

© 2026 runlocalai.coIndependently operated
RUNLOCALAI · v38
  1. >
  2. Home
  3. /Learn
  4. /Courses
  5. /Voice AI with Local Models
  6. /Ch. 8
Voice AI with Local Models

08. TTS: Piper

Chapter 8 of 22 · 20 min
KEY INSIGHT

Piper prioritizes efficiency for edge deployment at the cost of some voice naturalness compared to larger models.

Piper provides on-device TTS optimized for Raspberry Pi and embedded deployment. The models are extremely efficient, running on CPU with minimal power consumption.

Installation:

pip install piper-tts numpy

Download a voice model:

# Download English US voice
wget https://github.com/rhasspy/piper/raw/master/voicess/l_Jenny_Compact/or,柳柳,柳,柳,柳,柳
que.onnx
wget https://github.com/rhasspy/piper/raw/master/voicess/l_Jenny_Compact/or,柳,柳,柳,柳,柳
que.onnx.json

Generation pipeline:

import subprocess
import wave
import struct

text = "Piper text to speech runs efficiently on resource-constrained devices."

with wave.open("output.wav", "wb") as wav:
    wav.setnchannels(1)
    wav.setsampwidth(2)
    wav.setframerate(22050)
    
    process = subprocess.Popen(
        ["piper", "--model", "en_US-Jenny_Compact.onnx",
         "--output-raw"],
        stdin=subprocess.PIPE,
        stdout=wav,
        stderr=subprocess.DEVNULL
    )
    process.communicate(input=text.encode())

Batch generation for long texts:

import subprocess

sentences = [
    "First sentence of the longer response.",
    "Second sentence builds on the first.",
    "Third sentence concludes the thought."
]

for i, sentence in enumerate(sentences):
    result = subprocess.run(
        ["piper", "--model", "en_US-Jenny_Compact.onnx",
         "--output-file", f"sentence_{i}.wav"],
        input=sentence.encode(),
        capture_output=True
    )

A known limitation involves handling extremely long inputs. Break text into sentences and concatenate audio segments for continuous playback. Include brief silence between segments for natural pacing.

Voice selection offers dozens of options with varying quality levels. Compact models sacrifice some quality for file size, suitable for embedded deployment. Standard and high-quality voices require more storage but produce more natural output.

Local verification checkpoint

Run the smallest example from this chapter in a local workspace and record the package version, runtime, data path, and observed output. If the result depends on model size, vector count, CPU/GPU backend, or available memory, note that constraint beside the exercise so the lesson remains reproducible.

Local verification checkpoint

Run the smallest example from this chapter in a local workspace and record the package version, runtime, data path, and observed output. If the result depends on model size, vector count, CPU/GPU backend, or available memory, note that constraint beside the exercise so the lesson remains reproducible.

EXERCISE

Generate speech using a Piper voice on a text input. Measure execution time and note audio quality characteristics. Profile CPU usage during generation. (10 minutes)

← Chapter 7
TTS: XTTS-v2
Chapter 9 →
STT→LLM→TTS Pipeline