Mohamed Aymane Farhi
commited on
Commit
·
3ab0a08
1
Parent(s):
c4ca71a
Add other variants.
Browse files
app.py
CHANGED
|
@@ -2,36 +2,32 @@
|
|
| 2 |
from ttsmms import TTS
|
| 3 |
import gradio as gr
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
return (audio['sampling_rate'], audio['x'])
|
| 10 |
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
fn=generate_voice,
|
| 31 |
-
inputs=inputs,
|
| 32 |
-
outputs=outputs,
|
| 33 |
-
queue=True,
|
| 34 |
-
)
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
blocks.queue(concurrency_count=1).launch(debug=True)
|
|
|
|
| 2 |
from ttsmms import TTS
|
| 3 |
import gradio as gr
|
| 4 |
|
| 5 |
+
VARIANTS = ['shi', 'rif-script_latin', 'rif-script_arabic', 'kab', 'taq', 'ttq-script_tifinagh']
|
| 6 |
+
MODELS = {}
|
| 7 |
+
|
| 8 |
+
def tts(text, variant):
|
| 9 |
+
if variant not in MODELS:
|
| 10 |
+
MODELS[variant] = TTS(variant)
|
| 11 |
+
model = MODELS[variant]
|
| 12 |
+
audio = model.synthesis(text)
|
| 13 |
return (audio['sampling_rate'], audio['x'])
|
| 14 |
|
| 15 |
+
examples = [["wala manis a-ttidun?", "shi"],
|
| 16 |
+
["ġ-iḍ-an ġ-ilul-umsiggel, illas lḥal s-umdlu isemmiḍn.", "shi"]]
|
| 17 |
+
|
| 18 |
+
iface = gr.Interface(
|
| 19 |
+
fn=tts,
|
| 20 |
+
inputs=[
|
| 21 |
+
gr.inputs.Textbox(
|
| 22 |
+
label="Text",
|
| 23 |
+
default="Text to synthesize.",
|
| 24 |
+
),
|
| 25 |
+
gr.inputs.Dropdown(label="Select a variant", choices=VARIANTS, default=VARIANTS[0])
|
| 26 |
+
],
|
| 27 |
+
outputs=gr.outputs.Audio(label="Output", type="numpy"),
|
| 28 |
+
examples=examples,
|
| 29 |
+
title="🗣️ Tamazight Text to Speech with MMS 🗣️",
|
| 30 |
+
allow_flagging="manual",
|
| 31 |
+
flagging_options=['error', 'bad-quality', 'wrong-pronounciation'],
|
| 32 |
+
)
|
| 33 |
+
iface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|