Run this model with HF Jobs

Run AlexeyNe/kitten-tts-2-mini-coreml on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.

Paste one of these prompts into your coding agent:

Fine-tune on my dataset

Use HF Jobs to fine-tune https://huggingface.co/AlexeyNe/kitten-tts-2-mini-coreml. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.

Run batch inference

Use HF Jobs to run batch inference with https://huggingface.co/AlexeyNe/kitten-tts-2-mini-coreml on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
kitten-tts-2-mini-coreml / scripts /generator_buckets.py
AlexeyNe's picture
Kitten TTS 2 Mini for Core ML: graphs, bucket generator, voices, eSpeak NG data, export scripts
e66a8be verified
Raw History Blame Contribute Delete
1.98 kB
# Генератор бакетами — один мультифункциональный ML Program, функции bN
# (N — кадры x_pre, 80 в секунду речи), веса общие.
# KOKORO=1 GEN_GAIN=1.5 BUCKETS=240,400,640,960,1600,2400 NAME=kokoro_generator_buckets python generator_buckets.py <папка>
# BUCKETS=240,400,640,960,1600 NAME=kitten_generator_buckets python generator_buckets.py <папка>
# fp16, суммы нормализации — в fp32 (иначе переполнение на длинных бакетах).
import sys, os, numpy as np, torch, coremltools as ct
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))); OUT = sys.argv[1]
from masked_generator import MaskedGenerator
BUCKETS = [int(b) for b in os.environ.get("BUCKETS", "240,400,640,960,1600").split(",")]
PREC = ct.transform.FP16ComputePrecision(op_selector=lambda op: op.op_type != "reduce_sum")
mg = MaskedGenerator().eval(); desc = ct.utils.MultiFunctionDescriptor()
for N in BUCKETS:
ex = (torch.randn(1, 512, N), torch.randn(1, 256), torch.randn(1, 22, 60 * N + 1), torch.tensor([N - 3], dtype=torch.int32))
with torch.no_grad(): tr = torch.jit.trace(mg, ex, check_trace=False)
m = ct.convert(tr, inputs=[ct.TensorType('x_pre', shape=(1, 512, N)), ct.TensorType('ref_s', shape=(1, 256)),
ct.TensorType('har', shape=(1, 22, 60 * N + 1)), ct.TensorType('valid', shape=(1,), dtype=np.int32)],
outputs=[ct.TensorType('waveform')], minimum_deployment_target=ct.target.iOS18,
compute_precision=PREC, convert_to='mlprogram')
path = f'{OUT}/gen_b{N}.mlpackage'; m.save(path); desc.add_function(path, src_function_name='main', target_function_name=f'b{N}'); print('bucket', N, flush=True)
desc.default_function_name = 'b400'
ct.utils.save_multifunction(desc, f"{OUT}/{os.environ.get('NAME', 'kitten_generator_buckets')}.mlpackage"); print('saved multifunction')