HusseinBashir commited on
Commit
c23265c
·
verified ·
1 Parent(s): 528f1a0

Upload main.py

Browse files
Files changed (1) hide show
  1. main.py +18 -0
main.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI, Request
2
+ from fastapi.responses import JSONResponse
3
+ from gradio_client import Client
4
+
5
+ app = FastAPI()
6
+ client = Client("HusseinBashir/Somali_tts")
7
+
8
+ @app.post("/somali-tts/")
9
+ async def somali_tts(request: Request):
10
+ data = await request.json()
11
+ text = data.get("text")
12
+ if not text:
13
+ return JSONResponse(content={"error": "No text provided"}, status_code=400)
14
+ try:
15
+ audio_url = client.predict(text, api_name="/predict")
16
+ return JSONResponse(content={"audio_url": audio_url})
17
+ except Exception as e:
18
+ return JSONResponse(content={"error": str(e)}, status_code=500)