File size: 1,122 Bytes
3285bd5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
"""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)")