SPACERUNNER99 commited on
Commit
c2d9223
·
verified ·
1 Parent(s): 7a768fa

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -16
app.py CHANGED
@@ -30,11 +30,10 @@ os.makedirs(OUTPUT_DIR, exist_ok=True)
30
  # Initialize the Separator class (this might download the model on first run)
31
  logger.info(f"Initializing audio separator with model: {MODEL_NAME}...")
32
  try:
33
- # You might need to specify log level or other options depending on audio-separator version
34
- separator = Separator(model_name=MODEL_NAME,
35
- log_level='INFO',
36
  # Optional: Specify device (e.g., 'cuda' if PyTorch GPU is setup, else 'cpu')
37
- # computation_device='cuda'
38
  )
39
  logger.info("Separator initialized successfully.")
40
  except Exception as e:
@@ -56,24 +55,25 @@ def enhance_vocal(input_audio_path):
56
  logger.info(f"Processing audio file: {input_audio_path}")
57
  processing_start_time = time.time()
58
 
59
- try:
60
  # --- Step 1: Vocal Separation using audio-separator (UVR5) ---
61
- logger.info("Starting vocal separation...")
62
  separation_start_time = time.time()
63
 
64
- # Create a temporary directory for separation outputs
65
- # This directory will be automatically cleaned up
66
  with tempfile.TemporaryDirectory(prefix=TEMP_SEP_DIR_PREFIX) as temp_sep_dir:
67
  logger.info(f"Using temporary directory for separation: {temp_sep_dir}")
68
-
69
  try:
70
- # Perform separation
71
- # The library typically saves files named like:
72
- # {basename}_(Vocals)_{model_name}.wav
73
- # {basename}_(Instrumental)_{model_name}.wav
74
- # Or similar, depending on the model type and library version.
75
- output_paths = separator.separate(input_audio_path, output_dir=temp_sep_dir)
76
-
 
 
 
77
  separation_duration = time.time() - separation_start_time
78
  logger.info(f"Separation completed in {separation_duration:.2f} seconds.")
79
  logger.info(f"Separation output files: {output_paths}")
 
30
  # Initialize the Separator class (this might download the model on first run)
31
  logger.info(f"Initializing audio separator with model: {MODEL_NAME}...")
32
  try:
33
+ # Initialize Separator WITHOUT the model_name argument first
34
+ separator = Separator(log_level='INFO',
 
35
  # Optional: Specify device (e.g., 'cuda' if PyTorch GPU is setup, else 'cpu')
36
+ # computation_device='cuda'
37
  )
38
  logger.info("Separator initialized successfully.")
39
  except Exception as e:
 
55
  logger.info(f"Processing audio file: {input_audio_path}")
56
  processing_start_time = time.time()
57
 
58
+ try:
59
  # --- Step 1: Vocal Separation using audio-separator (UVR5) ---
60
+ logger.info(f"Starting vocal separation using model: {MODEL_NAME}...") # Log model name here
61
  separation_start_time = time.time()
62
 
 
 
63
  with tempfile.TemporaryDirectory(prefix=TEMP_SEP_DIR_PREFIX) as temp_sep_dir:
64
  logger.info(f"Using temporary directory for separation: {temp_sep_dir}")
65
+
66
  try:
67
+ # Perform separation - NOW we pass the model name HERE
68
+ # Check audio-separator documentation for your version if this exact syntax fails.
69
+ output_paths = separator.separate(
70
+ input_audio_path,
71
+ output_dir=temp_sep_dir,
72
+ model_name=MODEL_NAME # Pass model name to the separate method
73
+ # Other potential arguments might be needed depending on the version
74
+ # e.g., output_format='wav'
75
+ )
76
+
77
  separation_duration = time.time() - separation_start_time
78
  logger.info(f"Separation completed in {separation_duration:.2f} seconds.")
79
  logger.info(f"Separation output files: {output_paths}")