Spaces:
Runtime error
Runtime error
Update app.py
Browse files
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 |
-
#
|
34 |
-
separator = Separator(
|
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 |
-
|
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 |
-
#
|
72 |
-
|
73 |
-
|
74 |
-
|
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}")
|
|
|
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}")
|