Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -20,13 +20,15 @@ def inference(audio_file: str, model_name: str, vocals: bool, drums: bool, bass:
|
|
20 |
yield None, stream_log("Error: No audio file provided")
|
21 |
raise gr.Error("Please upload an audio file")
|
22 |
|
23 |
-
|
|
|
|
|
24 |
os.makedirs(output_dir, exist_ok=True)
|
25 |
|
26 |
-
# Construct the Demucs command
|
27 |
cmd = [
|
28 |
"python", "-m", "demucs",
|
29 |
-
"--out",
|
30 |
"-n", model_name,
|
31 |
audio_file
|
32 |
]
|
@@ -56,8 +58,8 @@ def inference(audio_file: str, model_name: str, vocals: bool, drums: bool, bass:
|
|
56 |
|
57 |
yield None, stream_log("Separation completed. Processing stems...")
|
58 |
|
59 |
-
# Change the stem search directory
|
60 |
-
stem_search_dir = os.path.join(
|
61 |
yield None, stream_log(f"Searching for stems in: {stem_search_dir}")
|
62 |
|
63 |
stems: Dict[str, str] = {}
|
@@ -71,8 +73,8 @@ def inference(audio_file: str, model_name: str, vocals: bool, drums: bool, bass:
|
|
71 |
yield None, stream_log(f"Warning: {stem} stem not found")
|
72 |
|
73 |
if not stems:
|
74 |
-
yield None, stream_log("Error: No stems found. Checking
|
75 |
-
stem_search_dir =
|
76 |
for stem in ["vocals", "drums", "bass", "other"]:
|
77 |
stem_path = os.path.join(stem_search_dir, f"{stem}.wav")
|
78 |
yield None, stream_log(f"Checking for {stem} stem at: {stem_path}")
|
|
|
20 |
yield None, stream_log("Error: No audio file provided")
|
21 |
raise gr.Error("Please upload an audio file")
|
22 |
|
23 |
+
# Use absolute paths
|
24 |
+
base_output_dir = os.path.abspath("separated")
|
25 |
+
output_dir = os.path.join(base_output_dir, model_name, os.path.splitext(os.path.basename(audio_file))[0])
|
26 |
os.makedirs(output_dir, exist_ok=True)
|
27 |
|
28 |
+
# Construct the Demucs command with full paths
|
29 |
cmd = [
|
30 |
"python", "-m", "demucs",
|
31 |
+
"--out", base_output_dir,
|
32 |
"-n", model_name,
|
33 |
audio_file
|
34 |
]
|
|
|
58 |
|
59 |
yield None, stream_log("Separation completed. Processing stems...")
|
60 |
|
61 |
+
# Change the stem search directory using full path
|
62 |
+
stem_search_dir = os.path.join(base_output_dir, model_name, os.path.splitext(os.path.basename(audio_file))[0])
|
63 |
yield None, stream_log(f"Searching for stems in: {stem_search_dir}")
|
64 |
|
65 |
stems: Dict[str, str] = {}
|
|
|
73 |
yield None, stream_log(f"Warning: {stem} stem not found")
|
74 |
|
75 |
if not stems:
|
76 |
+
yield None, stream_log("Error: No stems found. Checking alternative directory...")
|
77 |
+
stem_search_dir = os.path.join(base_output_dir, model_name)
|
78 |
for stem in ["vocals", "drums", "bass", "other"]:
|
79 |
stem_path = os.path.join(stem_search_dir, f"{stem}.wav")
|
80 |
yield None, stream_log(f"Checking for {stem} stem at: {stem_path}")
|