VSPAN commited on
Commit
d55a821
·
verified ·
1 Parent(s): e0e2d83

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +182 -69
app.py CHANGED
@@ -50,91 +50,204 @@ def tts_interface(*args):
50
  return None, gr.update(value=f"<span style='color:red;'>{warning}</span>", visible=True)
51
  return audio, gr.update(visible=False)
52
 
53
- # Custom CSS
54
- custom_css = """
55
- body {
56
- background: linear-gradient(45deg, #ff7e5f, #feb47b);
57
- animation: gradient 15s ease infinite;
58
- font-family: 'Arial', sans-serif;
59
- }
60
-
61
- @keyframes gradient {
62
- 0% { background-position: 0% 50%; }
63
- 50% { background-position: 100% 50%; }
64
- 100% { background-position: 0% 50%; }
65
- }
66
-
67
- .gradio-container {
68
- background-color: rgba(255, 255, 255, 0.1);
69
- border-radius: 10px;
70
- box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
71
- padding: 20px;
72
- }
73
-
74
- button {
75
- background: linear-gradient(45deg, #ff7e5f, #feb47b);
76
- border: none;
77
- color: white;
78
- padding: 10px 20px;
79
- text-align: center;
80
- text-decoration: none;
81
- display: inline-block;
82
- font-size: 16px;
83
- margin: 4px 2px;
84
- cursor: pointer;
85
- border-radius: 5px;
86
- transition: background 0.3s;
87
- }
88
-
89
- button:hover {
90
- background: linear-gradient(45deg, #feb47b, #ff7e5f);
91
- }
92
-
93
- textarea, select, input[type="range"] {
94
- background-color: rgba(255, 255, 255, 0.2);
95
- border: 1px solid rgba(255, 255, 255, 0.3);
96
- color: white;
97
- padding: 10px;
98
- border-radius: 5px;
99
- transition: background 0.3s;
100
- }
101
-
102
- textarea:focus, select:focus, input[type="range"]:focus {
103
- background-color: rgba(255, 255, 255, 0.3);
104
- }
105
-
106
- .warning {
107
- color: red;
108
- }
109
- """
110
-
111
  # Create Gradio application
112
  async def create_demo():
113
  voices = await get_voices()
114
 
115
  description = """
116
- <p style="color: white;">This is a simple text-to-speech application using Microsoft Edge TTS.</p>
117
- <p style="color: white;">You can enter any text and select the voice you want to use.</p>
118
- <p style="color: white;">Adjust the speech rate and pitch according to your preference.</p>
 
 
119
  """
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
120
  demo = gr.Interface(
121
  fn=tts_interface,
122
  inputs=[
123
- gr.Textbox(label="Input Text", lines=5),
124
- gr.Dropdown(choices=[""] + list(voices.keys()), label="Select Voice", value=""),
125
- gr.Slider(minimum=-50, maximum=50, value=0, label="Speech Rate Adjustment (%)", step=1),
126
- gr.Slider(minimum=-20, maximum=20, value=0, label="Pitch Adjustment (Hz)", step=1)
127
  ],
128
  outputs=[
129
  gr.Audio(label="Generated Audio", type="filepath"),
130
- gr.HTML(label="Warning", visible=False)
131
  ],
132
- title="Edge TTS Text-to-Speech",
133
  description=description,
134
- article="",
135
  analytics_enabled=False,
136
  allow_flagging="manual",
137
- css=custom_css
138
  )
139
  return demo
140
 
 
50
  return None, gr.update(value=f"<span style='color:red;'>{warning}</span>", visible=True)
51
  return audio, gr.update(visible=False)
52
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
  # Create Gradio application
54
  async def create_demo():
55
  voices = await get_voices()
56
 
57
  description = """
58
+ <div class="gradient-text">
59
+ This is a simple text-to-speech application using Microsoft Edge TTS.
60
+ You can enter any text and select the voice you want to use.
61
+ Adjust the speech rate and pitch according to your preference.
62
+ </div>
63
  """
64
+
65
+ css_style = """
66
+ <style>
67
+ body {
68
+ background: linear-gradient(135deg, #FF4E50, #EC9F05, #FF4E50);
69
+ background-size: 600% 600%;
70
+ color: white;
71
+ font-family: 'Arial', sans-serif;
72
+ animation: gradient 15s ease infinite;
73
+ display: flex;
74
+ justify-content: center;
75
+ align-items: center;
76
+ height: 100vh;
77
+ margin: 0;
78
+ }
79
+ .gradient-text {
80
+ background: linear-gradient(135deg, #FF4E50, #EC9F05, #FF4E50);
81
+ -webkit-background-clip: text;
82
+ -webkit-text-fill-color: transparent;
83
+ animation: text-gradient 15s ease infinite;
84
+ }
85
+ @keyframes gradient {
86
+ 0% { background-position: 0% 50%; }
87
+ 50% { background-position: 100% 50%; }
88
+ 100% { background-position: 0% 50%; }
89
+ }
90
+ @keyframes text-gradient {
91
+ 0% { background-position: 0% 50%; }
92
+ 50% { background-position: 100% 50%; }
93
+ 100% { background-position: 0% 50%; }
94
+ }
95
+ .gr-button {
96
+ background: linear-gradient(135deg, #FF4E50, #EC9F05);
97
+ border: none;
98
+ color: white;
99
+ padding: 15px 30px;
100
+ border-radius: 25px;
101
+ cursor: pointer;
102
+ font-size: 16px;
103
+ transition: transform 0.3s ease, box-shadow 0.3s ease;
104
+ outline: none;
105
+ position: relative;
106
+ overflow: hidden;
107
+ }
108
+ .gr-button::before {
109
+ content: '';
110
+ position: absolute;
111
+ top: 0;
112
+ left: 0;
113
+ width: 100%;
114
+ height: 100%;
115
+ background: linear-gradient(135deg, #FF4E50, #EC9F05);
116
+ opacity: 0;
117
+ transition: opacity 0.3s ease;
118
+ z-index: -1;
119
+ }
120
+ .gr-button:hover {
121
+ transform: translateY(-5px);
122
+ box-shadow: 0 10px 20px rgba(255, 78, 80, 0.5);
123
+ }
124
+ .gr-button:hover::before {
125
+ opacity: 0.5;
126
+ }
127
+ .gr-button:active {
128
+ transform: translateY(0);
129
+ box-shadow: 0 5px 10px rgba(255, 78, 80, 0.3);
130
+ }
131
+ .loading-spinner {
132
+ border: 4px solid rgba(255, 255, 255, 0.3);
133
+ border-top: 4px solid #FF4E50;
134
+ border-radius: 50%;
135
+ width: 30px;
136
+ height: 30px;
137
+ animation: spin 1s linear infinite;
138
+ }
139
+ @keyframes spin {
140
+ 0% { transform: rotate(0deg); }
141
+ 100% { transform: rotate(360deg); }
142
+ }
143
+ .gr-box {
144
+ background: rgba(255, 255, 255, 0.1);
145
+ border: 1px solid rgba(255, 255, 255, 0.2);
146
+ border-radius: 10px;
147
+ padding: 20px;
148
+ box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
149
+ transition: transform 0.3s ease;
150
+ margin-bottom: 10px;
151
+ }
152
+ .gr-box:hover {
153
+ transform: translateY(-5px);
154
+ }
155
+ .gr-slider {
156
+ -webkit-appearance: none;
157
+ width: 100%;
158
+ height: 10px;
159
+ background: linear-gradient(135deg, #FF4E50, #EC9F05);
160
+ outline: none;
161
+ border-radius: 5px;
162
+ transition: background 0.3s ease;
163
+ }
164
+ .gr-slider::-webkit-slider-thumb {
165
+ -webkit-appearance: none;
166
+ appearance: none;
167
+ width: 25px;
168
+ height: 25px;
169
+ background: white;
170
+ border-radius: 50%;
171
+ cursor: pointer;
172
+ transition: transform 0.3s ease, box-shadow 0.3s ease;
173
+ }
174
+ .gr-slider::-webkit-slider-thumb:hover {
175
+ transform: scale(1.1);
176
+ box-shadow: 0 0 10px rgba(255, 78, 80, 0.8);
177
+ }
178
+ .gr-slider::-moz-range-thumb {
179
+ width: 25px;
180
+ height: 25px;
181
+ background: white;
182
+ border-radius: 50%;
183
+ cursor: pointer;
184
+ transition: transform 0.3s ease, box-shadow 0.3s ease;
185
+ }
186
+ .gr-slider::-moz-range-thumb:hover {
187
+ transform: scale(1.1);
188
+ box-shadow: 0 0 10px rgba(255, 78, 80, 0.8);
189
+ }
190
+ .gr-slider::-moz-range-track {
191
+ background: linear-gradient(135deg, #FF4E50, #EC9F05);
192
+ border-radius: 5px;
193
+ }
194
+ .gr-slider::-ms-track {
195
+ width: 100%;
196
+ height: 10px;
197
+ background: transparent;
198
+ border-color: transparent;
199
+ color: transparent;
200
+ }
201
+ .gr-slider::-ms-fill-lower {
202
+ background: linear-gradient(135deg, #FF4E50, #EC9F05);
203
+ border-radius: 5px;
204
+ }
205
+ .gr-slider::-ms-fill-upper {
206
+ background: linear-gradient(135deg, #FF4E50, #EC9F05);
207
+ border-radius: 5px;
208
+ }
209
+ .gr-slider::-ms-thumb {
210
+ width: 25px;
211
+ height: 25px;
212
+ background: white;
213
+ border-radius: 50%;
214
+ cursor: pointer;
215
+ transition: transform 0.3s ease, box-shadow 0.3s ease;
216
+ }
217
+ .gr-slider::-ms-thumb:hover {
218
+ transform: scale(1.1);
219
+ box-shadow: 0 0 10px rgba(255, 78, 80, 0.8);
220
+ }
221
+ .gr-label {
222
+ color: white;
223
+ font-size: 16px;
224
+ margin-bottom: 10px;
225
+ }
226
+ .gr-markdown {
227
+ color: white;
228
+ font-size: 14px;
229
+ }
230
+ </style>
231
+ """
232
+
233
  demo = gr.Interface(
234
  fn=tts_interface,
235
  inputs=[
236
+ gr.Textbox(label="Input Text", lines=5, elem_classes=["gr-box", "gr-label"]),
237
+ gr.Dropdown(choices=[""] + list(voices.keys()), label="Select Voice", value="", elem_classes=["gr-box", "gr-label"]),
238
+ gr.Slider(minimum=-50, maximum=50, value=0, label="Speech Rate Adjustment (%)", step=1, elem_classes=["gr-slider", "gr-label"]),
239
+ gr.Slider(minimum=-20, maximum=20, value=0, label="Pitch Adjustment (Hz)", step=1, elem_classes=["gr-slider", "gr-label"])
240
  ],
241
  outputs=[
242
  gr.Audio(label="Generated Audio", type="filepath"),
243
+ gr.Markdown(label="Warning", visible=False, elem_classes=["gr-markdown"])
244
  ],
245
+ title="<div class='gradient-text'>Edge TTS Text-to-Speech</div>",
246
  description=description,
247
+ article=css_style,
248
  analytics_enabled=False,
249
  allow_flagging="manual",
250
+ theme="compact"
251
  )
252
  return demo
253