diff --git a/api/api/tasks.py b/api/api/tasks.py index f8955b2..6043223 100644 --- a/api/api/tasks.py +++ b/api/api/tasks.py @@ -78,8 +78,15 @@ def music_separation_task(file_path): # Determine the base directory (output path) output_path = file_path.parent - # Run Demucs separation - separate_audio_with_demucs(str(file_path), str(output_path)) + try: + # Run Demucs separation + separate_audio_with_demucs(str(file_path), str(output_path)) + except Exception as e: + print(f"Failed to separate music into sources: {e}") + + if os.path.exists(os.path.dirname(file_path)): + shutil.rmtree(os.path.dirname(file_path)) + return False # Define expected output dir demucs_dir = output_path / 'htdemucs' @@ -116,6 +123,7 @@ def music_separation_task(file_path): return True except Exception as e: + print(f"Failed to separate music into sources: {e}") return False @shared_task