from fastapi import FastAPI, File, Form, UploadFile import shutil import os app = FastAPI() if not os.path.exists('./tarun_1234'): os.mkdir('./tarun_1234') @app.post("/save_audio") async def save_audio(audio: UploadFile = File(...), path: str = Form(...)): # print('PATH ************************ >>>>>', path) folder_path = path.split('/')[1] # print('FOLDER PATH ----------->>>>>>>>>>>>>>', folder_path) if not os.path.exists(folder_path): os.mkdir(folder_path) print("Received Audio !!!!!") # Save the audio to the specified path with open(path, "wb") as buffer: shutil.copyfileobj(audio.file, buffer) return {"message": "Audio saved successfully"} if __name__ == '__main__': import uvicorn uvicorn.run(app, host="0.0.0.0", port=7860)