Spaces:
Runtime error
Runtime error
Commit Β·
c6607dc
1
Parent(s): 98e72e1
fix: define FastAPI routes before gr.mount_gradio_app
Browse files
app.py
CHANGED
|
@@ -84,13 +84,13 @@ demo = gr.Interface(
|
|
| 84 |
)
|
| 85 |
|
| 86 |
# ββ FastAPI routes mounted on Gradio app ββββββββββββββββββββββββββββββββββββββ
|
| 87 |
-
|
| 88 |
|
| 89 |
-
@
|
| 90 |
def health():
|
| 91 |
return JSONResponse({"status": "ok"})
|
| 92 |
|
| 93 |
-
@
|
| 94 |
async def synthesize(
|
| 95 |
text: str = Form(...),
|
| 96 |
ref_text: str = Form(...),
|
|
@@ -110,3 +110,5 @@ async def synthesize(
|
|
| 110 |
buf = io.BytesIO()
|
| 111 |
sf.write(buf, audio_out, sample_rate, format="WAV")
|
| 112 |
return Response(content=buf.getvalue(), media_type="audio/wav")
|
|
|
|
|
|
|
|
|
| 84 |
)
|
| 85 |
|
| 86 |
# ββ FastAPI routes mounted on Gradio app ββββββββββββββββββββββββββββββββββββββ
|
| 87 |
+
_api = FastAPI()
|
| 88 |
|
| 89 |
+
@_api.get("/health")
|
| 90 |
def health():
|
| 91 |
return JSONResponse({"status": "ok"})
|
| 92 |
|
| 93 |
+
@_api.post("/synthesize")
|
| 94 |
async def synthesize(
|
| 95 |
text: str = Form(...),
|
| 96 |
ref_text: str = Form(...),
|
|
|
|
| 110 |
buf = io.BytesIO()
|
| 111 |
sf.write(buf, audio_out, sample_rate, format="WAV")
|
| 112 |
return Response(content=buf.getvalue(), media_type="audio/wav")
|
| 113 |
+
|
| 114 |
+
app = gr.mount_gradio_app(_api, demo, path="/")
|