Spaces:
Running
Running
File size: 1,209 Bytes
104737f 323c87d 1f58459 5ed9749 323c87d 1ed6720 1f58459 5ed9749 1f58459 5ed9749 1f58459 104737f 1ed6720 1f58459 1ed6720 1f58459 de305ed 1f58459 5ed9749 1f58459 de305ed 323c87d 1f58459 de305ed d699ad7 104737f 1f58459 104737f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# Standard Library Imports
import asyncio
from pathlib import Path
# Third-Party Library Imports
import gradio as gr
from fastapi import FastAPI
from fastapi.staticfiles import StaticFiles
# Local Application Imports
from src.common import Config, logger
from src.database import init_db
from src.frontend import Frontend
from src.middleware import MetaTagInjectionMiddleware
async def main():
"""
Asynchronous main function to initialize the application.
"""
logger.info("Launching TTS Arena Gradio app...")
config = Config.get()
db_session_maker = init_db(config)
frontend = Frontend(config, db_session_maker)
demo = await frontend.build_gradio_interface()
app = FastAPI()
app.add_middleware(MetaTagInjectionMiddleware)
public_dir = Path("public")
app.mount("/static", StaticFiles(directory=public_dir), name="static")
gr.mount_gradio_app(
app=app,
blocks=demo,
path="/",
allowed_paths=["static"]
)
import uvicorn
config = uvicorn.Config(app, host="0.0.0.0", port=7860, log_level="info")
server = uvicorn.Server(config)
await server.serve()
if __name__ == "__main__":
asyncio.run(main())
|