Views
No views yet
TTS package requires a patched installation. Clone the fine-tuning repo and install its dependencies:1git clone https://github.com/Alexgichamba/XTTSv2-Finetuning-for-New-Languages.git
2cd XTTSv2-Finetuning-for-New-Languages
3pip install -r requirements.txt1import torch
2import torchaudio
3from TTS.tts.configs.xtts_config import XttsConfig
4from TTS.tts.models.xtts import Xtts
5
6# Load model
7config = XttsConfig()
8config.load_json("config.json")
9model = Xtts.init_from_config(config)
10model.load_checkpoint(config, checkpoint_path="model.pth", vocab_path="vocab.json", use_deepspeed=False)
11model.to("cuda" if torch.cuda.is_available() else "cpu")
12
13# Get speaker embedding from a reference audio clip
14gpt_cond_latent, speaker_embedding = model.get_conditioning_latents(
15 audio_path="reference_speaker.wav",
16 gpt_cond_len=model.config.gpt_cond_len,
17 max_ref_length=model.config.max_ref_len,
18 sound_norm_refs=model.config.sound_norm_refs,
19)
20
21# Synthesize
22result = model.inference(
23 text="Ndashaka amazi n'ibiryo",
24 language="rw",
25 gpt_cond_latent=gpt_cond_latent,
26 speaker_embedding=speaker_embedding,
27 temperature=0.1,
28 length_penalty=1.0,
29 repetition_penalty=10.0,
30 top_k=10,
31 top_p=0.3,
32)
33
34torchaudio.save("output.wav", torch.tensor(result["wav"]).unsqueeze(0), 24000)1python inference.py \
2 -t "Ndashaka amazi n'ibiryo" \
3 -s reference_speaker.wav \
4 -l rw \
5 -o output.wavmodel.pth — Model weights (85k-step checkpoint)config.json — Model configurationvocab.json — Tokenizer vocabularyinference.py — Standalone inference scriptreference_speaker.wav — Sample reference audio for voice cloning