Instructions to use ampixa/tiny-swar with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- F5-TTS
How to use ampixa/tiny-swar with F5-TTS:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Notebooks
- Google Colab
- Kaggle
File size: 1,510 Bytes
728171b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | """Load Tiny Swar (16-block F5-TTS DiT) with the stock f5-tts package.
from load_tiny_swar import load
tts = load("model.safetensors", "vocab.txt", device="cuda")
tts.infer(ref_file="ref.wav", ref_text="...", gen_text="नमस्ते, तपाईंलाई कस्तो छ?",
nfe_step=16, cfg_strength=2.0, seed=0, file_wave="out.wav")
f5-tts builds F5TTS_Base with 22 blocks from its YAML config. This helper sets depth to 16 for that one
config load, then checks that the built model really has 16 blocks.
"""
import json
import types
from pathlib import Path
import f5_tts.api as api
DEPTH = 16
def load(ckpt="model.safetensors", vocab="vocab.txt", device="cuda", vocoder_local_path=None, fp32=True):
cfg_path = Path(ckpt).with_name("config.json")
depth = json.loads(cfg_path.read_text())["arch"]["depth"] if cfg_path.exists() else DEPTH
real = api.OmegaConf
def _load(path):
cfg = real.load(path)
cfg.model.arch.depth = depth
return cfg
api.OmegaConf = types.SimpleNamespace(load=_load)
try:
tts = api.F5TTS(model="F5TTS_Base", ckpt_file=str(ckpt), vocab_file=str(vocab), device=device,
vocoder_local_path=vocoder_local_path)
finally:
api.OmegaConf = real
built = len(tts.ema_model.transformer.transformer_blocks)
if built != depth:
raise RuntimeError(f"built {built} blocks, expected {depth}")
if fp32:
tts.ema_model.float()
return tts
|