Fix Gradio UI crash and handle RLS errors gracefully
Browse files
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 |
-
|
|
|
|
|
|
|
| 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"
|
| 322 |
-
gr.Textbox(label="Password", type="password"
|
| 323 |
-
gr.Textbox(label="Text",
|
| 324 |
gr.Dropdown(
|
| 325 |
choices=["af_heart", "af_bella", "am_adam", "am_michael", "bf_emma", "bf_isabella"],
|
| 326 |
-
value="
|
| 327 |
-
label="Voice
|
| 328 |
),
|
| 329 |
gr.Slider(0.5, 2.0, value=1.0, step=0.1, label="Speed")
|
| 330 |
],
|
| 331 |
-
outputs=gr.Audio(label="Generated Speech
|
| 332 |
-
title="
|
| 333 |
-
description=
|
| 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="/")
|