snackshell commited on
Commit
53d6ba9
Β·
verified Β·
1 Parent(s): bda3923

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +56 -13
app.py CHANGED
@@ -16,7 +16,6 @@ async def text_to_speech_edge(text, speaker):
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,29 +29,73 @@ async def text_to_speech_edge(text, speaker):
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,
 
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
  error_msg = f"αˆ΅αˆ…α‰°α‰΅: α‹΅αˆα… መፍጠር αŠ αˆα‰°α‰»αˆˆαˆα’\nError: {str(e)}"
30
  raise gr.Error(error_msg)
31
 
32
+ with gr.Blocks(title="Amharic TTS", theme=gr.themes.Soft()) as demo:
33
  gr.HTML("""
34
  <style>
35
+ h1 {
36
+ color: #2E86C1;
37
+ text-align: center;
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(scale=1):
77
+ input_text = gr.Textbox(
78
+ lines=5,
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(scale=1):
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,