Download recipe/teacher/make_rows.py from KaleComputer/kale-tts-1-tiny: direct link, hf CLI and curl.
- Browser
- Download file 2.16 kB
-
https://huggingface.co/KaleComputer/kale-tts-1-tiny/resolve/main/recipe/teacher/make_rows.py
- Command line
-
hf download hf://KaleComputer/kale-tts-1-tiny/recipe/teacher/make_rows.py
-
curl -L -o make_rows.py https://huggingface.co/KaleComputer/kale-tts-1-tiny/resolve/main/recipe/teacher/make_rows.py
2.16 kB
| # SPDX-License-Identifier: Apache-2.0 | |
| # Copyright 2026 Kale | |
| """teacher rows for teacher.py::lists_entry (glue, adapted from our build drivers): one row per kept take of each teacher voice, | |
| {path (on the data volume, mounted at /renders), ids (Kokoro ids of the take's text from frontend/), spk (voice index in | |
| config/teacher.json teacher_voices), split, clip, seconds}. | |
| usage: python3 make_rows.py <kept dir> <ids map.json> [out=work/teacher-rows.jsonl] | |
| kept dir : the filter step's kept lists, one <voice> file per voice (name pattern = config/packs.json kept_file), rows with | |
| clip, text, path (relative to the data volume), seconds and optionally split ("train" / "val" / "validation") | |
| ids map : {text: [Kokoro ids]} made with the release front end (frontend/, CMUdict + overrides + g2p -> Kokoro ids; no espeak) | |
| Rows without a split field: every <val_every>-th take of a voice goes to val (config/teacher.json).""" | |
| import json | |
| import sys | |
| from pathlib import Path | |
| HERE = Path(__file__).resolve().parent | |
| C = {k: v for k, v in json.loads((HERE / "config/teacher.json").read_text()).items() if not k.startswith("_")} | |
| P = {k: v for k, v in json.loads((HERE / "config/packs.json").read_text()).items() if not k.startswith("_")} | |
| kept, idmap = Path(sys.argv[1]), json.loads(Path(sys.argv[2]).read_text()) | |
| out = Path(sys.argv[3] if len(sys.argv) > 3 else "work/teacher-rows.jsonl") | |
| rows, missing = [], 0 | |
| for spk, v in enumerate(C["teacher_voices"]): | |
| for k, r in enumerate(json.loads(l) for l in (kept / P["kept_file"].format(voice=v)).read_text().splitlines() if l.strip()): | |
| if r["text"] not in idmap: | |
| missing += 1 | |
| continue | |
| split = {"validation": "val"}.get(r.get("split"), r.get("split")) or ("val" if k % C["val_every"] == 0 else "train") | |
| rows.append(dict(path=f"/renders/{r['path']}", ids=idmap[r["text"]], spk=spk, split=split, clip=r["clip"], seconds=r["seconds"])) | |
| out.parent.mkdir(parents=True, exist_ok=True) | |
| out.write_text("".join(json.dumps(r) + "\n" for r in rows)) | |
| print("rows", len(rows), "val", sum(r["split"] == "val" for r in rows), "texts without ids", missing, "->", out) | |