Handle latin script for Tachelhit (shi)
Browse files
app.py
CHANGED
|
@@ -9,20 +9,29 @@ ISO_CODES = {'Tachelhit': 'shi',
|
|
| 9 |
'Tamasheq': 'taq',
|
| 10 |
'Tamajaq, Tawallammat (Tifinagh script)': 'ttq-script_tifinagh'
|
| 11 |
}
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
MODELS = {}
|
| 14 |
|
| 15 |
def tts(text, variant):
|
|
|
|
| 16 |
variant_code = ISO_CODES[variant]
|
|
|
|
|
|
|
|
|
|
| 17 |
if variant_code not in MODELS:
|
| 18 |
MODELS[variant_code] = TTS(variant_code)
|
| 19 |
model = MODELS[variant_code]
|
| 20 |
audio = model.synthesis(text)
|
| 21 |
return (audio['sampling_rate'], audio['x'])
|
| 22 |
|
| 23 |
-
examples = [["arraw n lhem yukr
|
| 24 |
-
["wa
|
| 25 |
-
["ar d iṭṭar unẓar,
|
| 26 |
["Egg lxir di timura, ad tafed di tiwwura.", "Tarifit (Latin script)"],
|
| 27 |
["Aqemmum iqnen ur ṯ-ttidfen izan.", "Tarifit (Latin script)"]]
|
| 28 |
|
|
|
|
| 9 |
'Tamasheq': 'taq',
|
| 10 |
'Tamajaq, Tawallammat (Tifinagh script)': 'ttq-script_tifinagh'
|
| 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 |
|
| 32 |
+
examples = [["arraw n lhem yukr aɣ ihdumn nɣ", "Tachelhit"],
|
| 33 |
+
["wa tamɣart ma d ukan teskart ?", "Tachelhit"],
|
| 34 |
+
["ar d iṭṭar unẓar, ffuɣn d igḍaḍ, mmɣin d ijjign", "Tachelhit"],
|
| 35 |
["Egg lxir di timura, ad tafed di tiwwura.", "Tarifit (Latin script)"],
|
| 36 |
["Aqemmum iqnen ur ṯ-ttidfen izan.", "Tarifit (Latin script)"]]
|
| 37 |
|