owiedotch commited on
Commit
5c906d0
1 Parent(s): 164f998

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -2
app.py CHANGED
@@ -26,7 +26,7 @@ def inference(audio_file: str, model_name: str, vocals: bool, drums: bool, bass:
26
  # Construct the Demucs command
27
  cmd = [
28
  "python", "-m", "demucs",
29
- "--out", output_dir,
30
  "-n", model_name,
31
  audio_file
32
  ]
@@ -56,9 +56,13 @@ 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
  stems: Dict[str, str] = {}
60
  for stem in ["vocals", "drums", "bass", "other"]:
61
- stem_path = os.path.join(output_dir, model_name, f"{stem}.wav")
62
  yield None, stream_log(f"Checking for {stem} stem at: {stem_path}")
63
  if os.path.exists(stem_path):
64
  stems[stem] = stem_path
@@ -66,6 +70,18 @@ def inference(audio_file: str, model_name: str, vocals: bool, drums: bool, bass:
66
  else:
67
  yield None, stream_log(f"Warning: {stem} stem not found")
68
 
 
 
 
 
 
 
 
 
 
 
 
 
69
  yield None, stream_log(f"All found stems: {list(stems.keys())}")
70
 
71
  selected_stems: List[str] = []
 
26
  # Construct the Demucs command
27
  cmd = [
28
  "python", "-m", "demucs",
29
+ "--out", os.path.dirname(output_dir), # Use the parent directory of output_dir
30
  "-n", model_name,
31
  audio_file
32
  ]
 
56
 
57
  yield None, stream_log("Separation completed. Processing stems...")
58
 
59
+ # Change the stem search directory
60
+ stem_search_dir = os.path.join(output_dir, model_name)
61
+ yield None, stream_log(f"Searching for stems in: {stem_search_dir}")
62
+
63
  stems: Dict[str, str] = {}
64
  for stem in ["vocals", "drums", "bass", "other"]:
65
+ stem_path = os.path.join(stem_search_dir, f"{stem}.wav")
66
  yield None, stream_log(f"Checking for {stem} stem at: {stem_path}")
67
  if os.path.exists(stem_path):
68
  stems[stem] = stem_path
 
70
  else:
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 parent directory...")
75
+ stem_search_dir = output_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}")
79
+ if os.path.exists(stem_path):
80
+ stems[stem] = stem_path
81
+ yield None, stream_log(f"Found {stem} stem")
82
+ else:
83
+ yield None, stream_log(f"Warning: {stem} stem not found")
84
+
85
  yield None, stream_log(f"All found stems: {list(stems.keys())}")
86
 
87
  selected_stems: List[str] = []