ArnavGhost commited on
Commit
7064395
1 Parent(s): 63bdccf

Update server.py

Browse files
Files changed (1) hide show
  1. server.py +5 -7
server.py CHANGED
@@ -5,13 +5,11 @@ import torch
5
  import os
6
  from pipeline import build_audiosep, separate_audio
7
 
8
- app = FastAPI()
 
 
9
 
10
- @app.on_event("startup")
11
- async def startup_event():
12
- # Create directories for uploaded and processed files
13
- os.makedirs('uploaded', exist_ok=True)
14
- os.makedirs('processed', exist_ok=True)
15
 
16
  # Mount the static files directory
17
  app.mount("/processed", StaticFiles(directory="processed"), name="processed")
@@ -41,4 +39,4 @@ async def upload_file(file: UploadFile = File(...), text: str = Form(...)):
41
 
42
  # Response with processed audio file URL
43
  processed_file_url = f"/processed/{os.path.basename(processed_audio_file_path)}"
44
- return JSONResponse(status_code=200, content={"message": "Audio file received and processed.", "processed_audio_file": processed_file_url})
 
5
  import os
6
  from pipeline import build_audiosep, separate_audio
7
 
8
+ # Ensure directories exist
9
+ os.makedirs('uploaded', exist_ok=True)
10
+ os.makedirs('processed', exist_ok=True)
11
 
12
+ app = FastAPI()
 
 
 
 
13
 
14
  # Mount the static files directory
15
  app.mount("/processed", StaticFiles(directory="processed"), name="processed")
 
39
 
40
  # Response with processed audio file URL
41
  processed_file_url = f"/processed/{os.path.basename(processed_audio_file_path)}"
42
+ return JSONResponse(status_code=200, content={"message": "Audio file received and processed.", "processed_audio_file": processed_file_url})