Views
No views yet
pip install TTS==0.22.0 transformers==4.37.2 torch==2.1.01import torch, soundfile as sf
2from TTS.tts.configs.xtts_config import XttsConfig
3from TTS.tts.models.xtts import Xtts
4from huggingface_hub import snapshot_download
5
6# Download model
7model_dir = snapshot_download("your-username/xtts-v2-child-voice-finetuned")
8
9# Load
10config = XttsConfig()
11config.load_json(f"{model_dir}/config.json")
12model = Xtts.init_from_config(config)
13model.load_checkpoint(config, checkpoint_dir=model_dir, eval=True)
14model.cuda()
15
16# Generate child voice speech
17out = model.synthesize(
18 "Hello! My name is Lily. I love playing with my toys!",
19 config,
20 speaker_wav=f"{model_dir}/reference_child.wav",
21 language="en"
22)
23sf.write("output.wav", out["wav"], 24000)