Initial Gradio demo
Browse files- .gitattributes +1 -0
- README.md +9 -7
- app.py +91 -0
- reference.wav +3 -0
- requirements.txt +4 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
reference.wav filter=lfs diff=lfs merge=lfs -text
|
README.md
CHANGED
|
@@ -1,13 +1,15 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version: 6.
|
| 8 |
-
python_version: '3.13'
|
| 9 |
app_file: app.py
|
| 10 |
pinned: false
|
|
|
|
| 11 |
---
|
| 12 |
|
| 13 |
-
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
title: Yoruba English Code Switching TTS
|
| 3 |
+
emoji: 🎙️
|
| 4 |
+
colorFrom: green
|
| 5 |
+
colorTo: yellow
|
| 6 |
sdk: gradio
|
| 7 |
+
sdk_version: 5.6.0
|
|
|
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
+
license: apache-2.0
|
| 11 |
---
|
| 12 |
|
| 13 |
+
Interactive demo for [LyngualLabs/YorubaEnglish-CodeSwitching-TTS](https://huggingface.co/LyngualLabs/YorubaEnglish-CodeSwitching-TTS) —
|
| 14 |
+
a voice-cloning Yoruba/Yoruba-English TTS model, full fine-tuned from VoxCPM2 on
|
| 15 |
+
~1,039 hours of pooled Yoruba speech data.
|
app.py
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import gradio as gr
|
| 3 |
+
import soundfile as sf
|
| 4 |
+
from huggingface_hub import snapshot_download
|
| 5 |
+
|
| 6 |
+
MODEL_REPO = "LyngualLabs/YorubaEnglish-CodeSwitching-TTS"
|
| 7 |
+
DEFAULT_REF_WAV = "reference.wav"
|
| 8 |
+
DEFAULT_REF_TEXT = "Ìròyìn ti sọ pé the government will ensure electricity tariff goes down ní January."
|
| 9 |
+
|
| 10 |
+
print("Downloading model...", flush=True)
|
| 11 |
+
model_dir = snapshot_download(MODEL_REPO)
|
| 12 |
+
|
| 13 |
+
from voxcpm import VoxCPM # noqa: E402 (import after snapshot_download so the repo is cached)
|
| 14 |
+
|
| 15 |
+
print("Loading model...", flush=True)
|
| 16 |
+
model = VoxCPM.from_pretrained(model_dir, load_denoiser=False)
|
| 17 |
+
SR = model.tts_model.sample_rate
|
| 18 |
+
print("Model loaded.", flush=True)
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
def synthesize(text, ref_audio, ref_text, cfg_value, inference_timesteps):
|
| 22 |
+
if not text or not text.strip():
|
| 23 |
+
raise gr.Error("Please enter some text to synthesize.")
|
| 24 |
+
|
| 25 |
+
prompt_wav_path = ref_audio if ref_audio else DEFAULT_REF_WAV
|
| 26 |
+
prompt_text = ref_text.strip() if (ref_audio and ref_text and ref_text.strip()) else (
|
| 27 |
+
DEFAULT_REF_TEXT if not ref_audio else ""
|
| 28 |
+
)
|
| 29 |
+
if ref_audio and not prompt_text:
|
| 30 |
+
raise gr.Error("Please provide the exact transcript of your uploaded reference audio.")
|
| 31 |
+
|
| 32 |
+
wav = model.generate(
|
| 33 |
+
text=text.strip(),
|
| 34 |
+
prompt_wav_path=prompt_wav_path,
|
| 35 |
+
prompt_text=prompt_text,
|
| 36 |
+
cfg_value=cfg_value,
|
| 37 |
+
inference_timesteps=int(inference_timesteps),
|
| 38 |
+
)
|
| 39 |
+
out_path = "output.wav"
|
| 40 |
+
sf.write(out_path, wav, SR)
|
| 41 |
+
return out_path
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
EXAMPLES = [
|
| 45 |
+
["Mo ní meeting pẹ̀lú marketing team ní aago mẹ́wàá lónìí, nítorí náà ẹ jẹ́ ká yára."],
|
| 46 |
+
["Ìròyìn ti sọ pé the government will ensure electricity tariff goes down ní January."],
|
| 47 |
+
["Wọ́n ní ìpàdé ní hotel tó wà ní Victoria Island, kì í ṣe ní office wa."],
|
| 48 |
+
]
|
| 49 |
+
|
| 50 |
+
with gr.Blocks(title="Yoruba-English Code-Switching TTS") as demo:
|
| 51 |
+
gr.Markdown(
|
| 52 |
+
"""
|
| 53 |
+
# 🎙️ Yoruba–English Code-Switching TTS
|
| 54 |
+
A voice-cloning text-to-speech model for Yoruba, including natural
|
| 55 |
+
Yoruba–English code-switching — full fine-tuned from
|
| 56 |
+
[VoxCPM2](https://huggingface.co/openbmb/VoxCPM2) on ~1,039 hours pooled from
|
| 57 |
+
DSN African Voices, NaijaVoices, YECS, and WAXAL.
|
| 58 |
+
|
| 59 |
+
Model card: [LyngualLabs/YorubaEnglish-CodeSwitching-TTS](https://huggingface.co/LyngualLabs/YorubaEnglish-CodeSwitching-TTS)
|
| 60 |
+
|
| 61 |
+
⚠️ **Experimental** — trained for only ~1 epoch. Quality varies by sentence;
|
| 62 |
+
rarer words/proper nouns are more likely to be mispronounced.
|
| 63 |
+
"""
|
| 64 |
+
)
|
| 65 |
+
with gr.Row():
|
| 66 |
+
with gr.Column():
|
| 67 |
+
text_in = gr.Textbox(
|
| 68 |
+
label="Text to speak",
|
| 69 |
+
placeholder="Type Yoruba, English, or mixed Yoruba-English text...",
|
| 70 |
+
lines=4,
|
| 71 |
+
)
|
| 72 |
+
with gr.Accordion("Voice cloning (optional) — upload your own reference", open=False):
|
| 73 |
+
ref_audio = gr.Audio(label="Reference audio (3-10s, clean)", type="filepath")
|
| 74 |
+
ref_text = gr.Textbox(label="Exact transcript of the reference audio")
|
| 75 |
+
gr.Markdown("_Leave blank to use the default built-in voice._")
|
| 76 |
+
with gr.Accordion("Advanced", open=False):
|
| 77 |
+
cfg_value = gr.Slider(1.0, 4.0, value=2.0, step=0.1, label="cfg_value (higher = sticks closer to reference)")
|
| 78 |
+
inference_timesteps = gr.Slider(10, 35, value=22, step=1, label="inference_timesteps (higher = smoother, slower)")
|
| 79 |
+
btn = gr.Button("Generate", variant="primary")
|
| 80 |
+
with gr.Column():
|
| 81 |
+
audio_out = gr.Audio(label="Generated speech", type="filepath")
|
| 82 |
+
|
| 83 |
+
gr.Examples(examples=EXAMPLES, inputs=[text_in])
|
| 84 |
+
btn.click(
|
| 85 |
+
synthesize,
|
| 86 |
+
inputs=[text_in, ref_audio, ref_text, cfg_value, inference_timesteps],
|
| 87 |
+
outputs=[audio_out],
|
| 88 |
+
)
|
| 89 |
+
|
| 90 |
+
if __name__ == "__main__":
|
| 91 |
+
demo.launch()
|
reference.wav
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8ac05c7ce4b2afe926ffa2dcf8af0d194adcfed9a28862d7139069a28916fa56
|
| 3 |
+
size 537644
|
requirements.txt
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
git+https://github.com/OpenBMB/VoxCPM.git
|
| 2 |
+
gradio
|
| 3 |
+
soundfile
|
| 4 |
+
huggingface_hub
|