selfitcamera commited on
Commit
ea6bfb0
·
1 Parent(s): ed0625d
Files changed (5) hide show
  1. __pycache__/util.cpython-313.pyc +0 -0
  2. app.py +552 -0
  3. push.sh +13 -0
  4. requirements.txt +4 -0
  5. util.py +119 -0
__pycache__/util.cpython-313.pyc ADDED
Binary file (4.83 kB). View file
 
app.py ADDED
@@ -0,0 +1,552 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import time
3
+ import uuid
4
+ import re
5
+ from util import (
6
+ create_task_v3,
7
+ get_task_result,
8
+ )
9
+
10
+
11
+ IP_Dict = {}
12
+
13
+ # 支持的语言列表
14
+ SUPPORTED_LANGUAGES = [
15
+ {"flag": "🇺🇸", "name": "English", "code": "en"},
16
+ {"flag": "🇨🇳", "name": "中文", "code": "zh"},
17
+ {"flag": "🇪🇸", "name": "Español", "code": "es"},
18
+ {"flag": "🇫🇷", "name": "Français", "code": "fr"},
19
+ {"flag": "🇩🇪", "name": "Deutsch", "code": "de"},
20
+ {"flag": "🇮🇹", "name": "Italiano", "code": "it"},
21
+ {"flag": "🇯🇵", "name": "日本語", "code": "ja"},
22
+ {"flag": "🇰🇷", "name": "한국어", "code": "ko"},
23
+ {"flag": "🇷🇺", "name": "Русский", "code": "ru"}
24
+ ]
25
+
26
+ def detect_language(text):
27
+ """
28
+ 语言检测函数 - 只检测容易区分的语言
29
+ """
30
+ if len(text) < 5:
31
+ return None
32
+
33
+ # 语言特征字符
34
+ language_features = {
35
+ "zh": re.compile(r'[\u4e00-\u9fff\u3400-\u4dbf\uff00-\uffef\u3000-\u303f]'),
36
+ "ja": re.compile(r'[\u3040-\u309f\u30a0-\u30ff]'),
37
+ "ko": re.compile(r'[\uac00-\ud7af]'),
38
+ "ru": re.compile(r'[\u0400-\u04ff]')
39
+ }
40
+
41
+ scores = {lang: 0 for lang in language_features.keys()}
42
+
43
+ # 字符特征检测 - 只检测明显的非拉丁字符
44
+ for char in text:
45
+ for lang, pattern in language_features.items():
46
+ if pattern.search(char):
47
+ scores[lang] += 1
48
+
49
+ # 找到得分最高的语言
50
+ max_score = 0
51
+ detected_lang = None
52
+
53
+ for lang, score in scores.items():
54
+ if score > max_score and score > 0:
55
+ max_score = score
56
+ detected_lang = lang
57
+
58
+ # 检查是否满足阈值 - 如果有明显的非拉丁字符就切换
59
+ if detected_lang and max_score >= 2:
60
+ return detected_lang
61
+
62
+ # 没有检测到其他语言,默认保持英语
63
+ return None
64
+
65
+ def get_language_display_text(language_code):
66
+ """获取语言的显示文本(国旗 + 名称)"""
67
+ for lang in SUPPORTED_LANGUAGES:
68
+ if lang["code"] == language_code:
69
+ return f"{lang['flag']} {lang['name']}"
70
+ return "🇺🇸 English"
71
+
72
+ def get_language_code_from_display(display_text):
73
+ """从显示文本中提取语言代码"""
74
+ for lang in SUPPORTED_LANGUAGES:
75
+ if f"{lang['flag']} {lang['name']}" == display_text:
76
+ return lang['code']
77
+ return "en"
78
+
79
+ def auto_detect_language(text, current_language_display):
80
+ """
81
+ 自动检测语言并返回更新后的语言选择
82
+ """
83
+ if not text or len(text.strip()) < 5:
84
+ return current_language_display
85
+
86
+ current_code = get_language_code_from_display(current_language_display)
87
+ detected_lang = detect_language(text)
88
+
89
+ if detected_lang and detected_lang != current_code:
90
+ print(f"Language auto-detected: {current_code} -> {detected_lang}")
91
+ return get_language_display_text(detected_lang)
92
+
93
+ return current_language_display
94
+
95
+ def generate_obama_voice_with_realtime_updates(text, language_display, request: gr.Request):
96
+ """
97
+ Obama AI voice generation function with real-time status updates
98
+ """
99
+ # 从显示文本中提取语言代码
100
+ language = get_language_code_from_display(language_display)
101
+
102
+ client_ip = request.client.host
103
+ x_forwarded_for = dict(request.headers).get('x-forwarded-for')
104
+ if x_forwarded_for:
105
+ client_ip = x_forwarded_for
106
+ if client_ip not in IP_Dict:
107
+ IP_Dict[client_ip] = 0
108
+ IP_Dict[client_ip] += 1
109
+ print(f"client_ip: {client_ip}, count: {IP_Dict[client_ip]}")
110
+ if IP_Dict[client_ip] >= 6:
111
+ msg = "You have reached the maximum number of requests"
112
+ # Create "Get More Tries" button HTML
113
+ get_more_tries_html = f"""
114
+ <div style='display: flex; justify-content: center; gap: 30px; margin: 10px 0 25px 0; padding: 0px;'>
115
+ <a href='https://trumpaivoice.net/#generator' target='_blank' style='
116
+ display: inline-flex;
117
+ align-items: center;
118
+ justify-content: center;
119
+ padding: 16px 32px;
120
+ background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
121
+ color: white;
122
+ text-decoration: none;
123
+ border-radius: 12px;
124
+ font-weight: 600;
125
+ font-size: 16px;
126
+ text-align: center;
127
+ min-width: 160px;
128
+ box-shadow: 0 4px 15px rgba(17, 153, 142, 0.4);
129
+ transition: all 0.3s ease;
130
+ border: none;
131
+ '>🚀 Get More Tries for Free</a>
132
+ </div>
133
+ """
134
+ yield msg, None, gr.update(value=get_more_tries_html, visible=True), ""
135
+ return msg, None, gr.update(value=get_more_tries_html, visible=True), ""
136
+
137
+ if not text or len(text.strip()) < 3:
138
+ return "Text too short, please enter at least 3 characters", None, gr.update(visible=False), ""
139
+
140
+ try:
141
+ task_type = "voice"
142
+ word_num = len(text.strip().split()) # 自动计算单词数
143
+
144
+ # Create task
145
+ task_result = create_task_v3(task_type, text.strip(), word_num, is_rewrite=False, language=language)
146
+ if not task_result:
147
+ return "Failed to create task", None, gr.update(visible=False), ""
148
+ else:
149
+ yield "Task created successfully", None, gr.update(visible=False), ""
150
+
151
+ max_polls = 300
152
+ poll_interval = 1
153
+ task_url = f"https://trumpaivoice.net/task/{task_result['uuid']}"
154
+
155
+ for i in range(max_polls):
156
+ time.sleep(poll_interval)
157
+ task = get_task_result(task_result['uuid'])
158
+ # print(task, i, "get_task_result")
159
+ if task.get('data', {}):
160
+ status = task.get('data').get('status', '')
161
+ text_final = task.get('data').get('text_final', '')
162
+ if status in ['completed',]:
163
+ voice_url = task.get('data').get('voice_url', '')
164
+ print(voice_url, "===>voice_url")
165
+
166
+ # 下载音频文件到本地以避免SSRF保护问题
167
+ local_audio_path = voice_url
168
+
169
+ # Create action buttons HTML
170
+ action_buttons_html = f"""
171
+ <div style='display: flex; justify-content: center; gap: 30px; margin: 25px 0; padding: 20px;'>
172
+ <a href='https://trumpaivoice.net/#generator' target='_blank' style='
173
+ display: inline-flex;
174
+ align-items: center;
175
+ justify-content: center;
176
+ padding: 16px 32px;
177
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
178
+ color: white;
179
+ text-decoration: none;
180
+ border-radius: 12px;
181
+ font-weight: 600;
182
+ font-size: 16px;
183
+ text-align: center;
184
+ min-width: 160px;
185
+ box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
186
+ transition: all 0.3s ease;
187
+ border: none;
188
+ '>🎬 Generate 4K Video</a>
189
+ <a href='{task_url}' target='_blank' style='
190
+ display: inline-flex;
191
+ align-items: center;
192
+ justify-content: center;
193
+ padding: 16px 32px;
194
+ background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
195
+ color: white;
196
+ text-decoration: none;
197
+ border-radius: 12px;
198
+ font-weight: 600;
199
+ font-size: 16px;
200
+ text-align: center;
201
+ min-width: 160px;
202
+ box-shadow: 0 4px 15px rgba(17, 153, 142, 0.4);
203
+ transition: all 0.3s ease;
204
+ border: none;
205
+ '>👀 Check Generate Details</a>
206
+ </div>
207
+ """
208
+ yield f"✅ success!!!", local_audio_path, gr.update(value=action_buttons_html, visible=True), task_url
209
+ return "✅ Generation successful!", local_audio_path, gr.update(value=action_buttons_html, visible=True), task_url
210
+ elif status in ['failed', 'voice_error', 'no_credits']:
211
+ yield "❌ Generation failed!", None, gr.update(visible=False), ""
212
+ return "❌ Generation failed!", None, gr.update(visible=False), ""
213
+ else:
214
+ yield f"query {i} times, on processing, go to task page {task_url} to check status", None, gr.update(visible=False), task_url
215
+ return "❌ Generation failed!", None, gr.update(visible=False), ""
216
+ except Exception as e:
217
+ error_msg = f"Generation failed: {str(e)}"
218
+ yield error_msg, None, gr.update(visible=False), ""
219
+ return error_msg, None, gr.update(visible=False), ""
220
+
221
+ # Create Gradio Interface
222
+ with gr.Blocks(title="Barack Obama AI Voice", theme=gr.themes.Soft()) as demo:
223
+
224
+ # Main title - at the top
225
+ gr.HTML("""
226
+ <div style="text-align: center; margin: 5px auto 0px auto; max-width: 800px;">
227
+ <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);">
228
+ 🎤 Obama AI Voice
229
+ </h1>
230
+ </div>
231
+ """, padding=False)
232
+
233
+ # # Showcase link banner - second
234
+ # gr.HTML("""
235
+ # <div style="text-align: center; margin: 0px auto 40px auto; max-width: 600px;">
236
+ # <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);">
237
+ # <h3 style="color: white; margin: 0; font-size: 18px;">
238
+ # 🎬 <a href="https://trumpaivoice.net/showcase" target="_blank" style="color: white; text-decoration: none; font-weight: bold;">Check out Obama AI videos created by others →</a>
239
+ # </h3>
240
+ # </div>
241
+ # </div>
242
+ # """, padding=False)
243
+
244
+ # Powered by link - small text
245
+ gr.HTML("""
246
+ <div style="text-align: center; margin: 0px auto -5px auto;">
247
+ <p style="margin: 0; font-size: 16px; color: #999; font-weight: 400;">
248
+ powered by <a href="https://trumpaivoice.net/" target="_blank" style="color: #667eea; text-decoration: none;">trumpaivoice.net</a>
249
+ </p>
250
+ </div>
251
+ """, padding=False)
252
+
253
+ # Simple description text - third
254
+ # gr.HTML("""
255
+ # <div style="text-align: center; margin: 15px auto 30px auto; max-width: 500px;">
256
+ # <p style="color: #666; margin: 0; font-size: 1em; font-weight: 500; line-height: 1.4;">
257
+ # 🔥 Try the most advanced Obama AI Voice and Video generator for FREE at
258
+ # <a href="https://trumpaivoice.net/" target="_blank" style="color: #667eea; text-decoration: none; font-weight: bold;">donaldtrumpaivoice.com</a>!
259
+ # </p>
260
+ # </div>
261
+ # """)
262
+
263
+ with gr.Row():
264
+ with gr.Column(scale=2):
265
+ text_input = gr.Textbox(
266
+ label="📝 Input Text",
267
+ lines=4,
268
+ placeholder="Enter what you want Obama to say...",
269
+ value="Hello everyone, this is a demonstration of the Obama AI Voice system with real-time status monitoring."
270
+ )
271
+
272
+ with gr.Column(scale=1):
273
+ # 创建语言选择器的选项
274
+ language_choices = [f"{lang['flag']} {lang['name']}" for lang in SUPPORTED_LANGUAGES]
275
+ language_values = [lang['code'] for lang in SUPPORTED_LANGUAGES]
276
+
277
+ language_dropdown = gr.Dropdown(
278
+ choices=language_choices,
279
+ value="🇺🇸 English", # 默认值
280
+ label="🌍 Language",
281
+ interactive=True
282
+ )
283
+
284
+ submit_btn = gr.Button(
285
+ "🚀 Generate Obama AI Voice",
286
+ variant="primary",
287
+ size="lg"
288
+ )
289
+
290
+ with gr.Row():
291
+ status_output = gr.Textbox(
292
+ label="📊 Status",
293
+ interactive=False,
294
+ placeholder="Waiting for generation..."
295
+ )
296
+
297
+ # Action buttons that will show after task completion
298
+ with gr.Row():
299
+ action_links = gr.HTML(visible=False)
300
+
301
+ with gr.Row():
302
+ audio_output = gr.Audio(
303
+ label="🎵 Obama AI Voice",
304
+ interactive=False
305
+ )
306
+
307
+
308
+ # Video Showcase Section
309
+ gr.HTML("""
310
+ <div style="width: 100%; margin: 40px 0; padding: 0 20px;">
311
+ <div style="text-align: center; background: linear-gradient(135deg, #e3f2fd 0%, #f3e5f5 50%, #fce4ec 100%); padding: 30px; border-radius: 20px; box-shadow: 0 10px 30px rgba(0,0,0,0.1); margin-bottom: 30px;">
312
+ <h2 style="color: #2c3e50; margin: 0 0 15px 0; font-size: 2.2em; font-weight: 700;">
313
+ 🎬 Video Showcase
314
+ </h2>
315
+ <p style="color: #34495e; font-size: 1.2em; line-height: 1.6; margin: 0 0 25px 0;">
316
+ Watch amazing AI-generated Obama videos with realistic animations and perfect lip-sync!
317
+ </p>
318
+
319
+ <!-- Video Gallery -->
320
+ <div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; margin: 30px 0;">
321
+
322
+ <div style="background: rgba(255,255,255,0.8); padding: 20px; border-radius: 15px; box-shadow: 0 4px 15px rgba(0,0,0,0.1);">
323
+ <h4 style="color: #2c3e50; margin: 0 0 15px 0; font-size: 1.1em;">🌺 White House Garden</h4>
324
+ <video id="video-garden" style="width: 100%; height: 300px; border-radius: 10px; object-fit: cover;" controls preload="metadata">
325
+ <source src="https://www.trumpaivoice.net/SelfitAssert/Heygem/Obama/show/62_1758155530_8uRFAtYB-r.mp4" type="video/mp4">
326
+ Your browser does not support the video tag.
327
+ </video>
328
+ </div>
329
+
330
+ <div style="background: rgba(255,255,255,0.8); padding: 20px; border-radius: 15px; box-shadow: 0 4px 15px rgba(0,0,0,0.1);">
331
+ <h4 style="color: #2c3e50; margin: 0 0 15px 0; font-size: 1.1em;">🏛️ Oval Office Address</h4>
332
+ <video id="video-office" style="width: 100%; height: 300px; border-radius: 10px; object-fit: cover;" controls preload="metadata">
333
+ <source src="https://www.trumpaivoice.net/SelfitAssert/Heygem/Obama/show/62_1758155476_KdNzaG9p-r.mp4" type="video/mp4">
334
+ Your browser does not support the video tag.
335
+ </video>
336
+ </div>
337
+
338
+ </div>
339
+
340
+ <!-- Action Buttons -->
341
+ <div style="display: flex; justify-content: center; gap: 20px; flex-wrap: wrap; margin: 25px 0 0 0;">
342
+ <a href="https://trumpaivoice.net/obama-ai-voice#generator" target="_blank" style="
343
+ display: inline-flex;
344
+ align-items: center;
345
+ justify-content: center;
346
+ padding: 18px 35px;
347
+ background: linear-gradient(135deg, #ff6b6b 0%, #feca57 100%);
348
+ color: white;
349
+ text-decoration: none;
350
+ border-radius: 15px;
351
+ font-weight: 700;
352
+ font-size: 16px;
353
+ text-align: center;
354
+ min-width: 220px;
355
+ box-shadow: 0 8px 25px rgba(255, 107, 107, 0.4);
356
+ transition: all 0.3s ease;
357
+ border: none;
358
+ transform: scale(1);
359
+ " onmouseover="this.style.transform='scale(1.05)'" onmouseout="this.style.transform='scale(1)'">
360
+ 🎬 Generate 4K Obama Video
361
+ </a>
362
+
363
+ </div>
364
+
365
+ <p style="color: #555; font-size: 1em; margin: 15px 0 0 0;">
366
+ Create high-quality Obama AI videos and original songs with custom text and scenarios!
367
+ </p>
368
+ </div>
369
+ </div>
370
+
371
+ <script>
372
+ // Ensure only one video plays at a time
373
+ document.addEventListener('DOMContentLoaded', function() {
374
+ const videos = ['video-garden', 'video-office', 'video-flag'];
375
+
376
+ videos.forEach(function(videoId) {
377
+ const video = document.getElementById(videoId);
378
+ if (video) {
379
+ video.addEventListener('play', function() {
380
+ // Pause all other videos when this one starts playing
381
+ videos.forEach(function(otherId) {
382
+ if (otherId !== videoId) {
383
+ const otherVideo = document.getElementById(otherId);
384
+ if (otherVideo && !otherVideo.paused) {
385
+ otherVideo.pause();
386
+ }
387
+ }
388
+ });
389
+ });
390
+ }
391
+ });
392
+ });
393
+ </script>
394
+ """, padding=False)
395
+
396
+ # Comprehensive introduction section
397
+ gr.HTML("""
398
+ <div style="width: 100%; margin: 30px 0; padding: 0 20px;">
399
+
400
+ <!-- Hero Description -->
401
+ <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);">
402
+ <h2 style="color: #2c3e50; margin: 0 0 15px 0; font-size: 1.8em; font-weight: 700;">
403
+ 🇺🇸 Experience the Power of AI-Generated Obama Voice
404
+ </h2>
405
+ <p style="color: #555; font-size: 1.1em; line-height: 1.6; margin: 0 0 20px 0; width: 100%; padding: 0 20px;">
406
+ Transform any text into authentic Barack Obama speech with our cutting-edge AI voice synthesis technology.
407
+ Whether you're creating content for entertainment, education, or social media, our advanced neural network
408
+ captures Obama's distinctive speaking style, intonation, and rhetorical patterns with remarkable accuracy.
409
+ </p>
410
+ </div>
411
+
412
+ <!-- Features Grid -->
413
+ <div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; margin: 40px 0;">
414
+
415
+ <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;">
416
+ <h3 style="color: #e74c3c; margin: 0 0 12px 0; font-size: 1.3em; font-weight: 600;">
417
+ 🎯 Ultra-Realistic Voice
418
+ </h3>
419
+ <p style="color: #666; margin: 0; line-height: 1.5; font-size: 0.95em;">
420
+ Our AI model is trained on thousands of hours of Obama speeches, capturing his unique vocal characteristics,
421
+ pronunciation patterns, and speaking rhythm to deliver incredibly lifelike results.
422
+ </p>
423
+ </div>
424
+
425
+ <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;">
426
+ <h3 style="color: #3498db; margin: 0 0 12px 0; font-size: 1.3em; font-weight: 600;">
427
+ ⚡ Lightning Fast Generation
428
+ </h3>
429
+ <p style="color: #666; margin: 0; line-height: 1.5; font-size: 0.95em;">
430
+ Generate high-quality Obama AI voice clips in seconds, not minutes. Our optimized infrastructure
431
+ ensures rapid processing while maintaining exceptional audio quality.
432
+ </p>
433
+ </div>
434
+
435
+ <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;">
436
+ <h3 style="color: #27ae60; margin: 0 0 12px 0; font-size: 1.3em; font-weight: 600;">
437
+ 🎨 Creative Content Creation
438
+ </h3>
439
+ <p style="color: #666; margin: 0; line-height: 1.5; font-size: 0.95em;">
440
+ Perfect for memes, podcasts, educational content, entertainment videos, or any creative project
441
+ that needs an authentic Obama voice performance.
442
+ </p>
443
+ </div>
444
+
445
+ </div>
446
+
447
+
448
+ <!-- Celebrity Voices Section -->
449
+ <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;">
450
+ <h2 style="margin: 0 0 20px 0; font-size: 1.8em; font-weight: 700;">
451
+ 🎭 Try More Celebrity AI Voices
452
+ </h2>
453
+ <p style="margin: 0 0 25px 0; font-size: 1.1em; opacity: 0.95; line-height: 1.5;">
454
+ Explore our premium collection of celebrity AI voices! Our high-quality service delivers
455
+ lightning-fast results with exceptional audio quality. Experience the best AI voice generation
456
+ with our reliable and responsive platform.
457
+ </p>
458
+ <div style="display: flex; justify-content: center; gap: 20px; flex-wrap: wrap;">
459
+ <a href="https://trumpaivoice.net/explore" target="_blank" style="
460
+ display: inline-flex;
461
+ align-items: center;
462
+ justify-content: center;
463
+ padding: 18px 35px;
464
+ background: rgba(255,255,255,0.9);
465
+ color: #333;
466
+ text-decoration: none;
467
+ border-radius: 15px;
468
+ font-weight: 700;
469
+ font-size: 16px;
470
+ text-align: center;
471
+ min-width: 200px;
472
+ box-shadow: 0 6px 20px rgba(0,0,0,0.3);
473
+ transition: all 0.3s ease;
474
+ border: none;
475
+ ">🌟 Explore Celebrity Voices</a>
476
+ <a href="https://trumpaivoice.net/showcase" target="_blank" style="
477
+ display: inline-flex;
478
+ align-items: center;
479
+ justify-content: center;
480
+ padding: 18px 35px;
481
+ background: rgba(255,255,255,0.2);
482
+ color: white;
483
+ text-decoration: none;
484
+ border-radius: 15px;
485
+ font-weight: 700;
486
+ font-size: 16px;
487
+ text-align: center;
488
+ min-width: 200px;
489
+ box-shadow: 0 6px 20px rgba(0,0,0,0.2);
490
+ transition: all 0.3s ease;
491
+ border: 2px solid rgba(255,255,255,0.3);
492
+ ">🎭 View Showcase</a>
493
+ </div>
494
+ </div>
495
+
496
+ <!-- Tips Section -->
497
+ <div style="background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 50%, #fecfef 100%); padding: 25px; border-radius: 15px; margin: 40px 0;">
498
+ <h3 style="color: #8b5cf6; text-align: center; margin: 0 0 20px 0; font-size: 1.4em; font-weight: 700;">
499
+ 💡 Pro Tips for Best Results
500
+ </h3>
501
+ <div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 15px;">
502
+
503
+ <div style="background: rgba(255,255,255,0.8); padding: 15px; border-radius: 10px;">
504
+ <strong style="color: #8b5cf6;">📖 Clear Text:</strong>
505
+ <span style="color: #555;"> Use proper punctuation and avoid special characters for optimal results.</span>
506
+ </div>
507
+
508
+ <div style="background: rgba(255,255,255,0.8); padding: 15px; border-radius: 10px;">
509
+ <strong style="color: #8b5cf6;">⏱️ Length Matters:</strong>
510
+ <span style="color: #555;"> Shorter texts (20-60 words) typically produce the most natural-sounding results.</span>
511
+ </div>
512
+
513
+ <div style="background: rgba(255,255,255,0.8); padding: 15px; border-radius: 10px;">
514
+ <strong style="color: #8b5cf6;">🎯 Obama Style:</strong>
515
+ <span style="color: #555;"> Text written in Obama's speaking style will sound more authentic and natural.</span>
516
+ </div>
517
+
518
+ </div>
519
+ </div>
520
+
521
+ </div>
522
+ """, padding=False)
523
+
524
+
525
+ # Powered by link - small text
526
+ gr.HTML("""
527
+ <div style="text-align: center; margin: 0px auto -5px auto;">
528
+ <p style="margin: 0; font-size: 16px; color: #999; font-weight: 400;">
529
+ Click <a href="https://trumpaivoice.net/showcase" target="_blank" style="color: #667eea; text-decoration: none;"> obama ai voices showcase </a> to see more videos
530
+ </p>
531
+ </div>
532
+ """, padding=False)
533
+
534
+ # Hidden state to store task_url
535
+ task_url_state = gr.State("")
536
+
537
+ # 自动语言检测事件
538
+ text_input.change(
539
+ auto_detect_language,
540
+ inputs=[text_input, language_dropdown],
541
+ outputs=[language_dropdown]
542
+ )
543
+
544
+ # Bind event
545
+ submit_btn.click(
546
+ generate_obama_voice_with_realtime_updates,
547
+ inputs=[text_input, language_dropdown],
548
+ outputs=[status_output, audio_output, action_links, task_url_state]
549
+ )
550
+
551
+ if __name__ == "__main__":
552
+ demo.launch()
push.sh ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ # 设置仓库级别用户名
3
+ git config user.name "selfitcamera"
4
+ git config user.email "ethan.blake@heybeauty.ai"
5
+
6
+ # 验证
7
+ git config user.name
8
+ git config user.email
9
+
10
+
11
+ git add .
12
+ git commit -m "init"
13
+ git push
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ gradio>=4.0.0
2
+ requests>=2.31.0
3
+ supabase>=2.0.0
4
+ python-dotenv>=1.0.0
util.py ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import requests
2
+ import time
3
+ import uuid
4
+ import os
5
+ from datetime import datetime
6
+ from supabase import create_client, Client
7
+
8
+ try:
9
+ OneKey = os.environ['OneKey'].strip()
10
+
11
+ OneKey = OneKey.split("#")
12
+ TrumpAiUrl = OneKey[0]
13
+ ApiKey = OneKey[1]
14
+ SUPABASE_URL = OneKey[2]
15
+ UserUuid = OneKey[3]
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)
24
+
25
+
26
+ # 创建Supabase客户端
27
+ supabase: Client = create_client(SUPABASE_URL, SUPABASE_KEY)
28
+
29
+ # 任务状态枚举
30
+ class TaskStatus:
31
+ Created = "created"
32
+ Processing = "processing"
33
+ TextRewrited = "text_rewrited"
34
+ TextFormated = "text_formated"
35
+ VoiceCompleted = "voice_completed"
36
+ VoiceError = "voice_error"
37
+ VideoCompleted = "video_completed"
38
+ VideoPublished = "video_published"
39
+ VideoError = "video_error"
40
+ Completed = "completed"
41
+ Failed = "failed"
42
+ Cancelled = "cancelled"
43
+ NoCredits = "no_credits"
44
+
45
+ # 视频模板枚举
46
+ class VideoTemplate:
47
+ Outdoor = "outdoor"
48
+ UsFlag = "us-flag"
49
+ WhiteHouse = "white-house"
50
+
51
+ def create_task_v3(task_type, text, word_num, is_rewrite, language="en"):
52
+ import json
53
+ is_rewrite = False
54
+ url = f"{BackendUrl}/trump_process_ctx_api_v3"
55
+ headers = {
56
+ "Content-Type": "application/json"
57
+ }
58
+ print(url)
59
+ data = {
60
+ "video_template": "",
61
+ "speaker_template": "https://www.trumpaivoice.net/SelfitAssert/Heygem/Obama/obama_audio01.MP3",
62
+ "text": text,
63
+ "word_num": word_num,
64
+ "is_rewrite": False,
65
+ "language": language,
66
+ "watermark": True,
67
+ "type": "voice",
68
+ "cost_credits": 2,
69
+ "user_uuid": UserUuid,
70
+ "secret_key": "219ngu"
71
+ }
72
+ try:
73
+ resp = requests.post(url, headers=headers, data=json.dumps(data), timeout=60)
74
+ if not resp.ok:
75
+ print(f"调用trump_process_ctx_api失败: {resp.status_code} {resp.text}")
76
+ return None
77
+ try:
78
+ ctx_json = resp.json()
79
+ except Exception as e:
80
+ print(f"解析trump_process_ctx_api返回异常: {e}")
81
+ return None
82
+ if not ctx_json or ctx_json.get("code") != 0 or not ctx_json.get("data") or not ctx_json["data"].get("task_id"):
83
+ print(f"trump_process_ctx_api返回异常: {ctx_json}")
84
+ return None
85
+ return {
86
+ "task_id": ctx_json["data"]["task_id"],
87
+ "uuid": ctx_json["data"]["task_uuid"],
88
+ "status": "created",
89
+ "message": "任务创建成功,后台处理中"
90
+ }
91
+ except Exception as err:
92
+ print(f"create_task_v3异常: {err}")
93
+ return None
94
+
95
+ def get_task_result(task_id):
96
+ # Poll for task status and result
97
+ url = f"{TrumpAiUrl}/api/task-status/uuid/{task_id}"
98
+ headers = {
99
+ "Content-Type": "application/json",
100
+ "Authorization": f"Bearer {ApiKey}"
101
+ }
102
+ print(url)
103
+ try:
104
+ resp = requests.get(url, headers=headers, timeout=30)
105
+ resp.raise_for_status()
106
+ result = resp.json()
107
+ return result
108
+ except Exception as e:
109
+ return {}
110
+
111
+
112
+ if __name__ == "__main__":
113
+
114
+ task_type = "voice"
115
+ text = "Hello, this is a test message for Trump AI Voice."
116
+ word_num = 10
117
+ is_rewrite = True
118
+ task_result = create_task_v3(task_type, text, word_num, is_rewrite)
119
+ print(f"task_result: {task_result}")