Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import gradio as gr
|
3 |
+
from TTS.api import TTS
|
4 |
+
from huggingface_hub import hf_hub_download, login
|
5 |
+
|
6 |
+
# Login using token stored in secrets
|
7 |
+
login(token=os.getenv("HF_TOKEN"))
|
8 |
+
|
9 |
+
# Download model + config
|
10 |
+
model_path = hf_hub_download(repo_id="marconilabmak/vits-voco-cvft", filename="best_model.pth")
|
11 |
+
config_path = hf_hub_download(repo_id="marconilabmak/vits-voco-cvft", filename="config.json")
|
12 |
+
|
13 |
+
# Load Coqui TTS model
|
14 |
+
tts = TTS(model_path=model_path, config_path=config_path)
|
15 |
+
|
16 |
+
def synthesize(text):
|
17 |
+
wav = tts.tts(text)
|
18 |
+
return (22050, wav)
|
19 |
+
|
20 |
+
demo = gr.Interface(
|
21 |
+
fn=synthesize,
|
22 |
+
inputs=gr.Textbox(label="Enter Luganda text"),
|
23 |
+
outputs=gr.Audio(type="numpy", label="Generated speech"),
|
24 |
+
title="Luganda TTS Demo",
|
25 |
+
description="Enter Luganda text and listen to generated speech using VITS-Voco model."
|
26 |
+
)
|
27 |
+
|
28 |
+
if __name__ == "__main__":
|
29 |
+
demo.launch()
|