Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -98,6 +98,15 @@ DEMUCS_MODELS = [
|
|
98 |
'hdemucs_mmi.yaml',
|
99 |
]
|
100 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
def rename_stems(input_file, output_dir, stems, output_format):
|
102 |
"""Rename stems to the format of the input file name with __(StemX) suffix."""
|
103 |
base_name = os.path.splitext(os.path.basename(input_file))[0]
|
@@ -106,6 +115,7 @@ def rename_stems(input_file, output_dir, stems, output_format):
|
|
106 |
new_name = f"{base_name}_(Stem{i+1}).{output_format}"
|
107 |
new_path = os.path.join(output_dir, new_name)
|
108 |
try:
|
|
|
109 |
os.rename(os.path.join(output_dir, stem), new_path)
|
110 |
renamed_stems.append(new_path)
|
111 |
except Exception as e:
|
@@ -127,6 +137,7 @@ def prepare_output_dir(input_file, output_dir):
|
|
127 |
|
128 |
def roformer_separator(audio, model_key, seg_size, overlap, model_dir, out_dir, out_format, norm_thresh, amp_thresh, progress=gr.Progress()):
|
129 |
"""Separate audio using Roformer model."""
|
|
|
130 |
model = ROFORMER_MODELS[model_key]
|
131 |
try:
|
132 |
out_dir = prepare_output_dir(audio, out_dir)
|
@@ -160,6 +171,7 @@ def roformer_separator(audio, model_key, seg_size, overlap, model_dir, out_dir,
|
|
160 |
|
161 |
def mdx23c_separator(audio, model, seg_size, overlap, model_dir, out_dir, out_format, norm_thresh, amp_thresh, progress=gr.Progress()):
|
162 |
"""Separate audio using MDX23C model."""
|
|
|
163 |
try:
|
164 |
out_dir = prepare_output_dir(audio, out_dir)
|
165 |
separator = Separator(
|
@@ -192,6 +204,7 @@ def mdx23c_separator(audio, model, seg_size, overlap, model_dir, out_dir, out_fo
|
|
192 |
|
193 |
def mdx_separator(audio, model, hop_length, seg_size, overlap, denoise, model_dir, out_dir, out_format, norm_thresh, amp_thresh, progress=gr.Progress()):
|
194 |
"""Separate audio using MDX-NET model."""
|
|
|
195 |
try:
|
196 |
out_dir = prepare_output_dir(audio, out_dir)
|
197 |
separator = Separator(
|
@@ -226,6 +239,7 @@ def mdx_separator(audio, model, hop_length, seg_size, overlap, denoise, model_di
|
|
226 |
|
227 |
def vr_separator(audio, model, window_size, aggression, tta, post_process, post_process_threshold, high_end_process, model_dir, out_dir, out_format, norm_thresh, amp_thresh, progress=gr.Progress()):
|
228 |
"""Separate audio using VR ARCH model."""
|
|
|
229 |
try:
|
230 |
out_dir = prepare_output_dir(audio, out_dir)
|
231 |
separator = Separator(
|
@@ -262,6 +276,7 @@ def vr_separator(audio, model, window_size, aggression, tta, post_process, post_
|
|
262 |
|
263 |
def demucs_separator(audio, model, seg_size, shifts, overlap, segments_enabled, model_dir, out_dir, out_format, norm_thresh, amp_thresh, progress=gr.Progress()):
|
264 |
"""Separate audio using Demucs model."""
|
|
|
265 |
try:
|
266 |
out_dir = prepare_output_dir(audio, out_dir)
|
267 |
separator = Separator(
|
|
|
98 |
'hdemucs_mmi.yaml',
|
99 |
]
|
100 |
|
101 |
+
def print_message(input_file, model_name):
|
102 |
+
"""Prints information about the audio separation process."""
|
103 |
+
base_name = os.path.splitext(os.path.basename(input_file))[0]
|
104 |
+
print("\n")
|
105 |
+
print("🎵 PolUVR 🎵")
|
106 |
+
print("Input audio:", base_name)
|
107 |
+
print("Separation Model:", model_name)
|
108 |
+
print("Audio Separation Process...")
|
109 |
+
|
110 |
def rename_stems(input_file, output_dir, stems, output_format):
|
111 |
"""Rename stems to the format of the input file name with __(StemX) suffix."""
|
112 |
base_name = os.path.splitext(os.path.basename(input_file))[0]
|
|
|
115 |
new_name = f"{base_name}_(Stem{i+1}).{output_format}"
|
116 |
new_path = os.path.join(output_dir, new_name)
|
117 |
try:
|
118 |
+
print("Separation result:", new_name)
|
119 |
os.rename(os.path.join(output_dir, stem), new_path)
|
120 |
renamed_stems.append(new_path)
|
121 |
except Exception as e:
|
|
|
137 |
|
138 |
def roformer_separator(audio, model_key, seg_size, overlap, model_dir, out_dir, out_format, norm_thresh, amp_thresh, progress=gr.Progress()):
|
139 |
"""Separate audio using Roformer model."""
|
140 |
+
print_message(audio, model_key)
|
141 |
model = ROFORMER_MODELS[model_key]
|
142 |
try:
|
143 |
out_dir = prepare_output_dir(audio, out_dir)
|
|
|
171 |
|
172 |
def mdx23c_separator(audio, model, seg_size, overlap, model_dir, out_dir, out_format, norm_thresh, amp_thresh, progress=gr.Progress()):
|
173 |
"""Separate audio using MDX23C model."""
|
174 |
+
print_message(audio, model)
|
175 |
try:
|
176 |
out_dir = prepare_output_dir(audio, out_dir)
|
177 |
separator = Separator(
|
|
|
204 |
|
205 |
def mdx_separator(audio, model, hop_length, seg_size, overlap, denoise, model_dir, out_dir, out_format, norm_thresh, amp_thresh, progress=gr.Progress()):
|
206 |
"""Separate audio using MDX-NET model."""
|
207 |
+
print_message(audio, model)
|
208 |
try:
|
209 |
out_dir = prepare_output_dir(audio, out_dir)
|
210 |
separator = Separator(
|
|
|
239 |
|
240 |
def vr_separator(audio, model, window_size, aggression, tta, post_process, post_process_threshold, high_end_process, model_dir, out_dir, out_format, norm_thresh, amp_thresh, progress=gr.Progress()):
|
241 |
"""Separate audio using VR ARCH model."""
|
242 |
+
print_message(audio, model)
|
243 |
try:
|
244 |
out_dir = prepare_output_dir(audio, out_dir)
|
245 |
separator = Separator(
|
|
|
276 |
|
277 |
def demucs_separator(audio, model, seg_size, shifts, overlap, segments_enabled, model_dir, out_dir, out_format, norm_thresh, amp_thresh, progress=gr.Progress()):
|
278 |
"""Separate audio using Demucs model."""
|
279 |
+
print_message(audio, model)
|
280 |
try:
|
281 |
out_dir = prepare_output_dir(audio, out_dir)
|
282 |
separator = Separator(
|