Download recipe/render/make_singles.py from KaleComputer/kale-tts-1-tiny: direct link, hf CLI and curl.
- Browser
- Download file 1.92 kB
-
https://huggingface.co/KaleComputer/kale-tts-1-tiny/resolve/main/recipe/render/make_singles.py
- Command line
-
hf download hf://KaleComputer/kale-tts-1-tiny/recipe/render/make_singles.py
-
curl -L -o make_singles.py https://huggingface.co/KaleComputer/kale-tts-1-tiny/resolve/main/recipe/render/make_singles.py
1.92 kB
| # SPDX-License-Identifier: Apache-2.0 | |
| # Copyright 2026 Kale | |
| """Single-sentence pool (15 Nov 2026): every sentence (3-28 words, first occurrence only) of the text pool's items (make_text.py | |
| output: its singles + every sentence of its passages, ban list already applied there). First used for m3's second batch (his kept | |
| takes were 86 % singles; passages failed pace / creak more often); make_jobs.py samples every later voice's singles from it. | |
| python3 -I make_singles.py work/jobs-v7.jsonl work/singles.jsonl "<Maya-1 description>" [--voice m3] [--start 200000] | |
| Output rows: clip <voice>_<start + n>, voice, text, description, kind "single", n_sent 1, source "pool sentence". | |
| Trimmed from the original: it also rebuilt each sentence's token ids through our earlier text front end's character table; ids now | |
| come from the release front end (frontend/) when the train step prepares features.""" | |
| import argparse | |
| import json | |
| import re | |
| from pathlib import Path | |
| ap = argparse.ArgumentParser() | |
| ap.add_argument("pool"); ap.add_argument("out"); ap.add_argument("description") | |
| ap.add_argument("--voice", default="m3"); ap.add_argument("--start", type=int, default=200000) | |
| A = ap.parse_args() | |
| jobs = [json.loads(l) for l in Path(A.pool).read_text().splitlines() if l.strip()] | |
| split = lambda t: [s for s in re.split(r"(?<=[.!?])\s+", t.strip()) if s] # noqa: E731 | |
| sents = [] | |
| seen = set() | |
| for j in jobs: | |
| for s in split(j["text"]): | |
| if s not in seen and 3 <= len(s.split()) <= 28: | |
| seen.add(s); sents.append(s) | |
| out = [] | |
| for n, s in enumerate(sents): | |
| c = f"{A.voice}_{A.start + n:06d}" | |
| out.append(dict(clip=c, voice=A.voice, text=s, description=A.description, mood=None, tagname=None, kind="single", n_sent=1, source="pool sentence")) | |
| Path(A.out).parent.mkdir(parents=True, exist_ok=True) | |
| Path(A.out).write_text("".join(json.dumps(x) + "\n" for x in out)) | |
| print(len(out), "single-sentence jobs") | |