Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -16,6 +16,7 @@ async def text_to_speech_edge(text, speaker):
|
|
16 |
try:
|
17 |
communicate = edge_tts.Communicate(text, voice)
|
18 |
|
|
|
19 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".mp3") as tmp_file:
|
20 |
tmp_path = tmp_file.name
|
21 |
await asyncio.wait_for(communicate.save(tmp_path), timeout=30)
|
@@ -29,73 +30,29 @@ async def text_to_speech_edge(text, speaker):
|
|
29 |
error_msg = f"α΅α
α°α΅: α΅αα
ααα α α αα°α»ααα’\nError: {str(e)}"
|
30 |
raise gr.Error(error_msg)
|
31 |
|
32 |
-
with gr.Blocks(title="Amharic TTS"
|
33 |
gr.HTML("""
|
34 |
<style>
|
35 |
-
h1 {
|
36 |
-
|
37 |
-
|
38 |
-
background: linear-gradient(45deg, #FF007F, #2E86C1);
|
39 |
-
-webkit-background-clip: text;
|
40 |
-
-webkit-text-fill-color: transparent;
|
41 |
-
margin-bottom: 30px;
|
42 |
-
font-size: 2.5em;
|
43 |
-
}
|
44 |
-
.gradio-container {
|
45 |
-
background: #f8f9fa !important;
|
46 |
-
}
|
47 |
-
.gradio-button {
|
48 |
-
background: linear-gradient(45deg, #FF007F, #2E86C1) !important;
|
49 |
-
color: white !important;
|
50 |
-
border-radius: 8px !important;
|
51 |
-
padding: 12px 24px !important;
|
52 |
-
}
|
53 |
-
.gradio-textbox, .gradio-dropdown {
|
54 |
-
border-color: #2E86C1 !important;
|
55 |
-
border-radius: 8px !important;
|
56 |
-
padding: 12px !important;
|
57 |
-
}
|
58 |
-
.gradio-label {
|
59 |
-
color: #2E86C1 !important;
|
60 |
-
font-weight: 600 !important;
|
61 |
-
}
|
62 |
-
.prose {
|
63 |
-
max-width: 800px;
|
64 |
-
margin: 0 auto;
|
65 |
-
}
|
66 |
-
.gradio-row {
|
67 |
-
gap: 20px;
|
68 |
-
}
|
69 |
</style>
|
70 |
-
<center>
|
71 |
-
<h1>α¨α ααα α½αα αα° α΅αα
ααα</h1>
|
72 |
-
</center>
|
73 |
""")
|
74 |
|
75 |
with gr.Row():
|
76 |
-
with gr.Column(
|
77 |
-
input_text = gr.Textbox(
|
78 |
-
|
79 |
-
label="α½αα α«α΅αα‘",
|
80 |
-
placeholder="α΅αα
αααα α α½αααα αα»α..."
|
81 |
-
)
|
82 |
speaker = gr.Dropdown(
|
83 |
choices=["Ameha", "Mekdes"],
|
84 |
value="Ameha",
|
85 |
-
label="
|
86 |
-
)
|
87 |
-
run_btn = gr.Button(
|
88 |
-
value="α΅αα
αα α",
|
89 |
-
variant="primary",
|
90 |
-
scale=1
|
91 |
)
|
|
|
92 |
|
93 |
-
with gr.Column(
|
94 |
-
output_audio = gr.Audio(
|
95 |
-
type="filepath",
|
96 |
-
label="α¨α°αα α¨ α΅αα
",
|
97 |
-
elem_classes="output-audio"
|
98 |
-
)
|
99 |
|
100 |
run_btn.click(
|
101 |
text_to_speech_edge,
|
|
|
16 |
try:
|
17 |
communicate = edge_tts.Communicate(text, voice)
|
18 |
|
19 |
+
# Create temp file with increased timeout
|
20 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".mp3") as tmp_file:
|
21 |
tmp_path = tmp_file.name
|
22 |
await asyncio.wait_for(communicate.save(tmp_path), timeout=30)
|
|
|
30 |
error_msg = f"α΅α
α°α΅: α΅αα
ααα α α αα°α»ααα’\nError: {str(e)}"
|
31 |
raise gr.Error(error_msg)
|
32 |
|
33 |
+
with gr.Blocks(title="Amharic TTS") as demo:
|
34 |
gr.HTML("""
|
35 |
<style>
|
36 |
+
h1 { color: #FF007F; text-align: center; }
|
37 |
+
.gradio-button { background-color: #FF007F !important; color: white !important; }
|
38 |
+
.gradio-textbox, .gradio-dropdown { border-color: #FF007F !important; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
</style>
|
40 |
+
<center><h1>Amharic Text-to-Speech</h1></center>
|
|
|
|
|
41 |
""")
|
42 |
|
43 |
with gr.Row():
|
44 |
+
with gr.Column():
|
45 |
+
input_text = gr.Textbox(lines=5, label="α¨α ααα α½αα",
|
46 |
+
placeholder="α΅αα
αααα α α½αα α«α΅αα‘...")
|
|
|
|
|
|
|
47 |
speaker = gr.Dropdown(
|
48 |
choices=["Ameha", "Mekdes"],
|
49 |
value="Ameha",
|
50 |
+
label="α αα²α΅α΅"
|
|
|
|
|
|
|
|
|
|
|
51 |
)
|
52 |
+
run_btn = gr.Button(value="α΅αα
αα α", variant="primary")
|
53 |
|
54 |
+
with gr.Column():
|
55 |
+
output_audio = gr.Audio(type="filepath", label="α¨α΅αα
αα€α΅")
|
|
|
|
|
|
|
|
|
56 |
|
57 |
run_btn.click(
|
58 |
text_to_speech_edge,
|