Examples
The maintained scripts in examples/ use the request-centric API. Install one provider
(for example, pykokoro[cpu]) before running a synthesis example. Uncached synthesis
may download model assets; discovery-only scripts are identified below. Outputs go to
example-artifacts/ when run directly, and to example-artifacts/<script>/ through the
runner.
Runner groups
python examples/run_all.py --list
python examples/run_all.py --group core
python examples/run_all.py --group feature
python examples/run_all.py --group language-showcase
python examples/run_all.py --group optional-heavy
python examples/run_all.py --include-optional
The default group is core. Feature examples and the language showcase are separate
from it; optional-heavy is never added unless selected explicitly or
--include-optional is used. The runner processes scripts sequentially, isolates each
script’s output directory, and continues after a script fails. Use --list to inspect a
group without running it.
Core request examples
Script / command |
Purpose and public API |
Assets, network, and cost |
Expected output |
|---|---|---|---|
|
Smallest request using |
First run may download one model/voice asset; low CPU cost. |
|
|
Two explicit |
First run may download model assets; low-to-medium CPU cost for two short requests. |
|
|
Contrasts a source-span |
First run may download model assets; low-to-medium cost for two short requests. |
|
|
Passes a source-aligned |
First run may download model assets; low CPU cost. |
|
|
Sends one oversized original request with |
First run may download model assets; higher CPU cost for the long passage. |
|
|
Compares linear and SLERP blends and synthesizes both outputs. |
First run may download assets for the selected model/voices; low-to-medium CPU cost. |
|
|
Prints request/result fields, token IDs, diagnostics, trace summary, synthesis identity, word timings, and voice-level applications. |
First run may download model assets; low CPU cost for one request. |
|
|
Uses |
Default discovery may refresh registry metadata over the network; |
Default: printed inventory only. With |
Feature examples
Script / command |
Purpose and public API |
Assets, network, and cost |
Expected output |
|---|---|---|---|
|
Synthesizes prepared English text, calls |
First run may download model assets; two short inferences, low-to-medium CPU cost. |
|
|
Contrasts automatic G2P language routing with an explicit deterministic language override on the same source span. Acoustic model and voice remain explicit. |
First run may download model assets; low-to-medium cost for two short requests. |
|
|
Runs offline |
No model assets or lexicon data are installed; offline discovery avoids metadata refresh. Low cost. |
Printed lexicon inventory and frontend configuration; no file. |
|
Demonstrates |
May download model assets on first use; low CPU cost for one short request. |
|
|
Shows narrow catches for invalid language, voice, pronunciation, and oversized input errors. |
First run may download model assets on the valid path; low CPU cost for one short request. |
Normally |
Input-driven example
reference_voice.py requires a user-supplied
recording and its exact English transcript, so it is not run by the unattended example
groups:
python examples/reference_voice.py reference.wav \
"The exact words spoken in the reference." \
"New words spoken with the enrolled voice."
The script enrolls the recording, saves and reloads ReferenceVoice, then synthesizes
the target text. The reference voice guide documents audio
constraints, model binding, privacy, and permissions.
Language showcase
These scripts are separated from the default runner group because each performs synthesis; uncached runs may download model assets. Each is a short-to-medium single-language showcase unless noted. Run one directly with the command shown.
Script / command |
Purpose and public API |
Assets, network, and cost |
Expected output |
|---|---|---|---|
|
Synthesizes Mandarin with explicit |
May download the Chinese model/voice assets; medium CPU cost. |
|
|
Exercises English contractions and past-tense endings through multiple requests; joins audio in this caller-owned example. |
May download model assets; higher CPU cost than a single short sample. |
|
|
Synthesizes a prepared French passage with an explicit French voice/language. |
May download model assets; medium CPU cost. |
|
|
Synthesizes an Italian passage using the request API. |
May download model assets; medium CPU cost. |
|
|
Synthesizes a Japanese passage with an explicit |
May download model assets; medium CPU cost. |
|
|
Demonstrates experimental Korean phonemization and a parsed |
Requires a compatible experimental frontend/profile and may download assets; medium CPU cost. |
|
|
Synthesizes a Brazilian Portuguese passage with an explicit voice and language. |
May download model assets; medium CPU cost. |
|
|
Synthesizes a prepared Spanish passage with the request API. |
May download model assets; medium CPU cost. |
|
Optional heavy examples
Script / command |
Purpose and public API |
Assets, network, and cost |
Expected output |
|---|---|---|---|
|
Uses model discovery to enumerate profiles, then submits one independent synthesis request per selected voice. The script itself assembles a comparison WAV on the caller side. |
Inventory may refresh registry metadata. Rendering can download many model/voice assets, use substantial storage, and run for a long time on CPU; list-only does not synthesize. |
|
|
Compares disabled, wrap, phrase, and randomized-phrase |
May download model assets; high CPU cost (many short requests across four modes). |
|
Every runnable script is listed above. __init__.py, _output.py, and run_all.py are
support modules rather than synthesis examples. For API details, see the
reference.