owiedotch commited on
Commit
164f998
1 Parent(s): 85fcc07

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -4
app.py CHANGED
@@ -59,19 +59,30 @@ def inference(audio_file: str, model_name: str, vocals: bool, drums: bool, bass:
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
  if os.path.exists(stem_path):
63
  stems[stem] = stem_path
64
  yield None, stream_log(f"Found {stem} stem")
 
 
 
 
65
 
66
  selected_stems: List[str] = []
67
  for stem, selected in zip(["vocals", "drums", "bass", "other"], [vocals, drums, bass, other]):
68
- if selected and stem in stems:
69
- selected_stems.append(stems[stem])
70
- yield None, stream_log(f"Selected {stem} stem for mixing")
 
 
 
 
 
 
71
 
72
  if not selected_stems:
73
  yield None, stream_log("Error: No stems selected for mixing")
74
- raise gr.Error("Please select at least one stem to mix.")
75
 
76
  output_file: str = os.path.join(output_dir, "mixed.wav")
77
  yield None, stream_log("Mixing selected stems...")
 
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
65
  yield None, stream_log(f"Found {stem} stem")
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] = []
72
  for stem, selected in zip(["vocals", "drums", "bass", "other"], [vocals, drums, bass, other]):
73
+ if selected:
74
+ yield None, stream_log(f"{stem} is selected by user")
75
+ if stem in stems:
76
+ selected_stems.append(stems[stem])
77
+ yield None, stream_log(f"Selected {stem} stem for mixing")
78
+ else:
79
+ yield None, stream_log(f"Warning: {stem} was selected but not found")
80
+
81
+ yield None, stream_log(f"Final selected stems: {selected_stems}")
82
 
83
  if not selected_stems:
84
  yield None, stream_log("Error: No stems selected for mixing")
85
+ raise gr.Error("Please select at least one stem to mix and ensure it was successfully separated.")
86
 
87
  output_file: str = os.path.join(output_dir, "mixed.wav")
88
  yield None, stream_log("Mixing selected stems...")