Hexa06 commited on
Commit
9d1acd5
Β·
1 Parent(s): e852a1d

Fix Gradio UI crash and handle RLS errors gracefully

Browse files
Files changed (1) hide show
  1. app.py +11 -20
app.py CHANGED
@@ -46,7 +46,9 @@ def init_admin():
46
  else:
47
  print(f"βœ… Admin user exists: {ADMIN_USERNAME}")
48
  except Exception as e:
49
- print(f"⚠️ Error creating admin: {e}")
 
 
50
 
51
  # ============== KOKORO TTS MODEL ==============
52
  print("🎀 Loading Kokoro TTS model...")
@@ -318,30 +320,19 @@ def generate_tts_gradio(username, password, text, voice="af_heart", speed=1.0):
318
  gradio_app = gr.Interface(
319
  fn=generate_tts_gradio,
320
  inputs=[
321
- gr.Textbox(label="Username", placeholder="Enter your username"),
322
- gr.Textbox(label="Password", type="password", placeholder="Enter your password"),
323
- gr.Textbox(label="Text", placeholder=f"Enter text ({MIN_CHARS}-{MAX_CHARS} chars)", lines=8),
324
  gr.Dropdown(
325
  choices=["af_heart", "af_bella", "am_adam", "am_michael", "bf_emma", "bf_isabella"],
326
- value="af_heart",
327
- label="Voice (Emotional & Expressive)"
328
  ),
329
  gr.Slider(0.5, 2.0, value=1.0, step=0.1, label="Speed")
330
  ],
331
- outputs=gr.Audio(label="Generated Speech (Kokoro TTS)", type="filepath"),
332
- title="πŸš€ Kokoro TTS - Professional & Lightning Fast",
333
- description=f"""
334
- **High-Speed Text-to-Speech with Emotional Expression**
335
-
336
- - ⚑ Lightning fast generation (~20-30 sec)
337
- - 🎭 Emotional & expressive voices
338
- - πŸ”’ Secure authentication required
339
- - πŸ“Š Quota: {DAILY_QUOTA} generations/day
340
- - 🎡 Max audio: 5 minutes (4500 chars)
341
- - πŸ’Ύ Runs smoothly on CPU
342
-
343
- Perfect for audiobooks, educational content, and storytelling!
344
- """,
345
  )
346
 
347
  app = gr.mount_gradio_app(app, gradio_app, path="/")
 
46
  else:
47
  print(f"βœ… Admin user exists: {ADMIN_USERNAME}")
48
  except Exception as e:
49
+ # Ignore RLS errors - user may already exist or require manual creation
50
+ print(f"⚠️ Note: {e}")
51
+ print(f"ℹ️ Tip: Create admin user manually in Supabase if needed")
52
 
53
  # ============== KOKORO TTS MODEL ==============
54
  print("🎀 Loading Kokoro TTS model...")
 
320
  gradio_app = gr.Interface(
321
  fn=generate_tts_gradio,
322
  inputs=[
323
+ gr.Textbox(label="Username"),
324
+ gr.Textbox(label="Password", type="password"),
325
+ gr.Textbox(label="Text", lines=8),
326
  gr.Dropdown(
327
  choices=["af_heart", "af_bella", "am_adam", "am_michael", "bf_emma", "bf_isabella"],
328
+ value="bf_isabella",
329
+ label="Voice"
330
  ),
331
  gr.Slider(0.5, 2.0, value=1.0, step=0.1, label="Speed")
332
  ],
333
+ outputs=gr.Audio(label="Generated Speech"),
334
+ title="Kokoro TTS API",
335
+ description="Fast Text-to-Speech with authentication. Quota: 50 generations/day.",
 
 
 
 
 
 
 
 
 
 
 
336
  )
337
 
338
  app = gr.mount_gradio_app(app, gradio_app, path="/")