Add extra letter mappings.
Browse files
app.py
CHANGED
|
@@ -11,21 +11,32 @@ ISO_CODES = {'Tachelhit': 'shi',
|
|
| 11 |
}
|
| 12 |
|
| 13 |
mapping = {'ɣ': 'ġ',
|
|
|
|
| 14 |
'c': 'š',
|
| 15 |
-
'x': 'ḫ'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
}
|
| 17 |
|
| 18 |
MODELS = {}
|
| 19 |
|
| 20 |
def tts(text, variant):
|
| 21 |
-
text = text.lower()
|
| 22 |
variant_code = ISO_CODES[variant]
|
| 23 |
-
if variant_code == 'shi':
|
| 24 |
-
for key, value in mapping.items():
|
| 25 |
-
text = text.replace(key, value)
|
| 26 |
if variant_code not in MODELS:
|
| 27 |
MODELS[variant_code] = TTS(variant_code)
|
| 28 |
model = MODELS[variant_code]
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
audio = model.synthesis(text)
|
| 30 |
return (audio['sampling_rate'], audio['x'])
|
| 31 |
|
|
@@ -41,13 +52,13 @@ description = "Text-to-speech for Tachelhit, Tarifit, Taqbaylit, Tamasheq and Ta
|
|
| 41 |
iface = gr.Interface(
|
| 42 |
fn=tts,
|
| 43 |
inputs=[
|
| 44 |
-
gr.
|
| 45 |
label="Text",
|
| 46 |
default="Text to synthesize.",
|
| 47 |
),
|
| 48 |
-
gr.
|
| 49 |
],
|
| 50 |
-
outputs=gr.
|
| 51 |
examples=examples,
|
| 52 |
title="🗣️ Tamazight Text-to-Speech with MMS (Massively Multilingual Speech) 🗣️",
|
| 53 |
description=description,
|
|
|
|
| 11 |
}
|
| 12 |
|
| 13 |
mapping = {'ɣ': 'ġ',
|
| 14 |
+
'v': 'ġ',
|
| 15 |
'c': 'š',
|
| 16 |
+
'x': 'ḫ',
|
| 17 |
+
'T': 'ṭ',
|
| 18 |
+
'S': 'ṣ',
|
| 19 |
+
'D': 'ḍ',
|
| 20 |
+
'H': 'ḥ',
|
| 21 |
+
'Z': 'ẓ',
|
| 22 |
+
'3': 'ε',
|
| 23 |
+
'7': 'ḥ',
|
| 24 |
+
'9': 'q',
|
| 25 |
+
'gh': 'ġ',
|
| 26 |
+
'kh': 'ḫ'
|
| 27 |
}
|
| 28 |
|
| 29 |
MODELS = {}
|
| 30 |
|
| 31 |
def tts(text, variant):
|
|
|
|
| 32 |
variant_code = ISO_CODES[variant]
|
|
|
|
|
|
|
|
|
|
| 33 |
if variant_code not in MODELS:
|
| 34 |
MODELS[variant_code] = TTS(variant_code)
|
| 35 |
model = MODELS[variant_code]
|
| 36 |
+
|
| 37 |
+
if variant_code == 'shi':
|
| 38 |
+
for key, value in mapping.items():
|
| 39 |
+
text = text.replace(key, value)
|
| 40 |
audio = model.synthesis(text)
|
| 41 |
return (audio['sampling_rate'], audio['x'])
|
| 42 |
|
|
|
|
| 52 |
iface = gr.Interface(
|
| 53 |
fn=tts,
|
| 54 |
inputs=[
|
| 55 |
+
gr.Textbox(
|
| 56 |
label="Text",
|
| 57 |
default="Text to synthesize.",
|
| 58 |
),
|
| 59 |
+
gr.Dropdown(label="Variant", choices=list(ISO_CODES.keys()), default="Tachelhit")
|
| 60 |
],
|
| 61 |
+
outputs=gr.Audio(label="Output", type="numpy"),
|
| 62 |
examples=examples,
|
| 63 |
title="🗣️ Tamazight Text-to-Speech with MMS (Massively Multilingual Speech) 🗣️",
|
| 64 |
description=description,
|