One sentence per Piper call is slow when you have a hundred. --json-input takes a file of JSON objects, one per line, and Piper speaks them all in one run — each line can even carry its own speaker or output file.
Write the JSON lines and run Piper once
Write a file with one JSON object per line: each line has a text field, and optionally a speaker, a speaker_id, or an output_file. Then run piper --model en_US-lessac-medium --json-input sentences.jsonl. Piper reads each line, speaks it, and writes the audio — one run for the whole batch instead of one process per sentence.
{"text": "First sentence."}
{"text": "Second sentence.", "speaker": 1}
{"text": "Third sentence.", "output_file": "third.wav"}
piper --model en_US-lessac-medium --json-input sentences.jsonl
One bad line stops the batch: a line that is not valid JSON, or a speaker number past the voice’s count, fails the run. Check the file with a JSON linter first, and keep the batch small on the first try — a hundred lines is a lot to debug at once.
Try it: four checks
| Check | What you should see | If you do not see it |
|---|---|---|
| File written | The .jsonl file has one object per line | Each line is valid JSON |
| Fields right | Each line has a text field | speaker and output_file are optional |
| Run succeeds | Piper finishes the batch | Check the first bad line on error |
| Audio written | The output files exist | Check each output_file path |
Expected result. We checked the Piper README, which documents –json-input with per-line JSON objects carrying text plus optional speaker, speaker_id and output_file. We did not run a batch on this machine.
Limits
This guide covers the JSON input only. One bad line fails the batch. We did not test any batch ourselves.
