Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -11,6 +11,10 @@ language_dict = {
|
|
11 |
"English": {
|
12 |
"Ryan": "en-GB-RyanNeural",
|
13 |
"Clara": "en-CA-ClaraNeural"
|
|
|
|
|
|
|
|
|
14 |
}
|
15 |
}
|
16 |
|
@@ -27,10 +31,14 @@ async def text_to_speech_edge(text, language, speaker):
|
|
27 |
return tmp_path
|
28 |
|
29 |
except asyncio.TimeoutError:
|
30 |
-
error_msg = "α΅α
α°α΅: αα α αααα’ α₯α£αα α₯αα°αα αααα©α’ (Timeout)"
|
|
|
|
|
31 |
raise gr.Error(error_msg)
|
32 |
except Exception as e:
|
33 |
-
error_msg = f"α΅α
α°α΅: α΅αα
ααα α α αα°α»ααα’\nError: {str(e)}"
|
|
|
|
|
34 |
raise gr.Error(error_msg)
|
35 |
|
36 |
def update_speakers(language):
|
@@ -38,7 +46,7 @@ def update_speakers(language):
|
|
38 |
# Use gr.update to update the dropdown's choices and default value.
|
39 |
return gr.update(choices=speakers, value=speakers[0])
|
40 |
|
41 |
-
with gr.Blocks(title="Amharic &
|
42 |
gr.HTML("""
|
43 |
<style>
|
44 |
h1 {
|
@@ -56,13 +64,13 @@ with gr.Blocks(title="Amharic & English TTS") as demo:
|
|
56 |
border-color: #2E86C1 !important;
|
57 |
}
|
58 |
</style>
|
59 |
-
<center><h1>Amharic &
|
60 |
""")
|
61 |
|
62 |
with gr.Row():
|
63 |
with gr.Column():
|
64 |
language = gr.Dropdown(
|
65 |
-
choices=["Amharic", "English"],
|
66 |
value="Amharic",
|
67 |
label="Select Language / ααα ααα¨α‘"
|
68 |
)
|
|
|
11 |
"English": {
|
12 |
"Ryan": "en-GB-RyanNeural",
|
13 |
"Clara": "en-CA-ClaraNeural"
|
14 |
+
},
|
15 |
+
"Tigrinya": {
|
16 |
+
"Ameha": "ti-ET-AmehaNeural", # Adjust if a different Tigrinya voice is available
|
17 |
+
"Mekdes": "ti-ET-MekdesNeural" # Adjust if needed
|
18 |
}
|
19 |
}
|
20 |
|
|
|
31 |
return tmp_path
|
32 |
|
33 |
except asyncio.TimeoutError:
|
34 |
+
error_msg = ("α΅α
α°α΅: αα α αααα’ α₯α£αα α₯αα°αα αααα©α’ (Timeout)"
|
35 |
+
if language == "Amharic" or language == "Tigrinya"
|
36 |
+
else "Error: Timeout. Please try again.")
|
37 |
raise gr.Error(error_msg)
|
38 |
except Exception as e:
|
39 |
+
error_msg = (f"α΅α
α°α΅: α΅αα
ααα α α αα°α»ααα’\nError: {str(e)}"
|
40 |
+
if language == "Amharic" or language == "Tigrinya"
|
41 |
+
else f"Error: Failed to generate audio.\nDetails: {str(e)}")
|
42 |
raise gr.Error(error_msg)
|
43 |
|
44 |
def update_speakers(language):
|
|
|
46 |
# Use gr.update to update the dropdown's choices and default value.
|
47 |
return gr.update(choices=speakers, value=speakers[0])
|
48 |
|
49 |
+
with gr.Blocks(title="Amharic, English & Tigrinya TTS") as demo:
|
50 |
gr.HTML("""
|
51 |
<style>
|
52 |
h1 {
|
|
|
64 |
border-color: #2E86C1 !important;
|
65 |
}
|
66 |
</style>
|
67 |
+
<center><h1>Amharic, English & Tigrinya Text-to-Speech</h1></center>
|
68 |
""")
|
69 |
|
70 |
with gr.Row():
|
71 |
with gr.Column():
|
72 |
language = gr.Dropdown(
|
73 |
+
choices=["Amharic", "English", "Tigrinya"],
|
74 |
value="Amharic",
|
75 |
label="Select Language / ααα ααα¨α‘"
|
76 |
)
|