Spaces:
Running
Running
File size: 1,029 Bytes
b740fff 3ab0a08 b740fff 3ab0a08 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# -*- coding: utf-8 -*-
from ttsmms import TTS
import gradio as gr
VARIANTS = ['shi', 'rif-script_latin', 'rif-script_arabic', 'kab', 'taq', 'ttq-script_tifinagh']
MODELS = {}
def tts(text, variant):
if variant not in MODELS:
MODELS[variant] = TTS(variant)
model = MODELS[variant]
audio = model.synthesis(text)
return (audio['sampling_rate'], audio['x'])
examples = [["wala manis a-ttidun?", "shi"],
["ġ-iḍ-an ġ-ilul-umsiggel, illas lḥal s-umdlu isemmiḍn.", "shi"]]
iface = gr.Interface(
fn=tts,
inputs=[
gr.inputs.Textbox(
label="Text",
default="Text to synthesize.",
),
gr.inputs.Dropdown(label="Select a variant", choices=VARIANTS, default=VARIANTS[0])
],
outputs=gr.outputs.Audio(label="Output", type="numpy"),
examples=examples,
title="🗣️ Tamazight Text to Speech with MMS 🗣️",
allow_flagging="manual",
flagging_options=['error', 'bad-quality', 'wrong-pronounciation'],
)
iface.launch() |