Writing a WAV file first and playing it second adds a wait. Piper can stream instead: --output-raw sends the raw audio to stdout, and you pipe it straight into a player — the voice starts as soon as the first audio arrives.
Pipe the raw stream into a player
Run Piper with --output-raw and pipe stdout to a player that takes raw PCM: echo 'Hello!' | piper --model en_US-lessac-medium --output-raw | aplay -r 22050 -f S16_LE -t raw -. The raw stream is 16-bit mono PCM at the voice’s sample rate — 22050 Hz for this voice — so the player needs the same rate, format and channel count, or the audio plays at the wrong speed.
echo 'Hello!' | piper --model en_US-lessac-medium --output-raw | \
aplay -r 22050 -f S16_LE -t raw -
# raw stream: 16-bit mono PCM at the voice sample rate (22050 here)
The sample rate belongs to the voice, not to Piper: another voice may use 16000 or 44100 Hz, and the player rate must match it. Check the voice’s config file for its sample rate before you pipe, or the voice will sound like the wrong person.
Try it: four checks
| Check | What you should see | If you do not see it |
|---|---|---|
| Raw flag set | The command uses –output-raw | No output file |
| Player rate right | The player rate matches the voice | 22050 for this voice |
| Audio starts fast | Sound begins before the sentence ends | That is streaming working |
| Speed right | The voice sounds normal | Wrong rate sounds wrong |
Expected result. We checked the Piper README, which documents –output-raw streaming 16-bit mono PCM to stdout at the voice’s sample rate, with 22050 as the example. We did not stream audio on this machine.
Limits
This guide covers the raw stream only. The sample rate belongs to the voice and must match the player. We did not test any stream ourselves.
