Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -85,6 +85,14 @@ def normalize_text(text):
|
|
85 |
# ➤ Beddel ereyga zamzam dhammaan noocyadiisa (bilow, dhex, dhammaad)
|
86 |
text = re.sub(r'(?i)(?<!\w)zamzam(?!\w)', 'samsam', text)
|
87 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
# ➤ Ka saar tirooyin leh koma iyo tobanle
|
89 |
text = re.sub(r'(\d{1,3})(,\d{3})+', lambda m: m.group(0).replace(",", ""), text)
|
90 |
text = re.sub(r'\.\d+', '', text)
|
@@ -108,14 +116,12 @@ def normalize_text(text):
|
|
108 |
text = text.replace("KH", "qa").replace("Z", "S")
|
109 |
text = text.replace("SH", "SHa'a").replace("DH", "Dha'a")
|
110 |
|
111 |
-
# ➤ Haddii jumladda ku dhammaato zamzam ama samsam, ku dar "
|
112 |
if re.search(r'(?i)(zamzam|samsam)[\s\.\,\!\?]*$', text.strip()):
|
113 |
text += " m"
|
114 |
|
115 |
return text
|
116 |
|
117 |
-
|
118 |
-
|
119 |
def tts(text):
|
120 |
paragraphs = text.strip().split("\n")
|
121 |
audio_list = []
|
|
|
85 |
# ➤ Beddel ereyga zamzam dhammaan noocyadiisa (bilow, dhex, dhammaad)
|
86 |
text = re.sub(r'(?i)(?<!\w)zamzam(?!\w)', 'samsam', text)
|
87 |
|
88 |
+
# ➤ Bedel shortcuts - eray kasta oo qoraalka ku jira beddel
|
89 |
+
# Ka dhig case-insensitive beddelka
|
90 |
+
def replace_shortcuts(match):
|
91 |
+
word = match.group(0).lower()
|
92 |
+
return shortcut_map.get(word, word)
|
93 |
+
pattern = re.compile(r'\b(' + '|'.join(re.escape(k) for k in shortcut_map.keys()) + r')\b', re.IGNORECASE)
|
94 |
+
text = pattern.sub(replace_shortcuts, text)
|
95 |
+
|
96 |
# ➤ Ka saar tirooyin leh koma iyo tobanle
|
97 |
text = re.sub(r'(\d{1,3})(,\d{3})+', lambda m: m.group(0).replace(",", ""), text)
|
98 |
text = re.sub(r'\.\d+', '', text)
|
|
|
116 |
text = text.replace("KH", "qa").replace("Z", "S")
|
117 |
text = text.replace("SH", "SHa'a").replace("DH", "Dha'a")
|
118 |
|
119 |
+
# ➤ Haddii jumladda ku dhammaato zamzam ama samsam, ku dar " m" (silent m)
|
120 |
if re.search(r'(?i)(zamzam|samsam)[\s\.\,\!\?]*$', text.strip()):
|
121 |
text += " m"
|
122 |
|
123 |
return text
|
124 |
|
|
|
|
|
125 |
def tts(text):
|
126 |
paragraphs = text.strip().split("\n")
|
127 |
audio_list = []
|