# 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)