Spaces:
Sleeping
Sleeping
from fastapi import FastAPI, Request | |
from fastapi.responses import JSONResponse | |
from gradio_client import Client | |
app = FastAPI() | |
client = Client("HusseinBashir/Somali_tts") | |
async def somali_tts(request: Request): | |
data = await request.json() | |
text = data.get("text") | |
if not text: | |
return JSONResponse(content={"error": "No text provided"}, status_code=400) | |
try: | |
audio_url = client.predict(text, api_name="/predict") | |
return JSONResponse(content={"audio_url": audio_url}) | |
except Exception as e: | |
return JSONResponse(content={"error": str(e)}, status_code=500) | |