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.
Instructions to use AlexeyNe/kitten-tts-2-mini-coreml with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- KittenTTS
How to use AlexeyNe/kitten-tts-2-mini-coreml with KittenTTS:
from kittentts import KittenTTS m = KittenTTS("AlexeyNe/kitten-tts-2-mini-coreml") audio = m.generate("This high quality TTS model works without a GPU") # Save the audio import soundfile as sf sf.write('output.wav', audio, 24000) - Notebooks
- Google Colab
- Kaggle
Download scripts/kitten_pack.py from AlexeyNe/kitten-tts-2-mini-coreml: direct link, hf CLI and curl.
- Browser
- Download file 4.17 kB
-
https://huggingface.co/AlexeyNe/kitten-tts-2-mini-coreml/resolve/main/scripts/kitten_pack.py
- Command line
-
hf download hf://AlexeyNe/kitten-tts-2-mini-coreml/scripts/kitten_pack.py
-
curl -L -o kitten_pack.py https://huggingface.co/AlexeyNe/kitten-tts-2-mini-coreml/resolve/main/scripts/kitten_pack.py
4.17 kB
| # Пакет весов Kitten TTS 2 Mini для Core ML — папка в том виде, в каком её | |
| # качает приложение (KittenPack в KokoroKit): скомпилированные графы, | |
| # возбуждение hn-NSF, словарь фонем, голоса по файлу и данные eSpeak NG | |
| # языков модели (кроме японского: его Kitten читает не eSpeak'ом). | |
| # python kitten_pack.py <папка пакета> | |
| # Окружение — как у network.py, плюс `pip install --no-deps espeakng_loader==0.2.4` | |
| # (данные eSpeak NG 1.52) и Xcode (coremlcompiler). | |
| import sys, os, json, glob, shutil, subprocess, numpy as np | |
| HERE = os.path.dirname(os.path.abspath(__file__)) | |
| OUT = os.path.abspath(sys.argv[1]) | |
| SNAP = glob.glob(os.path.expanduser('~/.cache/huggingface/hub/models--KittenML--kitten-tts-2-mini/snapshots/8e89ae2a718ee4bb893c67d67657e520e6112faf'))[0] | |
| LANGUAGES = ['en', 'de', 'es', 'it', 'pt', 'ru', 'hi', 'da', 'fi', 'fr', 'ko', 'nl', 'sv', 'sw', 'tr'] | |
| # Голос eSpeak каждого языка — как у Kitten (frontend/phonemize_v1.ESPEAK_VOICE), | |
| # путь файла голоса в espeak-ng-data/lang. | |
| ESPEAK = {'en': 'gmw/en-US', 'de': 'gmw/de', 'es': 'roa/es', 'it': 'roa/it', 'pt': 'roa/pt-BR', 'ru': 'zle/ru', | |
| 'hi': 'inc/hi', 'da': 'gmq/da', 'fi': 'urj/fi', 'fr': 'roa/fr', 'ko': 'ko', 'nl': 'gmw/nl', | |
| 'sv': 'gmq/sv', 'sw': 'bnt/sw', 'tr': 'trk/tr'} | |
| os.makedirs(OUT, exist_ok=True) | |
| # Графы: длительности и интонация гибкой длины, генератор бакетами. | |
| work = os.path.join(OUT, '.export'); os.makedirs(work, exist_ok=True) | |
| env = dict(os.environ); env.pop('KOKORO', None) | |
| subprocess.run([sys.executable, os.path.join(HERE, 'kitten_graphs.py'), work], check=True, env=env) | |
| subprocess.run([sys.executable, os.path.join(HERE, 'generator_buckets.py'), work], check=True, | |
| env={**env, 'BUCKETS': '240,400,640,960,1600,2400', 'NAME': 'kitten_generator_buckets', 'GEN_GAIN': '1'}) | |
| for name in ['kitten_duration', 'kitten_prosody', 'kitten_generator_buckets']: | |
| shutil.rmtree(os.path.join(OUT, f'{name}.mlmodelc'), ignore_errors=True) | |
| subprocess.run(['xcrun', 'coremlcompiler', 'compile', os.path.join(work, f'{name}.mlpackage'), OUT], check=True, stdout=subprocess.DEVNULL) | |
| sys.path.insert(0, HERE) | |
| os.environ.pop('KOKORO', None) | |
| import network as ek | |
| lin = ek.net['decoder'].generator.m_source.l_linear | |
| json.dump({'linear_weights': lin.weight.detach().reshape(-1).tolist(), 'linear_bias': float(lin.bias.detach().reshape(-1)[0])}, | |
| open(os.path.join(OUT, 'hnsf_weights.json'), 'w')) | |
| # Словарь — в формате tokenizer.json Kokoro (KokoroAssets). | |
| vocab = json.load(open(os.path.join(SNAP, 'vocab.json'))) | |
| json.dump({'model': {'vocab': vocab}}, open(os.path.join(OUT, 'tokenizer.json'), 'w'), ensure_ascii=False) | |
| # Голоса: свои дикторы каждого языка, файл `voices/<язык>_<голос>.bin` — 510 × 256 float32. | |
| config = json.load(open(os.path.join(SNAP, 'config.json'))) | |
| os.makedirs(os.path.join(OUT, 'voices'), exist_ok=True) | |
| for lang in LANGUAGES: | |
| native = [v['key'] for v in config['voices'][lang] if lang == 'en' or v['description'].startswith(('Female', 'Male'))] | |
| with np.load(os.path.join(SNAP, config['languages'][lang]['voices'])) as z: | |
| for key in native: | |
| table = z[key].astype('<f4'); assert table.shape == (510, 256) | |
| table.tofile(os.path.join(OUT, 'voices', f'{lang}_{key}.bin')) | |
| # eSpeak NG: общие файлы, голос и словарь каждого языка. | |
| import espeakng_loader | |
| src = espeakng_loader.get_data_path(); dst = os.path.join(OUT, 'espeak-ng-data') | |
| shutil.rmtree(dst, ignore_errors=True) | |
| files = ['phontab', 'phonindex', 'phondata', 'intonations'] + [f'{lang}_dict' for lang in LANGUAGES] + [f'lang/{p}' for p in ESPEAK.values()] | |
| for f in files: | |
| os.makedirs(os.path.dirname(os.path.join(dst, f)), exist_ok=True) | |
| shutil.copy(os.path.join(src, f), os.path.join(dst, f)) | |
| shutil.rmtree(work) | |
| print('pack ready:', OUT) | |