Remove Gradio UI, keep FastAPI endpoints only
Browse filesFiles changed (3)
- README.md+1-2
- app.py+16-42
- requirements.txt-1
2 unmodified lines3456789102 unmodified linesemoji: 🎤colorFrom: bluecolorTo: purplesdk: gradiosdk_version: "4.44.1"app_file: app.pypinned: false---2 unmodified lines34567892 unmodified linesemoji: 🎤colorFrom: bluecolorTo: purplesdk: dockerapp_file: app.pypinned: false---
123456288 unmodified lines295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341from fastapi import FastAPI, HTTPException, Form, BackgroundTasksfrom fastapi.responses import FileResponseimport gradio as grfrom kokoro_onnx import Kokoroimport tempfileimport os288 unmodified linesresult = supabase.table("tts_users").select("username, role, daily_limit, is_active, created_at").execute()return {"users": result.data}# ============== GRADIO UI ==============def generate_tts_gradio(username, password, text, voice="af_heart", speed=1.0):if not username or not password:raise gr.Error("Username and password required")if not text or len(text.strip()) < MIN_CHARS:raise gr.Error(f"Text must be at least {MIN_CHARS} characters")try:user = authenticate_user(username, password)quota = check_quota(user['username'], user['daily_limit'], user['role'])output_path = generate_speech(text.strip(), voice, speed)if not quota['is_unlimited']:log_usage(user['username'], len(text), "en")return output_pathexcept HTTPException as e:raise gr.Error(e.detail)except Exception as e:raise gr.Error(str(e))gradio_app = gr.Interface(fn=generate_tts_gradio,inputs=[gr.Textbox(label="Username"),gr.Textbox(label="Password", type="password"),gr.Textbox(label="Text", lines=8),gr.Dropdown(choices=["af_heart", "af_bella", "am_adam", "am_michael", "bf_emma", "bf_isabella"],value="bf_isabella",label="Voice"),gr.Slider(0.5, 2.0, value=1.0, step=0.1, label="Speed")],outputs=gr.Audio(label="Generated Speech"),title="Kokoro TTS API",description="Fast Text-to-Speech with authentication. Quota: 50 generations/day.",)app = gr.mount_gradio_app(app, gradio_app, path="/")if __name__ == "__main__":import uvicorn12345288 unmodified lines294295296297298299300301302303304305306307308309310311312313314315from fastapi import FastAPI, HTTPException, Form, BackgroundTasksfrom fastapi.responses import FileResponsefrom kokoro_onnx import Kokoroimport tempfileimport os288 unmodified linesresult = supabase.table("tts_users").select("username, role, daily_limit, is_active, created_at").execute()return {"users": result.data}# ============== ROOT ENDPOINT ==============@app.get("/")def root():return {"service": "Kokoro TTS API","status": "running","model": "Kokoro-82M","version": "1.0","endpoints": {"health": "/health","generate": "/api/generate (POST)","quota": "/api/quota (POST)","docs": "/docs"},"usage": "Visit /docs for interactive API documentation"}if __name__ == "__main__":import uvicorn
123456fastapi==0.115.0uvicorn[standard]==0.32.0gradio==4.44.1kokoro-onnxsoundfilepython-multipart12345fastapi==0.115.0uvicorn[standard]==0.32.0kokoro-onnxsoundfilepython-multipart
README.md+1-2
app.py+16-42
requirements.txt-1