ayymen commited on
Commit
af86d6e
1 Parent(s): 8540b99

Handle latin script for Tachelhit (shi)

Browse files
Files changed (1) hide show
  1. app.py +13 -4
app.py CHANGED
@@ -9,20 +9,29 @@ ISO_CODES = {'Tachelhit': 'shi',
9
  'Tamasheq': 'taq',
10
  'Tamajaq, Tawallammat (Tifinagh script)': 'ttq-script_tifinagh'
11
  }
12
- VARIANTS = list(ISO_CODES.values())
 
 
 
 
 
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 ihdumn ", "Tachelhit"],
24
- ["wa tamġart ma d ukan teskart ?", "Tachelhit"],
25
- ["ar d iṭṭar unẓar, ffuġn d igḍaḍ, mmġin d ijjign", "Tachelhit"],
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 ihdumn ", "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