|
Download recipe/export/README.md from KaleComputer/kale-tts-1-tiny: direct link, hf CLI and curl.
- Browser
- Download file 4.78 kB
-
https://huggingface.co/KaleComputer/kale-tts-1-tiny/resolve/main/recipe/export/README.md
- Command line
-
hf download hf://KaleComputer/kale-tts-1-tiny/recipe/export/README.md
-
curl -L -o README.md https://huggingface.co/KaleComputer/kale-tts-1-tiny/resolve/main/recipe/export/README.md
4.78 kB
| # recipe/export: from trained exports to the release one-file graphs | |
| Licence: Apache-2.0. Needs `pip install onnx onnxruntime numpy` (and `node` + `modal` for the Whisper part of the check). | |
| `build_release.sh <bundle dir> <out dir>` | |
| - in: the training exports in `<bundle dir>` (nano: one graph with a voice-id input; tiny: one graph per voice; voicepacks | |
| `vp-<voice>.f32`), plus tokenizer / config from `../../models` (or `RELEASE_MODELS`). | |
| - out: `<out dir>/kale-tts-1-{nano,tiny}/` with `model.onnx`, `model.fp32.onnx`, `voices/`, `voices.json`, `export-check-*.json` (on the hub these are `kale-tts-1-<size>.onnx`, `kale-tts-1-<size>.fp32.onnx` and `results/export-check/`). | |
| Steps, in order (each keeps the graph's inputs, outputs and node names): | |
| 1. `make_onefile.py`: one graph per model, voice as inputs (`voice_prosody`, `voice_prosody_col`, `voice_sound`) instead of a voice id; | |
| writes `voices/<id>.bin` (style table [510,256]) and `voices/<id>.extra.bin` (the voice inputs, in `voices.json` order). | |
| 2. `phase_float32.py`: the sine source's phase path in float32. | |
| 3. `speedtools/harmsum.py`: the 64-harmonic sine sum in closed form (exact). | |
| 4. `speedtools/apply_stft.py` (+ `stft_fact.py`): the six STFTs as one batched factorised DFT (exact). | |
| 5. nano, optional: `speedtools/albert_arms.py --layers N` with `NANO_ALBERT_PASSES=N`. Default 0 = keep all 6 passes (the release). | |
| 6. `add_end_clamp.py` + `end_clamp_floors.json`: in: graph + per-voice floor in Hz; out: graph with a `voice_pitch_floor` input. In the | |
| last 36 voiced frames of a sentence, pitch above 50 Hz is held at or above max(85 Hz, the voice's Maya median x 2^-0.5). | |
| 7. `toposort.py`: sort and prune unused constants; `make_fp32_graph.py`: low-precision weights stored as float32. | |
| 8. Export check, when `REF_NANO_ONNX` / `REF_TINY_ONNX` point at the float32 training exports: the same steps are rebuilt from the | |
| float32 weights into `<out>/.ref`, then | |
| - `keep_fp32.py` (nano): ALBERT, its encoder link and the duration projection take the float32 values inside the int8 graph; | |
| - `fp16_to_ref_fp32.py` (tiny): ALBERT, the duration path and the pitch/loudness branch take the float32 values; the decoder stays int8; | |
| - the float32 rebuild becomes `model.fp32.onnx`; | |
| - `export_check.py <graph> <ref graph> <model dir> --json out.json`: in: 20 sentences (`check_ids.json`) x all voices, seeded noise; | |
| out: pass/fail per graph. Float graphs: same length + median SNR >= 30 dB. int8 graphs: same length + median log-mel L1 <= 0.20. | |
| - `whisper_check.py`: in: `whisper_items.json` and the graphs uploaded to the bench app's runs volume under `release/<model>/`; | |
| renders on Modal (`../bench`, functions `render_release` + `fe_score`), out: Whisper word errors per graph via `score_fe.mjs` | |
| (the release front end in `../../frontend`). Bar: the int8 graph within noise of its float32 reference. | |
| A failing check stops the build (exit 1). | |
| After the end clamp (17 Nov): `add_voice_tail.py <model dir> <out dir> '{"h013f": {"tail": 60, "thr": 1.0, "floor": 88.0}}'` makes the clamp's tail | |
| length and voicing threshold voice inputs (`voice_clamp_tail`, `voice_clamp_thr`, appended to each `.extra.bin`); every voice keeps 36 / 50 | |
| except the ones given (the release: Magnus 60 frames / 1 Hz / floor 88 Hz in tiny; 68 frames / 1 Hz / 90 Hz in nano). For tiny's Ettin graph the per-voice | |
| floor comes first from `ettin_voice_clamp.py`. | |
| Per-voice values (17 Nov): `voice_values.json` is the one source for every voice's `.extra.bin` scalars (floor, tail, threshold, and | |
| `unvoice_hz` once the graph has that input); `apply_voice_values.py <model dir> <tiny|nano>` writes them and prints each change. Toby / | |
| Jack / Earl first got their natural low ending as floor (10th percentile of sentence-end pitch before the clamp, 192 bench lines) so the | |
| clamp no longer lifted the last words; the low-pitch fix below replaced that the same day (no clamp for them). After applying: `export_check.py` on both models, and for nano rebuild `kokoro-compatible/` | |
| (`runtimes/sherpa-onnx/make_sherpa_model.py`, `runtimes/kokoro-onnx/make_voices_npz.py`, `kc_check.py`). | |
| Low-pitch fix (17 Nov midday): `add_voice_unvoice.py <model dir> <out dir> '{}'` makes the graph's fixed 80 Hz unvoicing floor (pitch below it | |
| is rendered as noise) a voice input, `voice_unvoice_hz`, in `model.onnx` and `model.fp32.onnx` (appended to every `.extra.bin`, 80 Hz for every | |
| voice). Then `apply_voice_values.py` writes `unvoice_hz` from `voice_values.json`: Magnus / Toby / Jack / Earl 60 Hz with floor 0 (no end clamp), | |
| the six others 80 Hz with their values (their output unchanged). Then `export_check.py` (tiny: both check sets; nano: defaults) and the nano | |
| `kokoro-compatible/` rebuild + `kc_check.py`, as above. | |