Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -12,24 +12,16 @@ language_dict = {
|
|
12 |
"Ryan": "en-GB-RyanNeural",
|
13 |
"Clara": "en-CA-ClaraNeural"
|
14 |
},
|
15 |
-
"Tigrinya": {
|
16 |
-
"Ameha (Amharic)": "am-ET-AmehaNeural",
|
17 |
-
"Mekdes (Amharic)": "am-ET-MekdesNeural"
|
18 |
-
}
|
19 |
}
|
20 |
|
21 |
async def text_to_speech_edge(text, language, speaker):
|
22 |
if language == "Tigrinya":
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
voice = language_dict[language][speaker]
|
27 |
-
|
28 |
-
error_msg = (f"α΅α
α°α΅: α΅αα
'{speaker}' αααα '{language}' α αα°αααα’"
|
29 |
-
if language in ["Amharic", "Tigrinya"]
|
30 |
-
else f"Error: Voice '{speaker}' not available for '{language}'")
|
31 |
-
raise gr.Error(error_msg)
|
32 |
-
|
33 |
try:
|
34 |
communicate = edge_tts.Communicate(text, voice)
|
35 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".mp3") as tmp_file:
|
@@ -49,11 +41,15 @@ async def text_to_speech_edge(text, language, speaker):
|
|
49 |
raise gr.Error(error_msg)
|
50 |
|
51 |
def update_speakers(language):
|
52 |
-
|
|
|
|
|
|
|
|
|
53 |
return gr.Dropdown(
|
54 |
choices=speakers,
|
55 |
value=speakers[0],
|
56 |
-
label=f"Select Speaker {'(Amharic)' if language == 'Tigrinya' else ''}"
|
57 |
)
|
58 |
|
59 |
with gr.Blocks(title="Amharic, English & Tigrinya TTS", theme=gr.themes.Soft()) as demo:
|
|
|
12 |
"Ryan": "en-GB-RyanNeural",
|
13 |
"Clara": "en-CA-ClaraNeural"
|
14 |
},
|
15 |
+
"Tigrinya": {} # Empty because we'll use Amharic voices with labels
|
|
|
|
|
|
|
16 |
}
|
17 |
|
18 |
async def text_to_speech_edge(text, language, speaker):
|
19 |
if language == "Tigrinya":
|
20 |
+
clean_speaker = speaker.replace(" (Amharic Voice)", "")
|
21 |
+
voice = language_dict["Amharic"][clean_speaker]
|
22 |
+
else:
|
23 |
voice = language_dict[language][speaker]
|
24 |
+
|
|
|
|
|
|
|
|
|
|
|
25 |
try:
|
26 |
communicate = edge_tts.Communicate(text, voice)
|
27 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".mp3") as tmp_file:
|
|
|
41 |
raise gr.Error(error_msg)
|
42 |
|
43 |
def update_speakers(language):
|
44 |
+
if language == "Tigrinya":
|
45 |
+
speakers = [f"{name} (Amharic Voice)" for name in language_dict["Amharic"].keys()]
|
46 |
+
else:
|
47 |
+
speakers = list(language_dict[language].keys())
|
48 |
+
|
49 |
return gr.Dropdown(
|
50 |
choices=speakers,
|
51 |
value=speakers[0],
|
52 |
+
label=f"Select Speaker {'(Amharic Voices)' if language == 'Tigrinya' else ''}"
|
53 |
)
|
54 |
|
55 |
with gr.Blocks(title="Amharic, English & Tigrinya TTS", theme=gr.themes.Soft()) as demo:
|