temptrip commited on
Commit
eaeab3e
·
1 Parent(s): 0bb37b8
Files changed (3) hide show
  1. __pycache__/util.cpython-313.pyc +0 -0
  2. app.py +387 -381
  3. util.py +2 -0
__pycache__/util.cpython-313.pyc CHANGED
Binary files a/__pycache__/util.cpython-313.pyc and b/__pycache__/util.cpython-313.pyc differ
 
app.py CHANGED
@@ -1,382 +1,388 @@
1
- import gradio as gr
2
- import time
3
- import uuid
4
- from util import (
5
- create_task_v3,
6
- get_task_result,
7
- )
8
-
9
-
10
- IP_Dict = {}
11
-
12
- def generate_trump_voice_with_realtime_updates(text, word_num, request: gr.Request):
13
- """
14
- Trump AI voice generation function with real-time status updates
15
- """
16
- client_ip = request.client.host
17
- x_forwarded_for = dict(request.headers).get('x-forwarded-for')
18
- if x_forwarded_for:
19
- client_ip = x_forwarded_for
20
- if client_ip not in IP_Dict:
21
- IP_Dict[client_ip] = 0
22
- IP_Dict[client_ip] += 1
23
- print(f"client_ip: {client_ip}, count: {IP_Dict[client_ip]}")
24
- if IP_Dict[client_ip] > 5:
25
- msg = "You have reached the maximum number of requests"
26
- # Create "Get More Tries" button HTML
27
- get_more_tries_html = f"""
28
- <div style='display: flex; justify-content: center; gap: 30px; margin: 10px 0 25px 0; padding: 0px;'>
29
- <a href='https://donaldtrumpaivoice.com/#generator' target='_blank' style='
30
- display: inline-flex;
31
- align-items: center;
32
- justify-content: center;
33
- padding: 16px 32px;
34
- background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
35
- color: white;
36
- text-decoration: none;
37
- border-radius: 12px;
38
- font-weight: 600;
39
- font-size: 16px;
40
- text-align: center;
41
- min-width: 160px;
42
- box-shadow: 0 4px 15px rgba(17, 153, 142, 0.4);
43
- transition: all 0.3s ease;
44
- border: none;
45
- '>🚀 Get More Tries for Free</a>
46
- </div>
47
- """
48
- yield msg, None, "", gr.update(value=get_more_tries_html, visible=True), ""
49
- return msg, None, "", gr.update(value=get_more_tries_html, visible=True), ""
50
-
51
- if not text or len(text.strip()) < 3:
52
- return "Text too short, please enter at least 3 characters", None, "No task information", gr.update(visible=False), ""
53
-
54
- try:
55
- task_type = "voice"
56
-
57
- # Create task
58
- task_result = create_task_v3(task_type, text.strip(), word_num, is_rewrite=False)
59
- if not task_result:
60
- return "Failed to create task", None, "Task creation failed", gr.update(visible=False), ""
61
- else:
62
- yield "Task created successfully", None, "Task creation successful", gr.update(visible=False), ""
63
-
64
- max_polls = 300
65
- poll_interval = 1
66
- task_url = f"https://donaldtrumpaivoice.com/task/{task_result['uuid']}"
67
-
68
- for i in range(max_polls):
69
- time.sleep(poll_interval)
70
- task = get_task_result(task_result['uuid'])
71
- # print(task, i, "get_task_result")
72
- if task.get('data', {}):
73
- status = task.get('data').get('status', '')
74
- text_final = task.get('data').get('text_final', '')
75
- if status in ['completed',]:
76
- voice_url = task.get('data').get('voice_url', '')
77
- # Create action buttons HTML
78
- action_buttons_html = f"""
79
- <div style='display: flex; justify-content: center; gap: 30px; margin: 25px 0; padding: 20px;'>
80
- <a href='https://donaldtrumpaivoice.com/#generator' target='_blank' style='
81
- display: inline-flex;
82
- align-items: center;
83
- justify-content: center;
84
- padding: 16px 32px;
85
- background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
86
- color: white;
87
- text-decoration: none;
88
- border-radius: 12px;
89
- font-weight: 600;
90
- font-size: 16px;
91
- text-align: center;
92
- min-width: 160px;
93
- box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
94
- transition: all 0.3s ease;
95
- border: none;
96
- '>🎬 Generate Video</a>
97
- <a href='{task_url}' target='_blank' style='
98
- display: inline-flex;
99
- align-items: center;
100
- justify-content: center;
101
- padding: 16px 32px;
102
- background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
103
- color: white;
104
- text-decoration: none;
105
- border-radius: 12px;
106
- font-weight: 600;
107
- font-size: 16px;
108
- text-align: center;
109
- min-width: 160px;
110
- box-shadow: 0 4px 15px rgba(17, 153, 142, 0.4);
111
- transition: all 0.3s ease;
112
- border: none;
113
- '>👀 Check Generate Details</a>
114
- </div>
115
- """
116
- yield f"✅ success!!!", voice_url, text_final, gr.update(value=action_buttons_html, visible=True), task_url
117
- return "✅ Generation successful!", voice_url, "success", gr.update(value=action_buttons_html, visible=True), task_url
118
- elif status in ['failed', 'voice_error', 'no_credits']:
119
- yield "❌ Generation failed!", None, None, gr.update(visible=False), ""
120
- return "❌ Generation failed!", None, None, gr.update(visible=False), ""
121
- else:
122
- yield f"query {i} times, on processing, go to task page {task_url} to check status", None, text_final, gr.update(visible=False), task_url
123
- return "❌ Generation failed!", None, None, gr.update(visible=False), ""
124
- except Exception as e:
125
- error_msg = f"Generation failed: {str(e)}"
126
- yield error_msg, None, f"❌ Error message: {error_msg}", gr.update(visible=False), ""
127
- return error_msg, None, f"❌ Error message: {error_msg}", gr.update(visible=False), ""
128
-
129
- # Create Gradio Interface
130
- with gr.Blocks(title="Donald Trump AI Voice", theme=gr.themes.Soft()) as demo:
131
-
132
- # Main title - at the top
133
- gr.HTML("""
134
- <div style="text-align: center; margin: 5px auto 0px auto; max-width: 800px;">
135
- <h1 style="color: #2c3e50; margin: 0; font-size: 3.5em; font-weight: 800; letter-spacing: 3px; text-shadow: 2px 2px 4px rgba(0,0,0,0.1);">
136
- 🎤 Trump AI Voice
137
- </h1>
138
- </div>
139
- """, padding=False)
140
-
141
- # # Showcase link banner - second
142
- # gr.HTML("""
143
- # <div style="text-align: center; margin: 0px auto 40px auto; max-width: 600px;">
144
- # <div style="background: linear-gradient(135deg, #ff6b6b 0%, #feca57 50%, #48dbfb 100%); padding: 15px 5px; border-radius: 15px; box-shadow: 0 8px 25px rgba(255, 107, 107, 0.3);">
145
- # <h3 style="color: white; margin: 0; font-size: 18px;">
146
- # 🎬 <a href="https://donaldtrumpaivoice.com/showcase" target="_blank" style="color: white; text-decoration: none; font-weight: bold;">Check out Trump AI videos created by others →</a>
147
- # </h3>
148
- # </div>
149
- # </div>
150
- # """, padding=False)
151
-
152
- # Powered by link - small text
153
- gr.HTML("""
154
- <div style="text-align: center; margin: 0px auto -5px auto;">
155
- <p style="margin: 0; font-size: 16px; color: #999; font-weight: 400;">
156
- powered by <a href="https://donaldtrumpaivoice.com/" target="_blank" style="color: #667eea; text-decoration: none;">donaldtrumpaivoice.com</a>
157
- </p>
158
- </div>
159
- """, padding=False)
160
-
161
- # Simple description text - third
162
- # gr.HTML("""
163
- # <div style="text-align: center; margin: 15px auto 30px auto; max-width: 500px;">
164
- # <p style="color: #666; margin: 0; font-size: 1em; font-weight: 500; line-height: 1.4;">
165
- # 🔥 Try the most advanced Trump AI Voice and Video generator for FREE at
166
- # <a href="https://donaldtrumpaivoice.com/" target="_blank" style="color: #667eea; text-decoration: none; font-weight: bold;">donaldtrumpaivoice.com</a>!
167
- # </p>
168
- # </div>
169
- # """)
170
-
171
- with gr.Row():
172
- with gr.Column(scale=2):
173
- text_input = gr.Textbox(
174
- label="📝 Input Text",
175
- lines=4,
176
- placeholder="Enter what you want Trump to say...",
177
- value="Hello everyone, this is a demonstration of the Trump AI Voice system with real-time status monitoring."
178
- )
179
-
180
- with gr.Column(scale=1):
181
- word_num_slider = gr.Slider(
182
- 20, 60, value=60, step=1,
183
- label="⏱️ Duration Limit"
184
- )
185
-
186
- submit_btn = gr.Button(
187
- "🚀 Generate Trump AI Voice",
188
- variant="primary",
189
- size="lg"
190
- )
191
-
192
- with gr.Row():
193
- status_output = gr.Textbox(
194
- label="📊 Status",
195
- interactive=False,
196
- placeholder="Waiting for generation..."
197
- )
198
-
199
- # Action buttons that will show after task completion
200
- with gr.Row():
201
- action_links = gr.HTML(visible=False)
202
-
203
- with gr.Row():
204
- audio_output = gr.Audio(
205
- label="🎵 Trump AI Voice",
206
- interactive=False
207
- )
208
-
209
- with gr.Row():
210
- task_info = gr.Textbox(
211
- label="📋 AI Rewritten Text with Latest News",
212
- interactive=False,
213
- lines=12,
214
- placeholder="AI rewritten text with the latest news will be shown here..."
215
- )
216
-
217
-
218
- # Comprehensive introduction section
219
- gr.HTML("""
220
- <div style="width: 100%; margin: 30px 0; padding: 0 20px;">
221
-
222
- <!-- Hero Description -->
223
- <div style="text-align: center; margin: 25px auto; background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%); padding: 30px; border-radius: 20px; box-shadow: 0 10px 30px rgba(0,0,0,0.1);">
224
- <h2 style="color: #2c3e50; margin: 0 0 15px 0; font-size: 1.8em; font-weight: 700;">
225
- 🇺🇸 Experience the Power of AI-Generated Trump Voice
226
- </h2>
227
- <p style="color: #555; font-size: 1.1em; line-height: 1.6; margin: 0 0 20px 0; width: 100%; padding: 0 20px;">
228
- Transform any text into authentic Donald Trump speech with our cutting-edge AI voice synthesis technology.
229
- Whether you're creating content for entertainment, education, or social media, our advanced neural network
230
- captures Trump's distinctive speaking style, intonation, and rhetorical patterns with remarkable accuracy.
231
- </p>
232
- <div style="text-align: center; margin: 15px 0;">
233
- <a href="https://donaldtrumpaivoice.com/" target="_blank" style="
234
- display: inline-flex;
235
- align-items: center;
236
- justify-content: center;
237
- padding: 12px 28px;
238
- background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
239
- color: white;
240
- text-decoration: none;
241
- border-radius: 10px;
242
- font-weight: 600;
243
- font-size: 14px;
244
- box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
245
- transition: all 0.3s ease;
246
- ">🎬 Generate Trump AI Videos & More →</a>
247
- </div>
248
- </div>
249
-
250
- <!-- Features Grid -->
251
- <div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; margin: 40px 0;">
252
-
253
- <div style="background: white; padding: 25px; border-radius: 15px; box-shadow: 0 5px 20px rgba(0,0,0,0.08); border-left: 5px solid #e74c3c;">
254
- <h3 style="color: #e74c3c; margin: 0 0 12px 0; font-size: 1.3em; font-weight: 600;">
255
- 🎯 Ultra-Realistic Voice
256
- </h3>
257
- <p style="color: #666; margin: 0; line-height: 1.5; font-size: 0.95em;">
258
- Our AI model is trained on thousands of hours of Trump speeches, capturing his unique vocal characteristics,
259
- pronunciation patterns, and speaking rhythm to deliver incredibly lifelike results.
260
- </p>
261
- </div>
262
-
263
- <div style="background: white; padding: 25px; border-radius: 15px; box-shadow: 0 5px 20px rgba(0,0,0,0.08); border-left: 5px solid #3498db;">
264
- <h3 style="color: #3498db; margin: 0 0 12px 0; font-size: 1.3em; font-weight: 600;">
265
- ⚡ Lightning Fast Generation
266
- </h3>
267
- <p style="color: #666; margin: 0; line-height: 1.5; font-size: 0.95em;">
268
- Generate high-quality Trump AI voice clips in seconds, not minutes. Our optimized infrastructure
269
- ensures rapid processing while maintaining exceptional audio quality.
270
- </p>
271
- </div>
272
-
273
- <div style="background: white; padding: 25px; border-radius: 15px; box-shadow: 0 5px 20px rgba(0,0,0,0.08); border-left: 5px solid #27ae60;">
274
- <h3 style="color: #27ae60; margin: 0 0 12px 0; font-size: 1.3em; font-weight: 600;">
275
- 🎨 Creative Content Creation
276
- </h3>
277
- <p style="color: #666; margin: 0; line-height: 1.5; font-size: 0.95em;">
278
- Perfect for memes, podcasts, educational content, entertainment videos, or any creative project
279
- that needs an authentic Trump voice performance.
280
- </p>
281
- </div>
282
-
283
- </div>
284
-
285
-
286
- <!-- Full Features Section -->
287
- <div style="background: linear-gradient(135deg, #ff6b6b 0%, #feca57 50%, #48dbfb 100%); color: white; padding: 40px; border-radius: 20px; margin: 40px 0; text-align: center;">
288
- <h2 style="margin: 0 0 20px 0; font-size: 1.8em; font-weight: 700;">
289
- 🎬 Want More Advanced Features?
290
- </h2>
291
- <p style="margin: 0 0 25px 0; font-size: 1.1em; opacity: 0.95; line-height: 1.5;">
292
- Experience the full power of Trump AI Voice with video generation, multiple templates,
293
- AI news rewriting, and much more on our main platform!
294
- </p>
295
- <div style="display: flex; justify-content: center; gap: 20px; flex-wrap: wrap;">
296
- <a href="https://donaldtrumpaivoice.com/" target="_blank" style="
297
- display: inline-flex;
298
- align-items: center;
299
- justify-content: center;
300
- padding: 18px 35px;
301
- background: rgba(255,255,255,0.9);
302
- color: #333;
303
- text-decoration: none;
304
- border-radius: 15px;
305
- font-weight: 700;
306
- font-size: 16px;
307
- text-align: center;
308
- min-width: 200px;
309
- box-shadow: 0 6px 20px rgba(0,0,0,0.3);
310
- transition: all 0.3s ease;
311
- border: none;
312
- ">🚀 Try Full Platform</a>
313
- <a href="https://donaldtrumpaivoice.com/showcase" target="_blank" style="
314
- display: inline-flex;
315
- align-items: center;
316
- justify-content: center;
317
- padding: 18px 35px;
318
- background: rgba(255,255,255,0.2);
319
- color: white;
320
- text-decoration: none;
321
- border-radius: 15px;
322
- font-weight: 700;
323
- font-size: 16px;
324
- text-align: center;
325
- min-width: 200px;
326
- box-shadow: 0 6px 20px rgba(0,0,0,0.2);
327
- transition: all 0.3s ease;
328
- border: 2px solid rgba(255,255,255,0.3);
329
- ">🎭 View Showcase</a>
330
- </div>
331
- </div>
332
-
333
- <!-- Tips Section -->
334
- <div style="background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 50%, #fecfef 100%); padding: 25px; border-radius: 15px; margin: 40px 0;">
335
- <h3 style="color: #8b5cf6; text-align: center; margin: 0 0 20px 0; font-size: 1.4em; font-weight: 700;">
336
- 💡 Pro Tips for Best Results
337
- </h3>
338
- <div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 15px;">
339
-
340
- <div style="background: rgba(255,255,255,0.8); padding: 15px; border-radius: 10px;">
341
- <strong style="color: #8b5cf6;">📖 Clear Text:</strong>
342
- <span style="color: #555;"> Use proper punctuation and avoid special characters for optimal results.</span>
343
- </div>
344
-
345
- <div style="background: rgba(255,255,255,0.8); padding: 15px; border-radius: 10px;">
346
- <strong style="color: #8b5cf6;">⏱️ Length Matters:</strong>
347
- <span style="color: #555;"> Shorter texts (20-60 words) typically produce the most natural-sounding results.</span>
348
- </div>
349
-
350
- <div style="background: rgba(255,255,255,0.8); padding: 15px; border-radius: 10px;">
351
- <strong style="color: #8b5cf6;">🎯 Trump Style:</strong>
352
- <span style="color: #555;"> Text written in Trump's speaking style will sound more authentic and natural.</span>
353
- </div>
354
-
355
- </div>
356
- </div>
357
-
358
- </div>
359
- """, padding=False)
360
-
361
-
362
- # Powered by link - small text
363
- gr.HTML("""
364
- <div style="text-align: center; margin: 0px auto -5px auto;">
365
- <p style="margin: 0; font-size: 16px; color: #999; font-weight: 400;">
366
- Click <a href="https://donaldtrumpaivoice.com/showcase" target="_blank" style="color: #667eea; text-decoration: none;"> trump ai voices showcase </a> to see more videos
367
- </p>
368
- </div>
369
- """, padding=False)
370
-
371
- # Hidden state to store task_url
372
- task_url_state = gr.State("")
373
-
374
- # Bind event
375
- submit_btn.click(
376
- generate_trump_voice_with_realtime_updates,
377
- inputs=[text_input, word_num_slider],
378
- outputs=[status_output, audio_output, task_info, action_links, task_url_state]
379
- )
380
-
381
- if __name__ == "__main__":
 
 
 
 
 
 
382
  demo.launch()
 
1
+ import gradio as gr
2
+ import time
3
+ import uuid
4
+ from util import (
5
+ create_task_v3,
6
+ get_task_result,
7
+ )
8
+
9
+
10
+ IP_Dict = {}
11
+
12
+ def generate_trump_voice_with_realtime_updates(text, word_num, request: gr.Request):
13
+ """
14
+ Trump AI voice generation function with real-time status updates
15
+ """
16
+ client_ip = request.client.host
17
+ x_forwarded_for = dict(request.headers).get('x-forwarded-for')
18
+ if x_forwarded_for:
19
+ client_ip = x_forwarded_for
20
+ if client_ip not in IP_Dict:
21
+ IP_Dict[client_ip] = 0
22
+ IP_Dict[client_ip] += 1
23
+ print(f"client_ip: {client_ip}, count: {IP_Dict[client_ip]}")
24
+ if IP_Dict[client_ip] > 5:
25
+ msg = "You have reached the maximum number of requests"
26
+ # Create "Get More Tries" button HTML
27
+ get_more_tries_html = f"""
28
+ <div style='display: flex; justify-content: center; gap: 30px; margin: 10px 0 25px 0; padding: 0px;'>
29
+ <a href='https://trumpaivoice.net/#generator' target='_blank' style='
30
+ display: inline-flex;
31
+ align-items: center;
32
+ justify-content: center;
33
+ padding: 16px 32px;
34
+ background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
35
+ color: white;
36
+ text-decoration: none;
37
+ border-radius: 12px;
38
+ font-weight: 600;
39
+ font-size: 16px;
40
+ text-align: center;
41
+ min-width: 160px;
42
+ box-shadow: 0 4px 15px rgba(17, 153, 142, 0.4);
43
+ transition: all 0.3s ease;
44
+ border: none;
45
+ '>🚀 Get More Tries for Free</a>
46
+ </div>
47
+ """
48
+ yield msg, None, "", gr.update(value=get_more_tries_html, visible=True), ""
49
+ return msg, None, "", gr.update(value=get_more_tries_html, visible=True), ""
50
+
51
+ if not text or len(text.strip()) < 3:
52
+ return "Text too short, please enter at least 3 characters", None, "No task information", gr.update(visible=False), ""
53
+
54
+ try:
55
+ task_type = "voice"
56
+
57
+ # Create task
58
+ task_result = create_task_v3(task_type, text.strip(), word_num, is_rewrite=False)
59
+ if not task_result:
60
+ return "Failed to create task", None, "Task creation failed", gr.update(visible=False), ""
61
+ else:
62
+ yield "Task created successfully", None, "Task creation successful", gr.update(visible=False), ""
63
+
64
+ max_polls = 300
65
+ poll_interval = 1
66
+ task_url = f"https://trumpaivoice.net/task/{task_result['uuid']}"
67
+
68
+ for i in range(max_polls):
69
+ time.sleep(poll_interval)
70
+ task = get_task_result(task_result['uuid'])
71
+ # print(task, i, "get_task_result")
72
+ if task.get('data', {}):
73
+ status = task.get('data').get('status', '')
74
+ text_final = task.get('data').get('text_final', '')
75
+ if status in ['completed',]:
76
+ voice_url = task.get('data').get('voice_url', '')
77
+ print(voice_url, "===>voice_url")
78
+
79
+ # 下载音频文件到本地以避免SSRF保护问题
80
+ local_audio_path = download_audio_file(voice_url)
81
+
82
+ # Create action buttons HTML
83
+ action_buttons_html = f"""
84
+ <div style='display: flex; justify-content: center; gap: 30px; margin: 25px 0; padding: 20px;'>
85
+ <a href='https://trumpaivoice.net/#generator' target='_blank' style='
86
+ display: inline-flex;
87
+ align-items: center;
88
+ justify-content: center;
89
+ padding: 16px 32px;
90
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
91
+ color: white;
92
+ text-decoration: none;
93
+ border-radius: 12px;
94
+ font-weight: 600;
95
+ font-size: 16px;
96
+ text-align: center;
97
+ min-width: 160px;
98
+ box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
99
+ transition: all 0.3s ease;
100
+ border: none;
101
+ '>🎬 Generate Video</a>
102
+ <a href='{task_url}' target='_blank' style='
103
+ display: inline-flex;
104
+ align-items: center;
105
+ justify-content: center;
106
+ padding: 16px 32px;
107
+ background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
108
+ color: white;
109
+ text-decoration: none;
110
+ border-radius: 12px;
111
+ font-weight: 600;
112
+ font-size: 16px;
113
+ text-align: center;
114
+ min-width: 160px;
115
+ box-shadow: 0 4px 15px rgba(17, 153, 142, 0.4);
116
+ transition: all 0.3s ease;
117
+ border: none;
118
+ '>👀 Check Generate Details</a>
119
+ </div>
120
+ """
121
+ yield f"✅ success!!!", local_audio_path, text_final, gr.update(value=action_buttons_html, visible=True), task_url
122
+ return " Generation successful!", local_audio_path, "success", gr.update(value=action_buttons_html, visible=True), task_url
123
+ elif status in ['failed', 'voice_error', 'no_credits']:
124
+ yield "❌ Generation failed!", None, None, gr.update(visible=False), ""
125
+ return "❌ Generation failed!", None, None, gr.update(visible=False), ""
126
+ else:
127
+ yield f"query {i} times, on processing, go to task page {task_url} to check status", None, text_final, gr.update(visible=False), task_url
128
+ return "❌ Generation failed!", None, None, gr.update(visible=False), ""
129
+ except Exception as e:
130
+ error_msg = f"Generation failed: {str(e)}"
131
+ yield error_msg, None, f"❌ Error message: {error_msg}", gr.update(visible=False), ""
132
+ return error_msg, None, f"❌ Error message: {error_msg}", gr.update(visible=False), ""
133
+
134
+ # Create Gradio Interface
135
+ with gr.Blocks(title="Donald Trump AI Voice", theme=gr.themes.Soft()) as demo:
136
+
137
+ # Main title - at the top
138
+ gr.HTML("""
139
+ <div style="text-align: center; margin: 5px auto 0px auto; max-width: 800px;">
140
+ <h1 style="color: #2c3e50; margin: 0; font-size: 3.5em; font-weight: 800; letter-spacing: 3px; text-shadow: 2px 2px 4px rgba(0,0,0,0.1);">
141
+ 🎤 Trump AI Voice
142
+ </h1>
143
+ </div>
144
+ """, padding=False)
145
+
146
+ # # Showcase link banner - second
147
+ # gr.HTML("""
148
+ # <div style="text-align: center; margin: 0px auto 40px auto; max-width: 600px;">
149
+ # <div style="background: linear-gradient(135deg, #ff6b6b 0%, #feca57 50%, #48dbfb 100%); padding: 15px 5px; border-radius: 15px; box-shadow: 0 8px 25px rgba(255, 107, 107, 0.3);">
150
+ # <h3 style="color: white; margin: 0; font-size: 18px;">
151
+ # 🎬 <a href="https://trumpaivoice.net/showcase" target="_blank" style="color: white; text-decoration: none; font-weight: bold;">Check out Trump AI videos created by others →</a>
152
+ # </h3>
153
+ # </div>
154
+ # </div>
155
+ # """, padding=False)
156
+
157
+ # Powered by link - small text
158
+ gr.HTML("""
159
+ <div style="text-align: center; margin: 0px auto -5px auto;">
160
+ <p style="margin: 0; font-size: 16px; color: #999; font-weight: 400;">
161
+ powered by <a href="https://trumpaivoice.net/" target="_blank" style="color: #667eea; text-decoration: none;">trumpaivoice.net</a>
162
+ </p>
163
+ </div>
164
+ """, padding=False)
165
+
166
+ # Simple description text - third
167
+ # gr.HTML("""
168
+ # <div style="text-align: center; margin: 15px auto 30px auto; max-width: 500px;">
169
+ # <p style="color: #666; margin: 0; font-size: 1em; font-weight: 500; line-height: 1.4;">
170
+ # 🔥 Try the most advanced Trump AI Voice and Video generator for FREE at
171
+ # <a href="https://trumpaivoice.net/" target="_blank" style="color: #667eea; text-decoration: none; font-weight: bold;">donaldtrumpaivoice.com</a>!
172
+ # </p>
173
+ # </div>
174
+ # """)
175
+
176
+ with gr.Row():
177
+ with gr.Column(scale=2):
178
+ text_input = gr.Textbox(
179
+ label="📝 Input Text",
180
+ lines=4,
181
+ placeholder="Enter what you want Trump to say...",
182
+ value="Hello everyone, this is a demonstration of the Trump AI Voice system with real-time status monitoring."
183
+ )
184
+
185
+ with gr.Column(scale=1):
186
+ word_num_slider = gr.Slider(
187
+ 20, 60, value=60, step=1,
188
+ label="⏱️ Duration Limit"
189
+ )
190
+
191
+ submit_btn = gr.Button(
192
+ "🚀 Generate Trump AI Voice",
193
+ variant="primary",
194
+ size="lg"
195
+ )
196
+
197
+ with gr.Row():
198
+ status_output = gr.Textbox(
199
+ label="📊 Status",
200
+ interactive=False,
201
+ placeholder="Waiting for generation..."
202
+ )
203
+
204
+ # Action buttons that will show after task completion
205
+ with gr.Row():
206
+ action_links = gr.HTML(visible=False)
207
+
208
+ with gr.Row():
209
+ audio_output = gr.Audio(
210
+ label="🎵 Trump AI Voice",
211
+ interactive=False
212
+ )
213
+
214
+ with gr.Row():
215
+ task_info = gr.Textbox(
216
+ label="📋 AI Rewritten Text with Latest News",
217
+ interactive=False,
218
+ lines=12,
219
+ placeholder="AI rewritten text with the latest news will be shown here..."
220
+ )
221
+
222
+
223
+ # Comprehensive introduction section
224
+ gr.HTML("""
225
+ <div style="width: 100%; margin: 30px 0; padding: 0 20px;">
226
+
227
+ <!-- Hero Description -->
228
+ <div style="text-align: center; margin: 25px auto; background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%); padding: 30px; border-radius: 20px; box-shadow: 0 10px 30px rgba(0,0,0,0.1);">
229
+ <h2 style="color: #2c3e50; margin: 0 0 15px 0; font-size: 1.8em; font-weight: 700;">
230
+ 🇺🇸 Experience the Power of AI-Generated Trump Voice
231
+ </h2>
232
+ <p style="color: #555; font-size: 1.1em; line-height: 1.6; margin: 0 0 20px 0; width: 100%; padding: 0 20px;">
233
+ Transform any text into authentic Donald Trump speech with our cutting-edge AI voice synthesis technology.
234
+ Whether you're creating content for entertainment, education, or social media, our advanced neural network
235
+ captures Trump's distinctive speaking style, intonation, and rhetorical patterns with remarkable accuracy.
236
+ </p>
237
+ <div style="text-align: center; margin: 15px 0;">
238
+ <a href="https://trumpaivoice.net/" target="_blank" style="
239
+ display: inline-flex;
240
+ align-items: center;
241
+ justify-content: center;
242
+ padding: 12px 28px;
243
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
244
+ color: white;
245
+ text-decoration: none;
246
+ border-radius: 10px;
247
+ font-weight: 600;
248
+ font-size: 14px;
249
+ box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
250
+ transition: all 0.3s ease;
251
+ ">🎬 Generate Trump AI Videos & More →</a>
252
+ </div>
253
+ </div>
254
+
255
+ <!-- Features Grid -->
256
+ <div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; margin: 40px 0;">
257
+
258
+ <div style="background: white; padding: 25px; border-radius: 15px; box-shadow: 0 5px 20px rgba(0,0,0,0.08); border-left: 5px solid #e74c3c;">
259
+ <h3 style="color: #e74c3c; margin: 0 0 12px 0; font-size: 1.3em; font-weight: 600;">
260
+ 🎯 Ultra-Realistic Voice
261
+ </h3>
262
+ <p style="color: #666; margin: 0; line-height: 1.5; font-size: 0.95em;">
263
+ Our AI model is trained on thousands of hours of Trump speeches, capturing his unique vocal characteristics,
264
+ pronunciation patterns, and speaking rhythm to deliver incredibly lifelike results.
265
+ </p>
266
+ </div>
267
+
268
+ <div style="background: white; padding: 25px; border-radius: 15px; box-shadow: 0 5px 20px rgba(0,0,0,0.08); border-left: 5px solid #3498db;">
269
+ <h3 style="color: #3498db; margin: 0 0 12px 0; font-size: 1.3em; font-weight: 600;">
270
+ ⚡ Lightning Fast Generation
271
+ </h3>
272
+ <p style="color: #666; margin: 0; line-height: 1.5; font-size: 0.95em;">
273
+ Generate high-quality Trump AI voice clips in seconds, not minutes. Our optimized infrastructure
274
+ ensures rapid processing while maintaining exceptional audio quality.
275
+ </p>
276
+ </div>
277
+
278
+ <div style="background: white; padding: 25px; border-radius: 15px; box-shadow: 0 5px 20px rgba(0,0,0,0.08); border-left: 5px solid #27ae60;">
279
+ <h3 style="color: #27ae60; margin: 0 0 12px 0; font-size: 1.3em; font-weight: 600;">
280
+ 🎨 Creative Content Creation
281
+ </h3>
282
+ <p style="color: #666; margin: 0; line-height: 1.5; font-size: 0.95em;">
283
+ Perfect for memes, podcasts, educational content, entertainment videos, or any creative project
284
+ that needs an authentic Trump voice performance.
285
+ </p>
286
+ </div>
287
+
288
+ </div>
289
+
290
+
291
+ <!-- Celebrity Voices Section -->
292
+ <div style="background: linear-gradient(135deg, #ff6b6b 0%, #feca57 50%, #48dbfb 100%); color: white; padding: 40px; border-radius: 20px; margin: 40px 0; text-align: center;">
293
+ <h2 style="margin: 0 0 20px 0; font-size: 1.8em; font-weight: 700;">
294
+ 🎭 Try More Celebrity AI Voices
295
+ </h2>
296
+ <p style="margin: 0 0 25px 0; font-size: 1.1em; opacity: 0.95; line-height: 1.5;">
297
+ Explore our premium collection of celebrity AI voices! Our high-quality service delivers
298
+ lightning-fast results with exceptional audio quality. Experience the best AI voice generation
299
+ with our reliable and responsive platform.
300
+ </p>
301
+ <div style="display: flex; justify-content: center; gap: 20px; flex-wrap: wrap;">
302
+ <a href="https://trumpaivoice.net/explore" target="_blank" style="
303
+ display: inline-flex;
304
+ align-items: center;
305
+ justify-content: center;
306
+ padding: 18px 35px;
307
+ background: rgba(255,255,255,0.9);
308
+ color: #333;
309
+ text-decoration: none;
310
+ border-radius: 15px;
311
+ font-weight: 700;
312
+ font-size: 16px;
313
+ text-align: center;
314
+ min-width: 200px;
315
+ box-shadow: 0 6px 20px rgba(0,0,0,0.3);
316
+ transition: all 0.3s ease;
317
+ border: none;
318
+ ">🌟 Explore Celebrity Voices</a>
319
+ <a href="https://trumpaivoice.net/showcase" target="_blank" style="
320
+ display: inline-flex;
321
+ align-items: center;
322
+ justify-content: center;
323
+ padding: 18px 35px;
324
+ background: rgba(255,255,255,0.2);
325
+ color: white;
326
+ text-decoration: none;
327
+ border-radius: 15px;
328
+ font-weight: 700;
329
+ font-size: 16px;
330
+ text-align: center;
331
+ min-width: 200px;
332
+ box-shadow: 0 6px 20px rgba(0,0,0,0.2);
333
+ transition: all 0.3s ease;
334
+ border: 2px solid rgba(255,255,255,0.3);
335
+ ">🎭 View Showcase</a>
336
+ </div>
337
+ </div>
338
+
339
+ <!-- Tips Section -->
340
+ <div style="background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 50%, #fecfef 100%); padding: 25px; border-radius: 15px; margin: 40px 0;">
341
+ <h3 style="color: #8b5cf6; text-align: center; margin: 0 0 20px 0; font-size: 1.4em; font-weight: 700;">
342
+ 💡 Pro Tips for Best Results
343
+ </h3>
344
+ <div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 15px;">
345
+
346
+ <div style="background: rgba(255,255,255,0.8); padding: 15px; border-radius: 10px;">
347
+ <strong style="color: #8b5cf6;">📖 Clear Text:</strong>
348
+ <span style="color: #555;"> Use proper punctuation and avoid special characters for optimal results.</span>
349
+ </div>
350
+
351
+ <div style="background: rgba(255,255,255,0.8); padding: 15px; border-radius: 10px;">
352
+ <strong style="color: #8b5cf6;">⏱️ Length Matters:</strong>
353
+ <span style="color: #555;"> Shorter texts (20-60 words) typically produce the most natural-sounding results.</span>
354
+ </div>
355
+
356
+ <div style="background: rgba(255,255,255,0.8); padding: 15px; border-radius: 10px;">
357
+ <strong style="color: #8b5cf6;">🎯 Trump Style:</strong>
358
+ <span style="color: #555;"> Text written in Trump's speaking style will sound more authentic and natural.</span>
359
+ </div>
360
+
361
+ </div>
362
+ </div>
363
+
364
+ </div>
365
+ """, padding=False)
366
+
367
+
368
+ # Powered by link - small text
369
+ gr.HTML("""
370
+ <div style="text-align: center; margin: 0px auto -5px auto;">
371
+ <p style="margin: 0; font-size: 16px; color: #999; font-weight: 400;">
372
+ Click <a href="https://trumpaivoice.net/showcase" target="_blank" style="color: #667eea; text-decoration: none;"> trump ai voices showcase </a> to see more videos
373
+ </p>
374
+ </div>
375
+ """, padding=False)
376
+
377
+ # Hidden state to store task_url
378
+ task_url_state = gr.State("")
379
+
380
+ # Bind event
381
+ submit_btn.click(
382
+ generate_trump_voice_with_realtime_updates,
383
+ inputs=[text_input, word_num_slider],
384
+ outputs=[status_output, audio_output, task_info, action_links, task_url_state]
385
+ )
386
+
387
+ if __name__ == "__main__":
388
  demo.launch()
util.py CHANGED
@@ -16,6 +16,8 @@ try:
16
  BackendUrl = OneKey[4]
17
  BackendApiKey = OneKey[5]
18
  SUPABASE_KEY = OneKey[6]
 
 
19
  except Exception as e:
20
  print(f"OneKey: {e}")
21
  # exit(1)
 
16
  BackendUrl = OneKey[4]
17
  BackendApiKey = OneKey[5]
18
  SUPABASE_KEY = OneKey[6]
19
+ # GRADIO_ALLOWED_HOSTNAMES = OneKey[7]
20
+ # os.environ["GRADIO_ALLOWED_HOSTNAMES"] = GRADIO_ALLOWED_HOSTNAMES
21
  except Exception as e:
22
  print(f"OneKey: {e}")
23
  # exit(1)