File size: 3,426 Bytes
dd9bd18
 
 
34f65c0
dd9bd18
34f65c0
dd9bd18
34f65c0
dd9bd18
34f65c0
dd9bd18
34f65c0
dd9bd18
34f65c0
dd9bd18
 
 
 
 
 
 
 
 
 
 
 
34f65c0
 
dd9bd18
 
34f65c0
 
dd9bd18
34f65c0
dd9bd18
 
 
34f65c0
 
dd9bd18
 
 
34f65c0
 
dd9bd18
34f65c0
dd9bd18
 
34f65c0
dd9bd18
 
34f65c0
dd9bd18
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34f65c0
 
 
 
dd9bd18
34f65c0
 
 
dd9bd18
 
34f65c0
dd9bd18
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# YarnGPT ๐ŸŽ™๏ธ
![image/png](https://github.com/saheedniyi02/yarngpt/blob/main/notebooks%2Faudio_0c026c21-f432-4d20-a86b-899a10d9ed60.webp)
A text-to-speech model generating natural Nigerian-accented English speech. Built on pure language modeling without external adapters.

Web Url: https://yarngpt.co/

## Quick Start

```python

!git clone https://github.com/saheedniyi02/yarngpt.git

pip install outetts uroman

import os
import re
import json
import torch
import inflect
import random
import uroman as ur
import numpy as np
import torchaudio
import IPython
from transformers import AutoModelForCausalLM, AutoTokenizer
from outetts.wav_tokenizer.decoder import WavTokenizer


!wget https://huggingface.co/novateur/WavTokenizer-medium-speech-75token/resolve/main/wavtokenizer_mediumdata_frame75_3s_nq1_code4096_dim512_kmeans200_attn.yaml
!gdown 1-ASeEkrn4HY49yZWHTASgfGFNXdVnLTt


from yarngpt.audiotokenizer import AudioTokenizerV2

tokenizer_path="saheedniyi/YarnGPT2"
wav_tokenizer_config_path="/content/wavtokenizer_mediumdata_frame75_3s_nq1_code4096_dim512_kmeans200_attn.yaml"
wav_tokenizer_model_path = "/content/wavtokenizer_large_speech_320_24k.ckpt"


audio_tokenizer=AudioTokenizerV2(
    tokenizer_path,wav_tokenizer_model_path,wav_tokenizer_config_path
    )


model = AutoModelForCausalLM.from_pretrained(tokenizer_path,torch_dtype="auto").to(audio_tokenizer.device)

#change the text
text="The election was won by businessman and politician, Moshood Abiola, but Babangida annulled the results, citing concerns over national security."

# change the language and voice
prompt=audio_tokenizer.create_prompt(text,lang="english",speaker_name="idera")

input_ids=audio_tokenizer.tokenize_prompt(prompt)

output  = model.generate(
            input_ids=input_ids,
            temperature=0.1,
            repetition_penalty=1.1,
            max_length=4000,
            #num_beams=5,# using a beam size helps for the local languages but not english
        )

codes=audio_tokenizer.get_codes(output)
audio=audio_tokenizer.get_audio(codes)
IPython.display.Audio(audio,rate=24000)
torchaudio.save(f"Sample.wav", audio, sample_rate=24000)

```

## Features

- ๐Ÿ—ฃ๏ธ 12 preset voices (6 male, 6 female)
- ๐ŸŽฏ Trained on 2000+ hours of Nigerian audio
- ๐Ÿ”Š 24kHz high-quality audio output
- ๐Ÿš€ Simple API for quick integration
- ๐Ÿ“ Support for long-form text

## Available Voices
- Female: zainab, idera, regina, chinenye, joke, remi
- Male: jude, tayo, umar, osagie, onye, emma

## Examples

Check out our [demo notebook](link-to-notebook) or listen to [sample outputs](https://huggingface.co/saheedniyi/YarnGPT/tree/main/audio).

## Model Details

- Base: [HuggingFaceTB/SmolLM2-360M](https://huggingface.co/HuggingFaceTB/SmolLM2-360M)
- Training: 5 epochs on A100 GPU
- Data: Nigerian movies, podcasts, and open-source audio
- Architecture: Pure language modeling approach

## Limitations

- English to Nigerian-accented English only
- May not capture all Nigerian accent variations
- Training data includes auto-generated content

## Citation

```bibtex
@misc{yarngpt2025,
  author = {Saheed Azeez},
  title = {YarnGPT: Nigerian-Accented English Text-to-Speech Model},
  year = {2025},
  publisher = {Hugging Face}
}
```

## License
MIT

## Acknowledgments
Built with [WavTokenizer](https://github.com/jishengpeng/WavTokenizer) and inspired by [OuteTTS](https://huggingface.co/OuteAI/OuteTTS-0.2-500M/).