Spaces:
Sleeping
Sleeping
Initial commit with FastAPI + Gradio app
Browse files
app.py
CHANGED
@@ -2,6 +2,7 @@ import io
|
|
2 |
import tempfile
|
3 |
from fastapi import FastAPI, HTTPException, File, UploadFile
|
4 |
from speechbrain.inference import SpeakerRecognition
|
|
|
5 |
|
6 |
# Initialize the speaker verification model
|
7 |
verification = SpeakerRecognition.from_hparams(
|
@@ -54,7 +55,12 @@ async def compare_voices_api(file1: UploadFile = File(...), file2: UploadFile =
|
|
54 |
except Exception as e:
|
55 |
raise HTTPException(status_code=400, detail=str(e))
|
56 |
|
|
|
|
|
|
|
|
|
|
|
57 |
# Running the FastAPI app
|
58 |
if __name__ == "__main__":
|
59 |
import uvicorn
|
60 |
-
uvicorn.run(app, host="
|
|
|
2 |
import tempfile
|
3 |
from fastapi import FastAPI, HTTPException, File, UploadFile
|
4 |
from speechbrain.inference import SpeakerRecognition
|
5 |
+
from fastapi.openapi.docs import get_swagger_ui_html
|
6 |
|
7 |
# Initialize the speaker verification model
|
8 |
verification = SpeakerRecognition.from_hparams(
|
|
|
55 |
except Exception as e:
|
56 |
raise HTTPException(status_code=400, detail=str(e))
|
57 |
|
58 |
+
# Custom route to expose Swagger UI
|
59 |
+
@app.get("/docs")
|
60 |
+
def custom_swagger_ui_html():
|
61 |
+
return get_swagger_ui_html(openapi_url=app.openapi_url, title="API Docs")
|
62 |
+
|
63 |
# Running the FastAPI app
|
64 |
if __name__ == "__main__":
|
65 |
import uvicorn
|
66 |
+
uvicorn.run(app, host="127.0.0.0", port=5000)
|