Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -108,7 +108,7 @@ def rename_stems(input_file, output_dir, stems, output_format):
|
|
108 |
renamed_stems.append(new_path)
|
109 |
return renamed_stems
|
110 |
|
111 |
-
def roformer_separator(audio, model_key, seg_size, overlap, model_dir, out_dir, out_format, norm_thresh, amp_thresh):
|
112 |
"""Separate audio using Roformer model."""
|
113 |
model = ROFORMER_MODELS[model_key]
|
114 |
with tempfile.TemporaryDirectory() as tmp_dir:
|
@@ -125,14 +125,18 @@ def roformer_separator(audio, model_key, seg_size, overlap, model_dir, out_dir,
|
|
125 |
}
|
126 |
)
|
127 |
|
|
|
128 |
separator.load_model(model_filename=model)
|
|
|
|
|
129 |
separation = separator.separate(audio)
|
130 |
|
|
|
131 |
stems = rename_stems(audio, out_dir, separation, out_format)
|
132 |
|
133 |
return stems[0], stems[1]
|
134 |
|
135 |
-
def mdx23c_separator(audio, model, seg_size, overlap, model_dir, out_dir, out_format, norm_thresh, amp_thresh):
|
136 |
"""Separate audio using MDX23C model."""
|
137 |
with tempfile.TemporaryDirectory() as tmp_dir:
|
138 |
separator = Separator(
|
@@ -148,14 +152,18 @@ def mdx23c_separator(audio, model, seg_size, overlap, model_dir, out_dir, out_fo
|
|
148 |
}
|
149 |
)
|
150 |
|
|
|
151 |
separator.load_model(model_filename=model)
|
|
|
|
|
152 |
separation = separator.separate(audio)
|
153 |
|
|
|
154 |
stems = rename_stems(audio, out_dir, separation, out_format)
|
155 |
|
156 |
return stems[0], stems[1]
|
157 |
|
158 |
-
def mdx_separator(audio, model, hop_length, seg_size, overlap, denoise, model_dir, out_dir, out_format, norm_thresh, amp_thresh):
|
159 |
"""Separate audio using MDX-NET model."""
|
160 |
with tempfile.TemporaryDirectory() as tmp_dir:
|
161 |
separator = Separator(
|
@@ -173,14 +181,18 @@ def mdx_separator(audio, model, hop_length, seg_size, overlap, denoise, model_di
|
|
173 |
}
|
174 |
)
|
175 |
|
|
|
176 |
separator.load_model(model_filename=model)
|
|
|
|
|
177 |
separation = separator.separate(audio)
|
178 |
|
|
|
179 |
stems = rename_stems(audio, out_dir, separation, out_format)
|
180 |
|
181 |
return stems[0], stems[1]
|
182 |
|
183 |
-
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):
|
184 |
"""Separate audio using VR ARCH model."""
|
185 |
with tempfile.TemporaryDirectory() as tmp_dir:
|
186 |
separator = Separator(
|
@@ -200,14 +212,18 @@ def vr_separator(audio, model, window_size, aggression, tta, post_process, post_
|
|
200 |
}
|
201 |
)
|
202 |
|
|
|
203 |
separator.load_model(model_filename=model)
|
|
|
|
|
204 |
separation = separator.separate(audio)
|
205 |
|
|
|
206 |
stems = rename_stems(audio, out_dir, separation, out_format)
|
207 |
|
208 |
return stems[0], stems[1]
|
209 |
|
210 |
-
def demucs_separator(audio, model, seg_size, shifts, overlap, segments_enabled, model_dir, out_dir, out_format, norm_thresh, amp_thresh):
|
211 |
"""Separate audio using Demucs model."""
|
212 |
with tempfile.TemporaryDirectory() as tmp_dir:
|
213 |
separator = Separator(
|
@@ -224,9 +240,13 @@ def demucs_separator(audio, model, seg_size, shifts, overlap, segments_enabled,
|
|
224 |
}
|
225 |
)
|
226 |
|
|
|
227 |
separator.load_model(model_filename=model)
|
|
|
|
|
228 |
separation = separator.separate(audio)
|
229 |
|
|
|
230 |
stems = rename_stems(audio, out_dir, separation, out_format)
|
231 |
|
232 |
return stems[0], stems[1], stems[2], stems[3]
|
|
|
108 |
renamed_stems.append(new_path)
|
109 |
return renamed_stems
|
110 |
|
111 |
+
def roformer_separator(audio, model_key, seg_size, overlap, model_dir, out_dir, out_format, norm_thresh, amp_thresh, progress=gr.Progress()):
|
112 |
"""Separate audio using Roformer model."""
|
113 |
model = ROFORMER_MODELS[model_key]
|
114 |
with tempfile.TemporaryDirectory() as tmp_dir:
|
|
|
125 |
}
|
126 |
)
|
127 |
|
128 |
+
progress(0.2, desc="Model loaded")
|
129 |
separator.load_model(model_filename=model)
|
130 |
+
|
131 |
+
progress(0.7, desc="Audio separated")
|
132 |
separation = separator.separate(audio)
|
133 |
|
134 |
+
progress(0.9, desc="Stems renamed")
|
135 |
stems = rename_stems(audio, out_dir, separation, out_format)
|
136 |
|
137 |
return stems[0], stems[1]
|
138 |
|
139 |
+
def mdx23c_separator(audio, model, seg_size, overlap, model_dir, out_dir, out_format, norm_thresh, amp_thresh, progress=gr.Progress()):
|
140 |
"""Separate audio using MDX23C model."""
|
141 |
with tempfile.TemporaryDirectory() as tmp_dir:
|
142 |
separator = Separator(
|
|
|
152 |
}
|
153 |
)
|
154 |
|
155 |
+
progress(0.2, desc="Model loaded")
|
156 |
separator.load_model(model_filename=model)
|
157 |
+
|
158 |
+
progress(0.7, desc="Audio separated")
|
159 |
separation = separator.separate(audio)
|
160 |
|
161 |
+
progress(0.9, desc="Stems renamed")
|
162 |
stems = rename_stems(audio, out_dir, separation, out_format)
|
163 |
|
164 |
return stems[0], stems[1]
|
165 |
|
166 |
+
def mdx_separator(audio, model, hop_length, seg_size, overlap, denoise, model_dir, out_dir, out_format, norm_thresh, amp_thresh, progress=gr.Progress()):
|
167 |
"""Separate audio using MDX-NET model."""
|
168 |
with tempfile.TemporaryDirectory() as tmp_dir:
|
169 |
separator = Separator(
|
|
|
181 |
}
|
182 |
)
|
183 |
|
184 |
+
progress(0.2, desc="Model loaded")
|
185 |
separator.load_model(model_filename=model)
|
186 |
+
|
187 |
+
progress(0.7, desc="Audio separated")
|
188 |
separation = separator.separate(audio)
|
189 |
|
190 |
+
progress(0.9, desc="Stems renamed")
|
191 |
stems = rename_stems(audio, out_dir, separation, out_format)
|
192 |
|
193 |
return stems[0], stems[1]
|
194 |
|
195 |
+
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()):
|
196 |
"""Separate audio using VR ARCH model."""
|
197 |
with tempfile.TemporaryDirectory() as tmp_dir:
|
198 |
separator = Separator(
|
|
|
212 |
}
|
213 |
)
|
214 |
|
215 |
+
progress(0.2, desc="Model loaded")
|
216 |
separator.load_model(model_filename=model)
|
217 |
+
|
218 |
+
progress(0.7, desc="Audio separated")
|
219 |
separation = separator.separate(audio)
|
220 |
|
221 |
+
progress(0.9, desc="Stems renamed")
|
222 |
stems = rename_stems(audio, out_dir, separation, out_format)
|
223 |
|
224 |
return stems[0], stems[1]
|
225 |
|
226 |
+
def demucs_separator(audio, model, seg_size, shifts, overlap, segments_enabled, model_dir, out_dir, out_format, norm_thresh, amp_thresh, progress=gr.Progress()):
|
227 |
"""Separate audio using Demucs model."""
|
228 |
with tempfile.TemporaryDirectory() as tmp_dir:
|
229 |
separator = Separator(
|
|
|
240 |
}
|
241 |
)
|
242 |
|
243 |
+
progress(0.2, desc="Model loaded")
|
244 |
separator.load_model(model_filename=model)
|
245 |
+
|
246 |
+
progress(0.7, desc="Audio separated")
|
247 |
separation = separator.separate(audio)
|
248 |
|
249 |
+
progress(0.9, desc="Stems renamed")
|
250 |
stems = rename_stems(audio, out_dir, separation, out_format)
|
251 |
|
252 |
return stems[0], stems[1], stems[2], stems[3]
|