Views
No views yet
hau)✓ Preserved:
- Text encoder (language understanding)
- Model tokenizer
- Base architecture
✗ Reinitialized:
- Posterior encoder (speaker characteristics)
- Flow-based transformations
- Decoder/generator
- Duration predictor
+ Added:
- Speaker embedding layer (2x256)1# Clone fine-tuning repository
2git clone https://github.com/ylacombe/finetune-hf-vits.git
3cd finetune-hf-vits
4
5# Install requirements
6pip install -r requirements.txt
7
8# Build monotonic alignment search
9cd monotonic_align
10python setup.py build_ext --inplace
11cd ..
12
13# Run fine-tuning (adjust parameters as needed)
14accelerate launch run_vits_finetuning.py \
15 --model_name_or_path "suleiman2003/mms-tts-hau-2speaker" \
16 --dataset_name "your-dataset" \
17 --output_dir "./output" \
18 --num_train_epochs 100 \
19 --learning_rate 2e-4 \
20 --warmup_ratio 0.0 \
21 --per_device_train_batch_size 8 \
22 --speaker_id_column_name "speaker_id"1from transformers import VitsModel, VitsTokenizer, set_seed
2import torch
3import scipy
4
5# Load fine-tuned model
6model = VitsModel.from_pretrained("suleiman2003/mms-tts-hau-2speaker")
7tokenizer = VitsTokenizer.from_pretrained("suleiman2003/mms-tts-hau-2speaker")
8
9# Prepare input
10text = "Sannu, yaya kake?" # "Hello, how are you?" in Hausa
11inputs = tokenizer(text, return_tensors="pt")
12
13# Generate speech for speaker 0
14set_seed(42)
15with torch.no_grad():
16 outputs = model(**inputs, speaker_id=0)
17
18# Save audio
19audio = outputs.waveform[0].cpu().numpy()
20scipy.io.wavfile.write("output_speaker0.wav", rate=16000, data=audio)
21
22# Generate speech for speaker 1
23with torch.no_grad():
24 outputs = model(**inputs, speaker_id=1)
25audio = outputs.waveform[0].cpu().numpy()
26scipy.io.wavfile.write("output_speaker1.wav", rate=16000, data=audio)1# Example dataset format
2{
3 "audio": [<audio_path_1>, <audio_path_2>, ...],
4 "text": ["Yaya kake?", "Ina kwana?", ...],
5 "speaker_id": [0, 1, 0, 1, ...] # Speaker labels
6}1@article{pratap2023mms,
2 title={Scaling Speech Technology to 1,000+ Languages},
3 author={Pratap, Vineel and Tjandra, Andros and Shi, Bowen and others},
4 journal={arXiv preprint arXiv:2305.13516},
5 year={2023}
6}
7
8@inproceedings{kim2021vits,
9 title={Conditional variational autoencoder with adversarial learning for end-to-end text-to-speech},
10 author={Kim, Jaehyeon and Kong, Jungil and Son, Juhee},
11 booktitle={International Conference on Machine Learning},
12 pages={5530--5540},
13 year={2021},
14 organization={PMLR}
15}