Hexa06 commited on
Commit
5dfbde0
·
1 Parent(s): 9d1acd5

Remove Gradio UI, keep FastAPI endpoints only

Browse files
Files changed (3) hide show
  1. README.md +1 -2
  2. app.py +16 -42
  3. requirements.txt +0 -1
README.md CHANGED
@@ -3,8 +3,7 @@ title: Kokoro TTS API - Professional & Fast
3
  emoji: 🎤
4
  colorFrom: blue
5
  colorTo: purple
6
- sdk: gradio
7
- sdk_version: "4.44.1"
8
  app_file: app.py
9
  pinned: false
10
  ---
 
3
  emoji: 🎤
4
  colorFrom: blue
5
  colorTo: purple
6
+ sdk: docker
 
7
  app_file: app.py
8
  pinned: false
9
  ---
app.py CHANGED
@@ -1,6 +1,5 @@
1
  from fastapi import FastAPI, HTTPException, Form, BackgroundTasks
2
  from fastapi.responses import FileResponse
3
- import gradio as gr
4
  from kokoro_onnx import Kokoro
5
  import tempfile
6
  import os
@@ -295,47 +294,22 @@ async def list_users(admin_username: str = Form(...), admin_password: str = Form
295
  result = supabase.table("tts_users").select("username, role, daily_limit, is_active, created_at").execute()
296
  return {"users": result.data}
297
 
298
- # ============== GRADIO UI ==============
299
- def generate_tts_gradio(username, password, text, voice="af_heart", speed=1.0):
300
- if not username or not password:
301
- raise gr.Error("Username and password required")
302
- if not text or len(text.strip()) < MIN_CHARS:
303
- raise gr.Error(f"Text must be at least {MIN_CHARS} characters")
304
-
305
- try:
306
- user = authenticate_user(username, password)
307
- quota = check_quota(user['username'], user['daily_limit'], user['role'])
308
-
309
- output_path = generate_speech(text.strip(), voice, speed)
310
-
311
- if not quota['is_unlimited']:
312
- log_usage(user['username'], len(text), "en")
313
-
314
- return output_path
315
- except HTTPException as e:
316
- raise gr.Error(e.detail)
317
- except Exception as e:
318
- raise gr.Error(str(e))
319
-
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="/")
339
 
340
  if __name__ == "__main__":
341
  import uvicorn
 
1
  from fastapi import FastAPI, HTTPException, Form, BackgroundTasks
2
  from fastapi.responses import FileResponse
 
3
  from kokoro_onnx import Kokoro
4
  import tempfile
5
  import os
 
294
  result = supabase.table("tts_users").select("username, role, daily_limit, is_active, created_at").execute()
295
  return {"users": result.data}
296
 
297
+ # ============== ROOT ENDPOINT ==============
298
+ @app.get("/")
299
+ def root():
300
+ return {
301
+ "service": "Kokoro TTS API",
302
+ "status": "running",
303
+ "model": "Kokoro-82M",
304
+ "version": "1.0",
305
+ "endpoints": {
306
+ "health": "/health",
307
+ "generate": "/api/generate (POST)",
308
+ "quota": "/api/quota (POST)",
309
+ "docs": "/docs"
310
+ },
311
+ "usage": "Visit /docs for interactive API documentation"
312
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
313
 
314
  if __name__ == "__main__":
315
  import uvicorn
requirements.txt CHANGED
@@ -1,6 +1,5 @@
1
  fastapi==0.115.0
2
  uvicorn[standard]==0.32.0
3
- gradio==4.44.1
4
  kokoro-onnx
5
  soundfile
6
  python-multipart
 
1
  fastapi==0.115.0
2
  uvicorn[standard]==0.32.0
 
3
  kokoro-onnx
4
  soundfile
5
  python-multipart