Views
No views yet

1
2!git clone https://github.com/saheedniyi02/yarngpt.git
3
4pip install outetts uroman
5
6import os
7import re
8import json
9import torch
10import inflect
11import random
12import uroman as ur
13import numpy as np
14import torchaudio
15import IPython
16from transformers import AutoModelForCausalLM, AutoTokenizer
17from outetts.wav_tokenizer.decoder import WavTokenizer
18
19
20!wget https://huggingface.co/novateur/WavTokenizer-medium-speech-75token/resolve/main/wavtokenizer_mediumdata_frame75_3s_nq1_code4096_dim512_kmeans200_attn.yaml
21!gdown 1-ASeEkrn4HY49yZWHTASgfGFNXdVnLTt
22
23
24from yarngpt.audiotokenizer import AudioTokenizerV2
25
26tokenizer_path="saheedniyi/YarnGPT2"
27wav_tokenizer_config_path="/content/wavtokenizer_mediumdata_frame75_3s_nq1_code4096_dim512_kmeans200_attn.yaml"
28wav_tokenizer_model_path = "/content/wavtokenizer_large_speech_320_24k.ckpt"
29
30
31audio_tokenizer=AudioTokenizerV2(
32 tokenizer_path,wav_tokenizer_model_path,wav_tokenizer_config_path
33 )
34
35
36model = AutoModelForCausalLM.from_pretrained(tokenizer_path,torch_dtype="auto").to(audio_tokenizer.device)
37
38#change the text
39text="The election was won by businessman and politician, Moshood Abiola, but Babangida annulled the results, citing concerns over national security."
40
41# change the language and voice
42prompt=audio_tokenizer.create_prompt(text,lang="english",speaker_name="idera")
43
44input_ids=audio_tokenizer.tokenize_prompt(prompt)
45
46output = model.generate(
47 input_ids=input_ids,
48 temperature=0.1,
49 repetition_penalty=1.1,
50 max_length=4000,
51 #num_beams=5,# using a beam size helps for the local languages but not english
52 )
53
54codes=audio_tokenizer.get_codes(output)
55audio=audio_tokenizer.get_audio(codes)
56IPython.display.Audio(audio,rate=24000)
57torchaudio.save(f"Sample.wav", audio, sample_rate=24000)
58| Input | Audio | Notes |
|---|---|---|
| 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 | (temperature=0.1, repetition_penalty=1.1), language: english, voice: idera | |
| The election was won by businessman and politician, Moshood Abiola, but Babangida annulled the results, citing concerns over national security. | (temperature=0.1, repetition_penalty=1.1), language: english, voice: zainab | |
| Habeeb Okikiọla Olalomi Badmus ti ọpọ awọn ololufẹ rẹ mọ si Portable ti sọ fun ile ẹjọ majisireeti ti ipinlẹ Ogun wi pe ṣaka lara oun da, oun ko ni aisan tabi arun kankan lara. | (temperature=0.1, repetition_penalty=1.1), language: yoruba, voice: yoruba_male2 | |
| Gómìnà náà fẹ̀sùn kàn pé àwọn alága àná gbìyànjú láti fi ipá gba àwọn ìjọba ìbílẹ̀ lọ́nà àìtọ́, tó sì jẹ́ pé ó yẹ kí àwọn ìjọba ìbílẹ̀ náà wà ní títì | (temperature=0.1, repetition_penalty=1.1), language: yoruba, voice: yoruba_female2 | |
| Ọ bụ oge ha si Enugwu steeti eme njem aga Anambra ka ndị omekome ahụ wakporo ụgbọala ha. | (temperature=0.1, repetition_penalty=1.1), language: igbo, voice: igbo_male2 | |
| Isi ụlọorụ Shell dị na Lọndọn na gọọmenti Naịjirịa ekwuputala ugboro ugboro na ọrụ ịsacha ogbe ndị lara n'iyi n'Ogoni bụ nke malitere ihe dịka afọ asatọ gara aga na-aga nke ọma. | (temperature=0.1, repetition_penalty=1.1), language: igbo, voice: igbo_female1 | |
| Gwamnatin Najeriya ta sake maka shafin hada-hadar kuɗin kirifto na Binance a kotu, inda take buƙatar ya biya ta diyyar kuɗi dalar Amurka biliyan 81.5 | (temperature=0.1, repetition_penalty=1.1), language: hausa, voice: hausa_female1 | |
| Bisa ga dukkan alamu, haƙata cimma ruwa, dangane da koke-koken da tsofaffin ma'aikatan tarayya ke ta yi, a kan dimbin basukan wasu hakkokinsu da suke bi shekara da shekaru. | (temperature=0.1, repetition_penalty=1.1), language: hausa, voice: hausa_male2 |
1@misc{yarngpt2025,
2 author = {Saheed Azeez},
3 title = {YarnGPT: Nigerian-Accented English Text-to-Speech Model},
4 year = {2025},
5 publisher = {Hugging Face},
6 url = {https://huggingface.co/SaheedAzeez/yarngpt}
7}Saheed Azeez. (2025). YarnGPT: Nigerian-Accented English Text-to-Speech Model. Hugging Face. Available at: https://huggingface.co/saheedniyi/YarnGPT