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