Spaces:
Running
Running
temptrip
commited on
Commit
·
eaeab3e
1
Parent(s):
0bb37b8
init
Browse files- __pycache__/util.cpython-313.pyc +0 -0
- app.py +387 -381
- 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://
|
| 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://
|
| 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 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
""
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
#
|
| 147 |
-
#
|
| 148 |
-
#
|
| 149 |
-
#
|
| 150 |
-
# ""
|
| 151 |
-
|
| 152 |
-
#
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
""
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
#
|
| 167 |
-
#
|
| 168 |
-
#
|
| 169 |
-
# ""
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
|
| 266 |
-
|
| 267 |
-
|
| 268 |
-
|
| 269 |
-
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
|
| 273 |
-
|
| 274 |
-
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
|
| 281 |
-
|
| 282 |
-
|
| 283 |
-
|
| 284 |
-
|
| 285 |
-
|
| 286 |
-
|
| 287 |
-
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
|
| 296 |
-
|
| 297 |
-
|
| 298 |
-
|
| 299 |
-
|
| 300 |
-
|
| 301 |
-
|
| 302 |
-
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
|
| 306 |
-
|
| 307 |
-
|
| 308 |
-
|
| 309 |
-
|
| 310 |
-
|
| 311 |
-
|
| 312 |
-
|
| 313 |
-
|
| 314 |
-
|
| 315 |
-
|
| 316 |
-
|
| 317 |
-
|
| 318 |
-
|
| 319 |
-
|
| 320 |
-
|
| 321 |
-
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
|
| 336 |
-
|
| 337 |
-
|
| 338 |
-
|
| 339 |
-
|
| 340 |
-
|
| 341 |
-
|
| 342 |
-
|
| 343 |
-
|
| 344 |
-
|
| 345 |
-
|
| 346 |
-
|
| 347 |
-
<
|
| 348 |
-
|
| 349 |
-
|
| 350 |
-
|
| 351 |
-
|
| 352 |
-
<
|
| 353 |
-
|
| 354 |
-
|
| 355 |
-
|
| 356 |
-
|
| 357 |
-
|
| 358 |
-
|
| 359 |
-
|
| 360 |
-
|
| 361 |
-
|
| 362 |
-
|
| 363 |
-
|
| 364 |
-
|
| 365 |
-
|
| 366 |
-
|
| 367 |
-
|
| 368 |
-
|
| 369 |
-
"""
|
| 370 |
-
|
| 371 |
-
|
| 372 |
-
|
| 373 |
-
|
| 374 |
-
|
| 375 |
-
|
| 376 |
-
|
| 377 |
-
|
| 378 |
-
|
| 379 |
-
|
| 380 |
-
|
| 381 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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)
|