saheedniyi commited on
Commit
00067b9
·
verified ·
1 Parent(s): cbf0114

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +217 -141
README.md CHANGED
@@ -1,199 +1,275 @@
1
  ---
2
  library_name: transformers
3
- tags: []
 
 
 
 
 
 
 
4
  ---
5
 
6
- # Model Card for Model ID
 
7
 
8
- <!-- Provide a quick summary of what the model is/does. -->
9
 
 
 
 
 
 
 
 
 
 
 
 
10
 
 
11
 
12
- ## Model Details
13
 
14
- ### Model Description
 
 
 
 
 
 
 
 
 
 
 
 
15
 
16
- <!-- Provide a longer summary of what this model is. -->
17
 
18
- This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
 
 
19
 
20
- - **Developed by:** [More Information Needed]
21
- - **Funded by [optional]:** [More Information Needed]
22
- - **Shared by [optional]:** [More Information Needed]
23
- - **Model type:** [More Information Needed]
24
- - **Language(s) (NLP):** [More Information Needed]
25
- - **License:** [More Information Needed]
26
- - **Finetuned from model [optional]:** [More Information Needed]
27
 
28
- ### Model Sources [optional]
 
29
 
30
- <!-- Provide the basic links for the model. -->
 
 
 
 
 
 
 
 
 
 
 
 
 
31
 
32
- - **Repository:** [More Information Needed]
33
- - **Paper [optional]:** [More Information Needed]
34
- - **Demo [optional]:** [More Information Needed]
35
 
36
- ## Uses
 
 
37
 
38
- <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
 
 
 
39
 
40
- ### Direct Use
 
 
 
41
 
42
- <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
43
 
44
- [More Information Needed]
45
 
46
- ### Downstream Use [optional]
 
47
 
48
- <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
 
49
 
50
- [More Information Needed]
 
51
 
52
- ### Out-of-Scope Use
 
 
 
 
 
 
53
 
54
- <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
 
55
 
56
- [More Information Needed]
 
57
 
58
- ## Bias, Risks, and Limitations
59
-
60
- <!-- This section is meant to convey both technical and sociotechnical limitations. -->
61
-
62
- [More Information Needed]
63
 
64
- ### Recommendations
 
 
65
 
66
- <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
67
 
68
- Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
 
 
 
 
 
 
69
 
70
- ## How to Get Started with the Model
71
 
72
- Use the code below to get started with the model.
73
 
74
- [More Information Needed]
75
 
76
- ## Training Details
77
 
78
- ### Training Data
79
 
80
- <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
81
 
82
- [More Information Needed]
83
 
84
- ### Training Procedure
85
 
86
- <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
87
 
88
- #### Preprocessing [optional]
89
 
90
- [More Information Needed]
91
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92
 
93
  #### Training Hyperparameters
94
-
95
- - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
96
-
97
- #### Speeds, Sizes, Times [optional]
98
-
99
- <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
100
-
101
- [More Information Needed]
102
-
103
- ## Evaluation
104
-
105
- <!-- This section describes the evaluation protocols and provides the results. -->
106
-
107
- ### Testing Data, Factors & Metrics
108
-
109
- #### Testing Data
110
-
111
- <!-- This should link to a Dataset Card if possible. -->
112
-
113
- [More Information Needed]
114
-
115
- #### Factors
116
-
117
- <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
118
-
119
- [More Information Needed]
120
-
121
- #### Metrics
122
-
123
- <!-- These are the evaluation metrics being used, ideally with a description of why. -->
124
-
125
- [More Information Needed]
126
-
127
- ### Results
128
-
129
- [More Information Needed]
130
-
131
- #### Summary
132
-
133
-
134
-
135
- ## Model Examination [optional]
136
-
137
- <!-- Relevant interpretability work for the model goes here -->
138
-
139
- [More Information Needed]
140
-
141
- ## Environmental Impact
142
-
143
- <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
144
-
145
- Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
146
-
147
- - **Hardware Type:** [More Information Needed]
148
- - **Hours used:** [More Information Needed]
149
- - **Cloud Provider:** [More Information Needed]
150
- - **Compute Region:** [More Information Needed]
151
- - **Carbon Emitted:** [More Information Needed]
152
-
153
- ## Technical Specifications [optional]
154
-
155
- ### Model Architecture and Objective
156
-
157
- [More Information Needed]
158
-
159
- ### Compute Infrastructure
160
-
161
- [More Information Needed]
162
 
163
  #### Hardware
164
 
165
- [More Information Needed]
166
 
167
  #### Software
168
 
169
- [More Information Needed]
170
-
171
- ## Citation [optional]
172
-
173
- <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
174
 
175
- **BibTeX:**
 
 
 
 
 
176
 
177
- [More Information Needed]
178
-
179
- **APA:**
180
-
181
- [More Information Needed]
182
-
183
- ## Glossary [optional]
184
-
185
- <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
186
-
187
- [More Information Needed]
188
 
189
- ## More Information [optional]
190
 
191
- [More Information Needed]
 
 
 
 
 
 
 
 
192
 
193
- ## Model Card Authors [optional]
194
 
195
- [More Information Needed]
 
 
196
 
197
- ## Model Card Contact
198
 
199
- [More Information Needed]
 
 
 
 
 
1
  ---
2
  library_name: transformers
3
+ license: apache-2.0
4
+ datasets:
5
+ - intronhealth/afrispeech-200
6
+ language:
7
+ - en
8
+ base_model:
9
+ - HuggingFaceTB/SmolLM2-360M
10
+ pipeline_tag: text-to-speech
11
  ---
12
 
13
+ # YarnGPT-local
14
+ ![image/png](https://huggingface.co/saheedniyi/YarnGPT/resolve/main/audio/logo.webp)
15
 
16
+ ## Table of Contents
17
 
18
+ 1. [Model Summary](#model-summary)
19
+ 2. [Model Description](#model-description)
20
+ 3. [Bias, Risks, and Limitations](#bias-risks-and-limitations)
21
+ - [Recommendations](#recommendations)
22
+ 4. [Speech Samples](#speech-samples)
23
+ 5. [Training](#training)
24
+ 6. [Future Improvements](#future-improvements)
25
+ 7. [Citation](#citation)
26
+ 8. [Credits & References](#credits--references)
27
+
28
+ ## Model Summary
29
 
30
+ YarnGPT is a text-to-speech (TTS) model designed to synthesize Nigerian-accented English leveraging pure language modelling without external adapters or complex architectures, offering high-quality, natural, and culturally relevant speech synthesis for diverse applications.
31
 
 
32
 
33
+ #### How to use (Colab)
34
+ The model can generate audio on its own but its better to use a voice to prompt the model, there are about 11 voices supported by default (6 males and 5 females ):
35
+ - zainab
36
+ - jude
37
+ - tayo
38
+ - remi
39
+ - idera
40
+ - regina
41
+ - chinenye
42
+ - umar
43
+ - osagie
44
+ - joke
45
+ - emma (the names do not correlate to any tribe or accent)
46
 
 
47
 
48
+ ```python
49
+ # clone the YarnGPT repo to get access to the `audiotokenizer`
50
+ !git clone https://github.com/saheedniyi02/yarngpt.git
51
 
 
 
 
 
 
 
 
52
 
53
+ # install some necessary libraries
54
+ !pip install outetts==0.2.3 uroman
55
 
56
+ #import some important packages
57
+ import os
58
+ import re
59
+ import json
60
+ import torch
61
+ import inflect
62
+ import random
63
+ import uroman as ur
64
+ import numpy as np
65
+ import torchaudio
66
+ import IPython
67
+ from transformers import AutoModelForCausalLM, AutoTokenizer
68
+ from outetts.wav_tokenizer.decoder import WavTokenizer
69
+ from yarngpt.audiotokenizer import AudioTokenizer
70
 
 
 
 
71
 
72
+ # download the wavtokenizer weights and config (to encode and decode the audio)
73
+ !wget https://huggingface.co/novateur/WavTokenizer-medium-speech-75token/resolve/main/wavtokenizer_mediumdata_frame75_3s_nq1_code4096_dim512_kmeans200_attn.yaml
74
+ !wget https://huggingface.co/novateur/WavTokenizer-large-speech-75token/resolve/main/wavtokenizer_large_speech_320_24k.ckpt
75
 
76
+ # model path and wavtokenizer weight path (the paths are assumed based on Google colab, a different environment might save the weights to a different location).
77
+ hf_path="saheedniyi/YarnGPT"
78
+ wav_tokenizer_config_path="/content/wavtokenizer_mediumdata_frame75_3s_nq1_code4096_dim512_kmeans200_attn.yaml"
79
+ wav_tokenizer_model_path = "/content/wavtokenizer_large_speech_320_24k.ckpt"
80
 
81
+ # create the AudioTokenizer object
82
+ audio_tokenizer=AudioTokenizer(
83
+ hf_path,wav_tokenizer_model_path,wav_tokenizer_config_path
84
+ )
85
 
86
+ #load the model weights
87
 
88
+ model = AutoModelForCausalLM.from_pretrained(hf_path,torch_dtype="auto").to(audio_tokenizer.device)
89
 
90
+ # your input text
91
+ text="Uhm, so, what was the inspiration behind your latest project? Like, was there a specific moment where you were like, 'Yeah, this is it!' Or, you know, did it just kind of, uh, come together naturally over time?"
92
 
93
+ # creating a prompt, when creating a prompt, there is an optional `speaker_name` parameter, the possible speakers are "idera","emma","jude","osagie","tayo","zainab","joke","regina","remi","umar","chinenye" if no speaker is selected a speaker is chosen at random
94
+ prompt=audio_tokenizer.create_prompt(text,"idera")
95
 
96
+ # tokenize the prompt
97
+ input_ids=audio_tokenizer.tokenize_prompt(prompt)
98
 
99
+ # generate output from the model, you can tune the `.generate` parameters as you wish
100
+ output = model.generate(
101
+ input_ids=input_ids,
102
+ temperature=0.1,
103
+ repetition_penalty=1.1,
104
+ max_length=4000,
105
+ )
106
 
107
+ # convert the output to "audio codes"
108
+ codes=audio_tokenizer.get_codes(output)
109
 
110
+ # converts the codes to audio
111
+ audio=audio_tokenizer.get_audio(codes)
112
 
113
+ # play the audio
114
+ IPython.display.Audio(audio,rate=24000)
 
 
 
115
 
116
+ # save the audio
117
+ torchaudio.save(f"audio.wav", audio, sample_rate=24000)
118
+ ```
119
 
120
+ ## Model Description
121
 
122
+ - **Developed by:** [Saheedniyi](https://linkedin.com/in/azeez-saheed)
123
+ - **Model type:** Text-to-Speech
124
+ - **Language(s) (NLP):** English--> Nigerian Accented English
125
+ - **Finetuned from:** [HuggingFaceTB/SmolLM2-360M](https://huggingface.co/HuggingFaceTB/SmolLM2-360M)
126
+ - **Repository:** [YarnGPT Github Repository](https://github.com/saheedniyi02/yarngpt)
127
+ - **Paper:** IN PROGRESS.
128
+ - **Demo:** [Prompt YarnGPT notebook](#)
129
 
130
+ #### Uses
131
 
132
+ Generate Nigerian-accented English speech for experimental purposes.
133
 
 
134
 
135
+ #### Out-of-Scope Use
136
 
137
+ The model is not suitable for generating speech in languages other than English or other accents.
138
 
 
139
 
140
+ ## Bias, Risks, and Limitations
141
 
142
+ The model may not capture the full diversity of Nigerian accents and could exhibit biases based on the training dataset. Also a lot of the text the model was trained on were automatically generated which could impact performance.
143
 
 
144
 
145
+ #### Recommendations
146
 
147
+ <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
148
 
149
+ Users (both direct and downstream) should be made aware of the risks, biases, and limitations of the model. Feedback and diverse training data contributions are encouraged.
150
+ ## Speech Samples
151
+
152
+ Listen to samples generated by YarnGPT:
153
+
154
+ <div style="margin-top: 20px;">
155
+ <table style="width: 100%; border-collapse: collapse;">
156
+ <thead>
157
+ <tr>
158
+ <th style="border: 1px solid #ddd; padding: 8px; text-align: left; width: 40%;">Input</th>
159
+ <th style="border: 1px solid #ddd; padding: 8px; text-align: left; width: 40%;">Audio</th>
160
+ <th style="border: 1px solid #ddd; padding: 8px; text-align: left; width: 10%;">Notes</th>
161
+ </tr>
162
+ </thead>
163
+ <tbody>
164
+ <tr>
165
+ <td style="border: 1px solid #ddd; padding: 8px;">Hello world! I am Saheed Azeez and I am excited to announce the release of his project, I have been gathering data and learning how to build Audio-based models over the last two months, but thanks to God, I have been able to come up with something</td>
166
+ <td style="border: 1px solid #ddd; padding: 8px;">
167
+ <audio controls style="width: 100%;">
168
+ <source src="https://huggingface.co/saheedniyi/YarnGPT/resolve/main/audio/Sample_1.wav" type="audio/wav">
169
+ Your browser does not support the audio element.
170
+ </audio>
171
+ </td>
172
+ <td style="border: 1px solid #ddd; padding: 8px;">(temperature=0.1, repetition_penalty=1.1), voice: idera</td>
173
+ </tr>
174
+ <tr>
175
+ <td style="border: 1px solid #ddd; padding: 8px;"> Wizkid, Davido, Burna Boy perform at same event in Lagos. This event has sparked many reactions across social media, with fans and critics alike praising the artistes' performances and the rare opportunity to see the three music giants on the same stage.</td>
176
+ <td style="border: 1px solid #ddd; padding: 8px;">
177
+ <audio controls style="width: 100%;">
178
+ <source src="https://huggingface.co/saheedniyi/YarnGPT/resolve/main/audio/Sample_2.wav" type="audio/wav">
179
+ Your browser does not support the audio element.
180
+ </audio>
181
+ </td>
182
+ <td style="border: 1px solid #ddd; padding: 8px;">(temperature=0.1, repetition_penalty=1.1), voice: jude</td>
183
+ </tr>
184
+ <tr>
185
+ <td style="border: 1px solid #ddd; padding: 8px;">Since Nigeria became a republic in 1963, 14 individuals have served as head of state of Nigeria under different titles. The incumbent president Bola Tinubu is the nation's 16th head of state.</td>
186
+ <td style="border: 1px solid #ddd; padding: 8px;">
187
+ <audio controls style="width: 100%;">
188
+ <source src="https://huggingface.co/saheedniyi/YarnGPT/resolve/main/audio/Sample_3.wav" type="audio/wav">
189
+ Your browser does not support the audio element.
190
+ </audio>
191
+ </td>
192
+ <td style="border: 1px solid #ddd; padding: 8px;">(temperature=0.1, repetition_penalty=1.1), voice: zainab, the model struggled in pronouncing ` in 1963`</td>
193
+ </tr>
194
+ <tr>
195
+ <td style="border: 1px solid #ddd; padding: 8px;">I visited the President, who has shown great concern for the security of Plateau State, especially considering that just a year ago, our state was in mourning. The President’s commitment to addressing these challenges has been steadfast.</td>
196
+ <td style="border: 1px solid #ddd; padding: 8px;">
197
+ <audio controls style="width: 100%;">
198
+ <source src="https://huggingface.co/saheedniyi/YarnGPT/resolve/main/audio/Sample_4.wav" type="audio/wav">
199
+ Your browser does not support the audio element.
200
+ </audio>
201
+ </td>
202
+ <td style="border: 1px solid #ddd; padding: 8px;">(temperature=0.1, repetition_penalty=1.1), voice: emma</td>
203
+ </tr>
204
+ <tr>
205
+ <td style="border: 1px solid #ddd; padding: 8px;">Scientists have discovered a new planet that may be capable of supporting life!</td>
206
+ <td style="border: 1px solid #ddd; padding: 8px;">
207
+ <audio controls style="width: 100%;">
208
+ <source src="https://huggingface.co/saheedniyi/YarnGPT/resolve/main/audio/Sample_5.wav" type="audio/wav">
209
+ Your browser does not support the audio element.
210
+ </audio>
211
+ </td>
212
+ <td style="border: 1px solid #ddd; padding: 8px;">(temperature=0.1, repetition_penalty=1.1), voice: nonye</td>
213
+ </tr>
214
+ </tbody>
215
+ </table>
216
+ </div>
217
+
218
+
219
+ ## Training
220
+
221
+ #### Data
222
+ Trained on a dataset of about 2000hrs of Nigerian movies, podcasts and open source Nigerian audio data, using the subtitle-audio pairs.
223
+
224
+ #### Preprocessing
225
+
226
+ Audio files were preprocessed and resampled to 24Khz and tokenized using [wavtokenizer](https://huggingface.co/novateur/WavTokenizer).
227
 
228
  #### Training Hyperparameters
229
+ - **Number of epochs:** 5
230
+ - **batch_size:** 4
231
+ - **Scheduler:** linear schedule with warmup for 4 epochs, then linear decay to zero for the last epoch
232
+ - **Optimizer:** AdamW (betas=(0.9, 0.95),weight_decay=0.01)
233
+ - **Learning rate:** 1*10^-3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
234
 
235
  #### Hardware
236
 
237
+ - **GPUs:** 1 A100 (google colab: 50 hours)
238
 
239
  #### Software
240
 
241
+ - **Training Framework:** Pytorch
 
 
 
 
242
 
243
+ ## Future Improvements?
244
+ - Scaling up model size and human-annotaed/ reviewed training data
245
+ - Wrap the model around an API endpoint
246
+ - Add support for local Nigerian languages
247
+ - Voice cloning.
248
+ - Potential expansion into speech-to-speech assistant models
249
 
250
+ ## Citation [optional]
 
 
 
 
 
 
 
 
 
 
251
 
252
+ #### BibTeX:
253
 
254
+ ```python
255
+ @misc{yarngpt2025,
256
+ author = {Saheed Azeez},
257
+ title = {YarnGPT: Nigerian-Accented English Text-to-Speech Model},
258
+ year = {2025},
259
+ publisher = {Hugging Face},
260
+ url = {https://huggingface.co/SaheedAzeez/yarngpt}
261
+ }
262
+ ```
263
 
264
+ #### APA:
265
 
266
+ ```python
267
+ Saheed Azeez. (2025). YarnGPT: Nigerian-Accented English Text-to-Speech Model. Hugging Face. Available at: https://huggingface.co/SaheedAzeez/yarngpt
268
+ ```
269
 
 
270
 
271
+ ## Credits & References
272
+ - [OuteAI/OuteTTS-0.2-500M](https://huggingface.co/OuteAI/OuteTTS-0.2-500M/)
273
+ - [WavTokenizer](https://github.com/jishengpeng/WavTokenizer)
274
+ - [CTC Forced Alignment](https://pytorch.org/audio/stable/tutorials/ctc_forced_alignment_api_tutorial.html)
275
+ - [Voicera](https://huggingface.co/Lwasinam/voicera)