Update app.py
Browse files
app.py
CHANGED
|
@@ -1,26 +1,26 @@
|
|
| 1 |
-
# app.py
|
| 2 |
-
from fastapi import FastAPI, UploadFile, File
|
| 3 |
-
from
|
| 4 |
-
import os
|
| 5 |
-
|
| 6 |
-
app = FastAPI()
|
| 7 |
-
classifier = SpeakerClassifier()
|
| 8 |
-
|
| 9 |
-
@app.post("/predict")
|
| 10 |
-
async def predict_audio(file: UploadFile = File(...)):
|
| 11 |
-
# Save the uploaded file temporarily
|
| 12 |
-
temp_path = f"temp_{file.filename}"
|
| 13 |
-
with open(temp_path, "wb") as f:
|
| 14 |
-
f.write(await file.read())
|
| 15 |
-
|
| 16 |
-
# Predict
|
| 17 |
-
result =
|
| 18 |
-
|
| 19 |
-
# Clean up
|
| 20 |
-
os.remove(temp_path)
|
| 21 |
-
|
| 22 |
-
return result
|
| 23 |
-
|
| 24 |
-
if __name__ == "__main__":
|
| 25 |
-
import uvicorn
|
| 26 |
uvicorn.run(app, host="0.0.0.0", port=8000)
|
|
|
|
| 1 |
+
# app.py
|
| 2 |
+
from fastapi import FastAPI, UploadFile, File
|
| 3 |
+
from infer import *
|
| 4 |
+
import os
|
| 5 |
+
|
| 6 |
+
app = FastAPI()
|
| 7 |
+
# classifier = SpeakerClassifier()
|
| 8 |
+
|
| 9 |
+
@app.post("/predict")
|
| 10 |
+
async def predict_audio(file: UploadFile = File(...)):
|
| 11 |
+
# Save the uploaded file temporarily
|
| 12 |
+
temp_path = f"temp_{file.filename}"
|
| 13 |
+
with open(temp_path, "wb") as f:
|
| 14 |
+
f.write(await file.read())
|
| 15 |
+
|
| 16 |
+
# Predict
|
| 17 |
+
result = testing_pipeline(temp_path)
|
| 18 |
+
|
| 19 |
+
# Clean up
|
| 20 |
+
os.remove(temp_path)
|
| 21 |
+
|
| 22 |
+
return result
|
| 23 |
+
|
| 24 |
+
if __name__ == "__main__":
|
| 25 |
+
import uvicorn
|
| 26 |
uvicorn.run(app, host="0.0.0.0", port=8000)
|