Spaces:
Sleeping
Sleeping
helloWorld199
commited on
Commit
•
3d15671
1
Parent(s):
571bc0c
Upload 2 files
Browse files- src/main.py +8 -1
- src/my_utils.py +15 -1
src/main.py
CHANGED
@@ -18,6 +18,7 @@ import yt_dlp
|
|
18 |
from pedalboard import Pedalboard, Reverb, Compressor, HighpassFilter
|
19 |
from pedalboard.io import AudioFile
|
20 |
from pydub import AudioSegment
|
|
|
21 |
|
22 |
from mdx import run_mdx
|
23 |
from rvc import Config, load_hubert, get_vc, rvc_infer
|
@@ -361,9 +362,15 @@ def song_cover_pipeline(song_input, voice_model, pitch_change, keep_files,
|
|
361 |
if file and os.path.exists(file):
|
362 |
os.remove(file)
|
363 |
|
|
|
|
|
|
|
|
|
|
|
|
|
364 |
# Returning the stems: AI cover, original vocal, original instrumental, AI generated vocal
|
365 |
|
366 |
-
return ai_cover_path, vocals_path, instrumentals_path,
|
367 |
|
368 |
except Exception as e:
|
369 |
raise_exception(str(e), is_webui)
|
|
|
18 |
from pedalboard import Pedalboard, Reverb, Compressor, HighpassFilter
|
19 |
from pedalboard.io import AudioFile
|
20 |
from pydub import AudioSegment
|
21 |
+
from my_utils import add_stem_name
|
22 |
|
23 |
from mdx import run_mdx
|
24 |
from rvc import Config, load_hubert, get_vc, rvc_infer
|
|
|
362 |
if file and os.path.exists(file):
|
363 |
os.remove(file)
|
364 |
|
365 |
+
# Add _stemname to each stem
|
366 |
+
ai_cover_path = add_stem_name(ai_cover_path, "_cover")
|
367 |
+
vocals_path = add_stem_name(vocals_path, "_origvocals")
|
368 |
+
instrumentals_path = add_stem_name(instrumentals_path, "_originstr")
|
369 |
+
ai_vocals_mixed_path = add_stem_name(ai_vocals_mixed_path, "_covervocals")
|
370 |
+
|
371 |
# Returning the stems: AI cover, original vocal, original instrumental, AI generated vocal
|
372 |
|
373 |
+
return ai_cover_path, vocals_path, instrumentals_path, ai_vocals_mixed_path
|
374 |
|
375 |
except Exception as e:
|
376 |
raise_exception(str(e), is_webui)
|
src/my_utils.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
import ffmpeg
|
2 |
import numpy as np
|
3 |
-
|
4 |
|
5 |
def load_audio(file, sr):
|
6 |
try:
|
@@ -19,3 +19,17 @@ def load_audio(file, sr):
|
|
19 |
raise RuntimeError(f"Failed to load audio: {e}")
|
20 |
|
21 |
return np.frombuffer(out, np.float32).flatten()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import ffmpeg
|
2 |
import numpy as np
|
3 |
+
import os
|
4 |
|
5 |
def load_audio(file, sr):
|
6 |
try:
|
|
|
19 |
raise RuntimeError(f"Failed to load audio: {e}")
|
20 |
|
21 |
return np.frombuffer(out, np.float32).flatten()
|
22 |
+
|
23 |
+
|
24 |
+
def add_stem_name(path, stemname):
|
25 |
+
|
26 |
+
directory, filename_with_ext = os.path.split(path)
|
27 |
+
filename, extension = os.path.splitext(filename_with_ext)
|
28 |
+
|
29 |
+
# Concatenate the stem name with desired suffix and extension
|
30 |
+
new_filename = f"{filename}{stemname}{extension}"
|
31 |
+
|
32 |
+
# Construct the new path
|
33 |
+
new_path = os.path.join(directory, new_filename)
|
34 |
+
|
35 |
+
return new_path
|