Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,4 @@
|
|
1 |
import os
|
2 |
-
import tempfile
|
3 |
import gradio as gr
|
4 |
|
5 |
from audio_separator.separator import Separator
|
@@ -111,145 +110,140 @@ def rename_stems(input_file, output_dir, stems, output_format):
|
|
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 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
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 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
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 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
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 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
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 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
return stems[0], stems[1], stems[2], stems[3]
|
253 |
|
254 |
with gr.Blocks(title="🎵 PolUVR - Politrees 🎵", css="footer{display:none !important}") as app:
|
255 |
gr.Markdown("<h1> Audio-Separator by Politrees </h1>")
|
|
|
1 |
import os
|
|
|
2 |
import gradio as gr
|
3 |
|
4 |
from audio_separator.separator import Separator
|
|
|
110 |
def roformer_separator(audio, model_key, seg_size, overlap, model_dir, out_dir, out_format, norm_thresh, amp_thresh, progress=gr.Progress()):
|
111 |
"""Separate audio using Roformer model."""
|
112 |
model = ROFORMER_MODELS[model_key]
|
113 |
+
separator = Separator(
|
114 |
+
model_file_dir=model_dir,
|
115 |
+
output_dir=out_dir,
|
116 |
+
output_format=out_format,
|
117 |
+
normalization_threshold=norm_thresh,
|
118 |
+
amplification_threshold=amp_thresh,
|
119 |
+
mdxc_params={
|
120 |
+
"batch_size": 1,
|
121 |
+
"segment_size": seg_size,
|
122 |
+
"overlap": overlap,
|
123 |
+
}
|
124 |
+
)
|
125 |
+
|
126 |
+
progress(0.2, desc="Model loaded")
|
127 |
+
separator.load_model(model_filename=model)
|
128 |
+
|
129 |
+
progress(0.7, desc="Audio separated")
|
130 |
+
separation = separator.separate(audio)
|
131 |
+
|
132 |
+
progress(0.9, desc="Stems renamed")
|
133 |
+
stems = rename_stems(audio, out_dir, separation, out_format)
|
134 |
+
|
135 |
+
return stems[0], stems[1]
|
|
|
136 |
|
137 |
def mdx23c_separator(audio, model, seg_size, overlap, model_dir, out_dir, out_format, norm_thresh, amp_thresh, progress=gr.Progress()):
|
138 |
"""Separate audio using MDX23C model."""
|
139 |
+
separator = Separator(
|
140 |
+
model_file_dir=model_dir,
|
141 |
+
output_dir=out_dir,
|
142 |
+
output_format=out_format,
|
143 |
+
normalization_threshold=norm_thresh,
|
144 |
+
amplification_threshold=amp_thresh,
|
145 |
+
mdxc_params={
|
146 |
+
"batch_size": 1,
|
147 |
+
"segment_size": seg_size,
|
148 |
+
"overlap": overlap,
|
149 |
+
}
|
150 |
+
)
|
151 |
+
|
152 |
+
progress(0.2, desc="Model loaded")
|
153 |
+
separator.load_model(model_filename=model)
|
154 |
+
|
155 |
+
progress(0.7, desc="Audio separated")
|
156 |
+
separation = separator.separate(audio)
|
157 |
+
|
158 |
+
progress(0.9, desc="Stems renamed")
|
159 |
+
stems = rename_stems(audio, out_dir, separation, out_format)
|
160 |
+
|
161 |
+
return stems[0], stems[1]
|
|
|
162 |
|
163 |
def mdx_separator(audio, model, hop_length, seg_size, overlap, denoise, model_dir, out_dir, out_format, norm_thresh, amp_thresh, progress=gr.Progress()):
|
164 |
"""Separate audio using MDX-NET model."""
|
165 |
+
separator = Separator(
|
166 |
+
model_file_dir=model_dir,
|
167 |
+
output_dir=out_dir,
|
168 |
+
output_format=out_format,
|
169 |
+
normalization_threshold=norm_thresh,
|
170 |
+
amplification_threshold=amp_thresh,
|
171 |
+
mdx_params={
|
172 |
+
"batch_size": 1,
|
173 |
+
"hop_length": hop_length,
|
174 |
+
"segment_size": seg_size,
|
175 |
+
"overlap": overlap,
|
176 |
+
"enable_denoise": denoise,
|
177 |
+
}
|
178 |
+
)
|
179 |
+
|
180 |
+
progress(0.2, desc="Model loaded")
|
181 |
+
separator.load_model(model_filename=model)
|
182 |
+
|
183 |
+
progress(0.7, desc="Audio separated")
|
184 |
+
separation = separator.separate(audio)
|
185 |
+
|
186 |
+
progress(0.9, desc="Stems renamed")
|
187 |
+
stems = rename_stems(audio, out_dir, separation, out_format)
|
188 |
+
|
189 |
+
return stems[0], stems[1]
|
|
|
190 |
|
191 |
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()):
|
192 |
"""Separate audio using VR ARCH model."""
|
193 |
+
separator = Separator(
|
194 |
+
model_file_dir=model_dir,
|
195 |
+
output_dir=out_dir,
|
196 |
+
output_format=out_format,
|
197 |
+
normalization_threshold=norm_thresh,
|
198 |
+
amplification_threshold=amp_thresh,
|
199 |
+
vr_params={
|
200 |
+
"batch_size": 1,
|
201 |
+
"window_size": window_size,
|
202 |
+
"aggression": aggression,
|
203 |
+
"enable_tta": tta,
|
204 |
+
"enable_post_process": post_process,
|
205 |
+
"post_process_threshold": post_process_threshold,
|
206 |
+
"high_end_process": high_end_process,
|
207 |
+
}
|
208 |
+
)
|
209 |
+
|
210 |
+
progress(0.2, desc="Model loaded")
|
211 |
+
separator.load_model(model_filename=model)
|
212 |
+
|
213 |
+
progress(0.7, desc="Audio separated")
|
214 |
+
separation = separator.separate(audio)
|
215 |
+
|
216 |
+
progress(0.9, desc="Stems renamed")
|
217 |
+
stems = rename_stems(audio, out_dir, separation, out_format)
|
218 |
+
|
219 |
+
return stems[0], stems[1]
|
|
|
220 |
|
221 |
def demucs_separator(audio, model, seg_size, shifts, overlap, segments_enabled, model_dir, out_dir, out_format, norm_thresh, amp_thresh, progress=gr.Progress()):
|
222 |
"""Separate audio using Demucs model."""
|
223 |
+
separator = Separator(
|
224 |
+
model_file_dir=model_dir,
|
225 |
+
output_dir=out_dir,
|
226 |
+
output_format=out_format,
|
227 |
+
normalization_threshold=norm_thresh,
|
228 |
+
amplification_threshold=amp_thresh,
|
229 |
+
demucs_params={
|
230 |
+
"segment_size": seg_size,
|
231 |
+
"shifts": shifts,
|
232 |
+
"overlap": overlap,
|
233 |
+
"segments_enabled": segments_enabled,
|
234 |
+
}
|
235 |
+
)
|
236 |
+
|
237 |
+
progress(0.2, desc="Model loaded")
|
238 |
+
separator.load_model(model_filename=model)
|
239 |
+
|
240 |
+
progress(0.7, desc="Audio separated")
|
241 |
+
separation = separator.separate(audio)
|
242 |
+
|
243 |
+
progress(0.9, desc="Stems renamed")
|
244 |
+
stems = rename_stems(audio, out_dir, separation, out_format)
|
245 |
+
|
246 |
+
return stems[0], stems[1], stems[2], stems[3]
|
|
|
247 |
|
248 |
with gr.Blocks(title="🎵 PolUVR - Politrees 🎵", css="footer{display:none !important}") as app:
|
249 |
gr.Markdown("<h1> Audio-Separator by Politrees </h1>")
|