Spaces:
Running
Running
Initial commit
Browse files- README.md +2 -2
- app.py +49 -0
- requirements.txt +1 -0
README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
---
|
2 |
-
title: TTS
|
3 |
-
emoji:
|
4 |
colorFrom: indigo
|
5 |
colorTo: yellow
|
6 |
sdk: gradio
|
|
|
1 |
---
|
2 |
+
title: Coqui TTS
|
3 |
+
emoji: 🐸
|
4 |
colorFrom: indigo
|
5 |
colorTo: yellow
|
6 |
sdk: gradio
|
app.py
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import tempfile
|
3 |
+
from TTS.utils.synthesizer import Synthesizer
|
4 |
+
from huggingface_hub import hf_hub_download
|
5 |
+
|
6 |
+
REPO_ID = "ayymen/Coqui-TTS-Vits-shi"
|
7 |
+
|
8 |
+
my_title = "Tamazight Text-to-Speech"
|
9 |
+
my_description = "This model is based on [VITS](https://github.com/jaywalnut310/vits), thanks to 🐸 [Coqui.ai](https://coqui.ai/)."
|
10 |
+
|
11 |
+
my_examples = [
|
12 |
+
["ⴰⵣⵓⵍ"],
|
13 |
+
["ⴰⵔ ⴽⵎ ⵜⵜⵉⵔⵉⵖ"],
|
14 |
+
["ⴳⵏ! ⴰⴷ ⴰⴽ ⵉⵙⵙⴳⵏ ⵕⴱⴱⵉ ⵉⵜⵜⵓ ⴽ."]
|
15 |
+
]
|
16 |
+
|
17 |
+
my_inputs = [
|
18 |
+
gr.Textbox(lines=5, label="Input Text"),
|
19 |
+
]
|
20 |
+
|
21 |
+
my_outputs = gr.Audio(type="filepath", label="Output Audio")
|
22 |
+
|
23 |
+
def tts(text: str):
|
24 |
+
best_model_path = hf_hub_download(repo_id=REPO_ID, filename="best_model.pth")
|
25 |
+
config_path = hf_hub_download(repo_id=REPO_ID, filename="config.json")
|
26 |
+
|
27 |
+
# init synthesizer
|
28 |
+
synthesizer = Synthesizer(
|
29 |
+
best_model_path,
|
30 |
+
config_path,
|
31 |
+
use_cuda=True
|
32 |
+
)
|
33 |
+
|
34 |
+
# create audio file
|
35 |
+
wavs = synthesizer.tts(text)
|
36 |
+
with tempfile.NamedTemporaryFile(suffix = ".wav", delete = False) as fp:
|
37 |
+
synthesizer.save_wav(wavs, fp)
|
38 |
+
return fp.name
|
39 |
+
|
40 |
+
iface = gr.Interface(
|
41 |
+
fn=tts,
|
42 |
+
inputs=my_inputs,
|
43 |
+
outputs=my_outputs,
|
44 |
+
title=my_title,
|
45 |
+
description = my_description,
|
46 |
+
examples = my_examples,
|
47 |
+
cache_examples=True
|
48 |
+
)
|
49 |
+
iface.launch()
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
coqui-tts==0.24.3
|