|
|
|
from ttsmms import TTS |
|
import gradio as gr |
|
|
|
ISO_CODES = {'Tachelhit': 'shi', |
|
'Tarifit (Latin script)': 'rif-script_latin', |
|
'Tarifit (Arabic script)': 'rif-script_arabic', |
|
'Taqbaylit': 'kab', |
|
'Tamasheq': 'taq', |
|
'Tamajaq, Tawallammat (Tifinagh script)': 'ttq-script_tifinagh' |
|
} |
|
VARIANTS = list(ISO_CODES.values()) |
|
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="Variant", choices=ISO_CODES.values(), 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() |