Views
No views yet
nn.Embedding(n_speakers, 256) — learned lookupaudio, text, speaker_id, gendertrain split → automatically split 95/5 for train/val| Component | Details |
|---|---|
| Architecture | VITS (multi-speaker) |
| Language | Hausa (hau) |
| Sampling Rate | 16,000 Hz |
| Hidden Size | 192 |
| FFN Dim | 768 |
| Attention Heads | 2 |
| Transformer Layers | 6 |
| Speaker Embedding Dim | 256 |
| Generator Params | ~40M |
| Discriminator Params | ~47M |
| Upsample Rates | [8, 8, 2, 2] |
| Hyperparameter | Value |
|---|---|
| Learning Rate | 2e-4 |
| Optimizer | AdamW (β₁=0.8, β₂=0.99) |
| LR Schedule | ExponentialLR (γ=0.999875) |
| Batch Size | 16 |
| Epochs | 200 |
| Mel Loss Weight | 45 |
| KL Loss Weight | 1.0 |
| FP16 | ✅ |
| Segment Size | 8192 samples |
| Max Audio Length | 10 seconds |
pip install -r requirements.txt1# Single GPU
2python train_hausa_tts.py
3
4# The script will:
5# 1. Load the dataset from HuggingFace Hub
6# 2. Auto-detect speakers and remap IDs
7# 3. Split into train/val (95/5)
8# 4. Load text encoder from facebook/mms-tts-hau
9# 5. Train with full VITS losses
10# 6. Push final model to Hub1# Recommended: A10G (24GB VRAM) or better
2huggingface-cli jobs run train_hausa_tts.py \
3 --hardware a10g-large \
4 --timeout 8h \
5 --dependencies torch torchaudio transformers datasets librosa trackio huggingface_hub soundfile numpy scipy1import torch
2import json
3
4# Load the trained model
5checkpoint = torch.load("generator.pth", map_location="cpu")
6config = json.load(open("config.json"))
7
8# Rebuild the model (copy SynthesizerTrn class from train_hausa_tts.py)
9# Or import it:
10# from train_hausa_tts import SynthesizerTrn
11
12model = SynthesizerTrn(
13 n_vocab=config["vocab_size"],
14 spec_channels=config["n_fft"] // 2 + 1,
15 segment_size=config["segment_size"] // config["hop_length"],
16 inter_channels=config["inter_channels"],
17 hidden_channels=config["hidden_size"],
18 filter_channels=config["filter_channels"],
19 n_heads=config["n_heads"],
20 n_layers=config["n_layers"],
21 kernel_size=config["kernel_size"],
22 p_dropout=config["p_dropout"],
23 resblock_kernel_sizes=config["resblock_kernel_sizes"],
24 resblock_dilation_sizes=config["resblock_dilation_sizes"],
25 upsample_rates=config["upsample_rates"],
26 upsample_initial_channel=config["upsample_initial_channel"],
27 upsample_kernel_sizes=config["upsample_kernel_sizes"],
28 n_speakers=config["n_speakers"],
29 gin_channels=config["gin_channels"],
30 use_sdp=True,
31)
32model.load_state_dict(checkpoint["model"])
33model.eval()
34
35# Tokenize text
36vocab = config["vocab"]
37def text_to_ids(text, vocab, add_blank=True):
38 text = text.lower().strip()
39 ids = [vocab[c] for c in text if c in vocab]
40 if add_blank:
41 new_ids = [0] * (len(ids) * 2 + 1)
42 new_ids[1::2] = ids
43 ids = new_ids
44 return ids
45
46# Generate speech
47text = "Sannu da zuwa"
48text_ids = torch.LongTensor([text_to_ids(text, vocab)])
49text_lengths = torch.LongTensor([text_ids.size(1)])
50speaker_id = torch.LongTensor([0]) # Choose speaker
51
52with torch.no_grad():
53 audio, _, _, _ = model.infer(text_ids, text_lengths, speaker_id)
54 audio = audio.squeeze().cpu().numpy()
55
56# Save
57import soundfile as sf
58sf.write("output.wav", audio, 16000)1@inproceedings{kim2021conditional,
2 title={Conditional variational autoencoder with adversarial learning for end-to-end text-to-speech},
3 author={Kim, Jaehyeon and Kong, Jungil and Son, Juhee},
4 booktitle={International Conference on Machine Learning},
5 year={2021}
6}
7
8@article{pratap2023scaling,
9 title={Scaling Speech Technology to 1,000+ Languages},
10 author={Pratap, Vineel and others},
11 journal={arXiv preprint arXiv:2305.13516},
12 year={2023}
13}