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
Download load_tiny_swar.py from ampixa/tiny-swar: direct link, hf CLI and curl.
- Browser
- Download file 1.51 kB
-
https://huggingface.co/ampixa/tiny-swar/resolve/main/load_tiny_swar.py
- Command line
-
hf download hf://ampixa/tiny-swar/load_tiny_swar.py
-
curl -L -o load_tiny_swar.py https://huggingface.co/ampixa/tiny-swar/resolve/main/load_tiny_swar.py
1.51 kB
| """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 | |