""" HuggingFace Space entry point — Gradio SDK + ZeroGPU. Serves two things on the same port: / FastAPI REST API (what the Flutter app calls) /ui Gradio web demo (human-facing, ZeroGPU-backed) Deploy: Set sdk: gradio / app_file: hf_app.py in the Space README. Set hardware: zero-gpu in the Space README. Add secrets: HF_TOKEN, ANTHROPIC_API_KEY, SUPABASE_URL, SUPABASE_SERVICE_ROLE_KEY, PAYSTACK_SECRET_KEY """ import os import uvicorn import gradio as gr # Ensure imports resolve relative to this file's directory regardless of cwd. os.chdir(os.path.dirname(os.path.abspath(__file__))) os.environ.setdefault("CONFIG_PATH", "config/settings.yaml") os.environ.setdefault("PYTHONPATH", os.getcwd()) # Import the FastAPI app (all REST routes + @spaces.GPU transcription shim). from app import app as fastapi_app # noqa: E402 # Import the Gradio demo (also @spaces.GPU-wrapped via _gpu_decorator). from gradio_app import demo # noqa: E402 # Mount the Gradio UI inside the FastAPI app at /ui. # All REST routes remain at their original paths (/, /transcribe, /result/…). app = gr.mount_gradio_app(fastapi_app, demo, path="/ui") if __name__ == "__main__": uvicorn.run(app, host="0.0.0.0", port=7860)