github-actions[bot] commited on
Commit ·
ef24873
1
Parent(s): 61f32ab
Sync from GitHub: 5c4dc2b10bee528ddb7361e9d8a66872ade756e9
Browse files- 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 |
-
#
|
| 228 |
-
|
| 229 |
-
|
|
|
|
| 230 |
|
| 231 |
-
|
| 232 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 233 |
|
| 234 |
return {
|
| 235 |
-
"
|
| 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):
|