HusseinBashir commited on
Commit
372da11
·
verified ·
1 Parent(s): d5b2322

created app.py

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