selfit-camera commited on
Commit
cb9a662
·
1 Parent(s): 26c281a
Files changed (1) hide show
  1. app.py +28 -0
app.py CHANGED
@@ -137,6 +137,33 @@ def generate_trump_voice_with_realtime_updates(text, language_display, request:
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()) # 自动计算单词数
@@ -265,6 +292,7 @@ with gr.Blocks(title="Donald Trump AI Voice", theme=gr.themes.Soft()) as demo:
265
  text_input = gr.Textbox(
266
  label="📝 Input Text",
267
  lines=4,
 
268
  placeholder="Enter what you want Trump to say...",
269
  value="Hello everyone, this is a demonstration of the Trump AI Voice system with real-time status monitoring."
270
  )
 
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
+ if len(text.strip()) > 1000:
141
+ msg = "Text too long (maximum 1000 characters). Please visit our official website for longer text generation."
142
+ # Create "Go to Official Website" button HTML
143
+ go_to_website_html = f"""
144
+ <div style='display: flex; justify-content: center; gap: 30px; margin: 10px 0 25px 0; padding: 0px;'>
145
+ <a href='https://trumpaivoice.net/#generator' target='_blank' style='
146
+ display: inline-flex;
147
+ align-items: center;
148
+ justify-content: center;
149
+ padding: 16px 32px;
150
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
151
+ color: white;
152
+ text-decoration: none;
153
+ border-radius: 12px;
154
+ font-weight: 600;
155
+ font-size: 16px;
156
+ text-align: center;
157
+ min-width: 160px;
158
+ box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
159
+ transition: all 0.3s ease;
160
+ border: none;
161
+ '>🌐 Go to Official Website</a>
162
+ </div>
163
+ """
164
+ yield msg, None, gr.update(value=go_to_website_html, visible=True), ""
165
+ return msg, None, gr.update(value=go_to_website_html, visible=True), ""
166
+
167
  try:
168
  task_type = "voice"
169
  word_num = len(text.strip().split()) # 自动计算单词数
 
292
  text_input = gr.Textbox(
293
  label="📝 Input Text",
294
  lines=4,
295
+ max_length=1000,
296
  placeholder="Enter what you want Trump to say...",
297
  value="Hello everyone, this is a demonstration of the Trump AI Voice system with real-time status monitoring."
298
  )