indic-f5-mlx / example.py
yogenghodke's picture
Upload example.py with huggingface_hub
3285bd5 verified
Raw
History Blame Contribute Delete
1.12 kB
"""Minimal IndicF5-MLX example.
Prereqs:
1. Apple-Silicon Mac
2. `huggingface-cli login` and accept the gate at https://huggingface.co/ai4bharat/IndicF5
3. A 24 kHz mono reference clip + its transcript
"""
import soundfile as sf
from indic_f5_mlx import load_indicf5, generate
REF_AUDIO = "reference_24k_mono.wav" # ~5-10s clean natural voice
REF_TEXT = "transcript of the reference clip in its language"
# Numbers spelled out as words (३७० -> तीनशे सत्तर), not digits.
TEXT = ("भारतीय संविधानाच्या अनुच्छेद तीनशे सत्तर नुसार, सव्वीस जानेवारी एकोणीसशे पन्नास रोजी "
"प्रजासत्ताक भारताची स्थापना झाली.")
model, _ = load_indicf5() # downloads + converts ai4bharat/IndicF5
audio = generate(model, ref_audio_path=REF_AUDIO, ref_text=REF_TEXT, text=TEXT, steps=16)
sf.write("out.wav", audio, 24000)
print(f"wrote out.wav ({len(audio)/24000:.1f}s)")