github-actions[bot] commited on
Commit
ef24873
·
1 Parent(s): 61f32ab

Sync from GitHub: 5c4dc2b10bee528ddb7361e9d8a66872ade756e9

Browse files
Files changed (1) hide show
  1. services/audio_separator.py +16 -7
services/audio_separator.py CHANGED
@@ -224,16 +224,25 @@ class AudioSeparator:
224
  rhythm_stereo = normalize(rhythm_stereo)
225
  lead_stereo = normalize(lead_stereo)
226
 
227
- # Save files
228
- path_rhythm = os.path.join(output_dir, "guitar_rhythm.mp3")
229
- path_lead = os.path.join(output_dir, "guitar_lead.mp3")
 
230
 
231
- self._save_audio(rhythm_stereo, sr, path_rhythm)
232
- self._save_audio(lead_stereo, sr, path_lead)
 
 
 
 
 
 
 
 
 
233
 
234
  return {
235
- "guitar_rhythm": path_rhythm,
236
- "guitar_lead": path_lead
237
  }
238
 
239
  def _save_audio(self, source, sr, path):
 
224
  rhythm_stereo = normalize(rhythm_stereo)
225
  lead_stereo = normalize(lead_stereo)
226
 
227
+ # MERGE TO SINGLE STEREO FILE (L=Rhythm, R=Lead)
228
+ # We take the Left channel of the Rhythm stereo mix (which is mono-ish)
229
+ # And the Right channel of the Lead stereo mix (which is mono-ish)
230
+ # Or better: Just use the Mono mix of each.
231
 
232
+ rhythm_mono = rhythm_stereo.mean(dim=0, keepdim=True)
233
+ lead_mono = lead_stereo.mean(dim=0, keepdim=True)
234
+
235
+ # Combine: Channel 0 = Rhythm, Channel 1 = Lead
236
+ guitar_split = torch.cat([rhythm_mono, lead_mono], dim=0)
237
+
238
+ guitar_split = normalize(guitar_split)
239
+
240
+ # Save as single file named "guitar.mp3" (Special split)
241
+ path = os.path.join(output_dir, "guitar.mp3")
242
+ self._save_audio(guitar_split, sr, path)
243
 
244
  return {
245
+ "guitar": path
 
246
  }
247
 
248
  def _save_audio(self, source, sr, path):