Spaces:
Running
Running
Update main/app/app.py
Browse files- main/app/app.py +4 -757
main/app/app.py
CHANGED
@@ -25,6 +25,8 @@ import soundfile as sf
|
|
25 |
from time import sleep
|
26 |
from multiprocessing import cpu_count
|
27 |
from main.app.tabs.inference.inference import inference_tabs
|
|
|
|
|
28 |
sys.path.append(os.getcwd())
|
29 |
|
30 |
from main.tools import huggingface
|
@@ -143,765 +145,10 @@ with gr.Blocks(title=" Ultimate RVC Maker ⚡", theme=theme) as app:
|
|
143 |
inference_tabs()
|
144 |
|
145 |
|
146 |
-
with gr.TabItem(
|
147 |
-
|
148 |
-
with gr.Row():
|
149 |
-
gr.Markdown(translations["download_markdown_2"])
|
150 |
-
with gr.Row():
|
151 |
-
with gr.Accordion(translations["model_download"], open=True):
|
152 |
-
with gr.Row():
|
153 |
-
downloadmodel = gr.Radio(label=translations["model_download_select"], choices=[translations["download_url"], translations["download_from_csv"], translations["search_models"], translations["upload"]], interactive=True, value=translations["download_url"])
|
154 |
-
with gr.Row():
|
155 |
-
gr.Markdown("___")
|
156 |
-
with gr.Column():
|
157 |
-
with gr.Row():
|
158 |
-
url_input = gr.Textbox(label=translations["model_url"], value="", placeholder="https://...", scale=6)
|
159 |
-
download_model_name = gr.Textbox(label=translations["modelname"], value="", placeholder=translations["modelname"], scale=2)
|
160 |
-
url_download = gr.Button(value=translations["downloads"], scale=2)
|
161 |
-
with gr.Column():
|
162 |
-
model_browser = gr.Dropdown(choices=models.keys(), label=translations["model_warehouse"], scale=8, allow_custom_value=True, visible=False)
|
163 |
-
download_from_browser = gr.Button(value=translations["get_model"], scale=2, variant="primary", visible=False)
|
164 |
-
with gr.Column():
|
165 |
-
search_name = gr.Textbox(label=translations["name_to_search"], placeholder=translations["modelname"], interactive=True, scale=8, visible=False)
|
166 |
-
search = gr.Button(translations["search_2"], scale=2, visible=False)
|
167 |
-
search_dropdown = gr.Dropdown(label=translations["select_download_model"], value="", choices=[], allow_custom_value=True, interactive=False, visible=False)
|
168 |
-
download = gr.Button(translations["downloads"], variant="primary", visible=False)
|
169 |
-
with gr.Column():
|
170 |
-
model_upload = gr.File(label=translations["drop_model"], file_types=[".pth", ".onnx", ".index", ".zip"], visible=False)
|
171 |
-
with gr.Row():
|
172 |
-
with gr.Accordion(translations["download_pretrained_2"], open=False):
|
173 |
-
with gr.Row():
|
174 |
-
pretrain_download_choices = gr.Radio(label=translations["model_download_select"], choices=[translations["download_url"], translations["list_model"], translations["upload"]], value=translations["download_url"], interactive=True)
|
175 |
-
with gr.Row():
|
176 |
-
gr.Markdown("___")
|
177 |
-
with gr.Column():
|
178 |
-
with gr.Row():
|
179 |
-
pretrainD = gr.Textbox(label=translations["pretrained_url"].format(dg="D"), value="", info=translations["only_huggingface"], placeholder="https://...", interactive=True, scale=4)
|
180 |
-
pretrainG = gr.Textbox(label=translations["pretrained_url"].format(dg="G"), value="", info=translations["only_huggingface"], placeholder="https://...", interactive=True, scale=4)
|
181 |
-
download_pretrain_button = gr.Button(translations["downloads"], scale=2)
|
182 |
-
with gr.Column():
|
183 |
-
with gr.Row():
|
184 |
-
pretrain_choices = gr.Dropdown(label=translations["select_pretrain"], info=translations["select_pretrain_info"], choices=list(fetch_pretrained_data().keys()), value="Titan_Medium", allow_custom_value=True, interactive=True, scale=6, visible=False)
|
185 |
-
sample_rate_pretrain = gr.Dropdown(label=translations["pretrain_sr"], info=translations["pretrain_sr"], choices=["48k", "40k", "32k"], value="48k", interactive=True, visible=False)
|
186 |
-
download_pretrain_choices_button = gr.Button(translations["downloads"], scale=2, variant="primary", visible=False)
|
187 |
-
with gr.Row():
|
188 |
-
pretrain_upload_g = gr.File(label=translations["drop_pretrain"].format(dg="G"), file_types=[".pth"], visible=False)
|
189 |
-
pretrain_upload_d = gr.File(label=translations["drop_pretrain"].format(dg="D"), file_types=[".pth"], visible=False)
|
190 |
-
with gr.Row():
|
191 |
-
url_download.click(
|
192 |
-
fn=download_model,
|
193 |
-
inputs=[
|
194 |
-
url_input,
|
195 |
-
download_model_name
|
196 |
-
],
|
197 |
-
outputs=[url_input],
|
198 |
-
api_name="download_model"
|
199 |
-
)
|
200 |
-
download_from_browser.click(
|
201 |
-
fn=lambda model: download_model(models[model], model),
|
202 |
-
inputs=[model_browser],
|
203 |
-
outputs=[model_browser],
|
204 |
-
api_name="download_browser"
|
205 |
-
)
|
206 |
-
with gr.Row():
|
207 |
-
downloadmodel.change(fn=change_download_choices, inputs=[downloadmodel], outputs=[url_input, download_model_name, url_download, model_browser, download_from_browser, search_name, search, search_dropdown, download, model_upload])
|
208 |
-
search.click(fn=search_models, inputs=[search_name], outputs=[search_dropdown, download])
|
209 |
-
model_upload.upload(fn=save_drop_model, inputs=[model_upload], outputs=[model_upload])
|
210 |
-
download.click(
|
211 |
-
fn=lambda model: download_model(model_options[model], model),
|
212 |
-
inputs=[search_dropdown],
|
213 |
-
outputs=[search_dropdown],
|
214 |
-
api_name="search_models"
|
215 |
-
)
|
216 |
-
with gr.Row():
|
217 |
-
pretrain_download_choices.change(fn=change_download_pretrained_choices, inputs=[pretrain_download_choices], outputs=[pretrainD, pretrainG, download_pretrain_button, pretrain_choices, sample_rate_pretrain, download_pretrain_choices_button, pretrain_upload_d, pretrain_upload_g])
|
218 |
-
pretrain_choices.change(fn=update_sample_rate_dropdown, inputs=[pretrain_choices], outputs=[sample_rate_pretrain])
|
219 |
-
with gr.Row():
|
220 |
-
download_pretrain_button.click(
|
221 |
-
fn=download_pretrained_model,
|
222 |
-
inputs=[
|
223 |
-
pretrain_download_choices,
|
224 |
-
pretrainD,
|
225 |
-
pretrainG
|
226 |
-
],
|
227 |
-
outputs=[pretrainD],
|
228 |
-
api_name="download_pretrain_link"
|
229 |
-
)
|
230 |
-
download_pretrain_choices_button.click(
|
231 |
-
fn=download_pretrained_model,
|
232 |
-
inputs=[
|
233 |
-
pretrain_download_choices,
|
234 |
-
pretrain_choices,
|
235 |
-
sample_rate_pretrain
|
236 |
-
],
|
237 |
-
outputs=[pretrain_choices],
|
238 |
-
api_name="download_pretrain_choices"
|
239 |
-
)
|
240 |
-
pretrain_upload_g.upload(
|
241 |
-
fn=lambda pretrain_upload_g: shutil.move(pretrain_upload_g.name, os.path.join("assets", "models", "pretrained_custom")),
|
242 |
-
inputs=[pretrain_upload_g],
|
243 |
-
outputs=[],
|
244 |
-
api_name="upload_pretrain_g"
|
245 |
-
)
|
246 |
-
pretrain_upload_d.upload(
|
247 |
-
fn=lambda pretrain_upload_d: shutil.move(pretrain_upload_d.name, os.path.join("assets", "models", "pretrained_custom")),
|
248 |
-
inputs=[pretrain_upload_d],
|
249 |
-
outputs=[],
|
250 |
-
api_name="upload_pretrain_d"
|
251 |
-
)
|
252 |
-
|
253 |
-
|
254 |
-
with gr.TabItem(translations["training_model"], visible=configs.get("training_tab", True)):
|
255 |
-
gr.Markdown(f"## {translations['training_model']}")
|
256 |
-
with gr.Row():
|
257 |
-
gr.Markdown(translations["training_markdown"])
|
258 |
-
with gr.Row():
|
259 |
-
with gr.Column():
|
260 |
-
with gr.Row():
|
261 |
-
with gr.Column():
|
262 |
-
training_name = gr.Textbox(label=translations["modelname"], info=translations["training_model_name"], value="", placeholder=translations["modelname"], interactive=True)
|
263 |
-
training_sr = gr.Radio(label=translations["sample_rate"], info=translations["sample_rate_info"], choices=["32k", "40k", "48k"], value="48k", interactive=True)
|
264 |
-
training_ver = gr.Radio(label=translations["training_version"], info=translations["training_version_info"], choices=["v1", "v2"], value="v2", interactive=True)
|
265 |
-
with gr.Row():
|
266 |
-
clean_dataset = gr.Checkbox(label=translations["clear_dataset"], value=False, interactive=True)
|
267 |
-
preprocess_cut = gr.Checkbox(label=translations["split_audio"], value=True, interactive=True)
|
268 |
-
process_effects = gr.Checkbox(label=translations["preprocess_effect"], value=False, interactive=True)
|
269 |
-
checkpointing1 = gr.Checkbox(label=translations["memory_efficient_training"], value=False, interactive=True)
|
270 |
-
training_f0 = gr.Checkbox(label=translations["training_pitch"], value=True, interactive=True)
|
271 |
-
upload = gr.Checkbox(label=translations["upload_dataset"], value=False, interactive=True)
|
272 |
-
with gr.Row():
|
273 |
-
clean_dataset_strength = gr.Slider(label=translations["clean_strength"], info=translations["clean_strength_info"], minimum=0, maximum=1, value=0.7, step=0.1, interactive=True, visible=clean_dataset.value)
|
274 |
-
with gr.Column():
|
275 |
-
preprocess_button = gr.Button(translations["preprocess_button"], scale=2)
|
276 |
-
upload_dataset = gr.Files(label=translations["drop_audio"], file_types=[".wav", ".mp3", ".flac", ".ogg", ".opus", ".m4a", ".mp4", ".aac", ".alac", ".wma", ".aiff", ".webm", ".ac3"], visible=upload.value)
|
277 |
-
preprocess_info = gr.Textbox(label=translations["preprocess_info"], value="", interactive=False)
|
278 |
-
with gr.Column():
|
279 |
-
with gr.Row():
|
280 |
-
with gr.Column():
|
281 |
-
with gr.Accordion(label=translations["f0_method"], open=False):
|
282 |
-
with gr.Group():
|
283 |
-
with gr.Row():
|
284 |
-
onnx_f0_mode2 = gr.Checkbox(label=translations["f0_onnx_mode"], info=translations["f0_onnx_mode_info"], value=False, interactive=True)
|
285 |
-
unlock_full_method4 = gr.Checkbox(label=translations["f0_unlock"], info=translations["f0_unlock_info"], value=False, interactive=True)
|
286 |
-
extract_method = gr.Radio(label=translations["f0_method"], info=translations["f0_method_info"], choices=method_f0, value="rmvpe", interactive=True)
|
287 |
-
extract_hop_length = gr.Slider(label="Hop length", info=translations["hop_length_info"], minimum=1, maximum=512, value=128, step=1, interactive=True, visible=False)
|
288 |
-
with gr.Accordion(label=translations["hubert_model"], open=False):
|
289 |
-
with gr.Group():
|
290 |
-
embed_mode2 = gr.Radio(label=translations["embed_mode"], info=translations["embed_mode_info"], value="fairseq", choices=embedders_mode, interactive=True, visible=True)
|
291 |
-
extract_embedders = gr.Radio(label=translations["hubert_model"], info=translations["hubert_info"], choices=embedders_model, value="hubert_base", interactive=True)
|
292 |
-
with gr.Row():
|
293 |
-
extract_embedders_custom = gr.Textbox(label=translations["modelname"], info=translations["modelname_info"], value="", placeholder="hubert_base", interactive=True, visible=extract_embedders.value == "custom")
|
294 |
-
with gr.Column():
|
295 |
-
extract_button = gr.Button(translations["extract_button"], scale=2)
|
296 |
-
extract_info = gr.Textbox(label=translations["extract_info"], value="", interactive=False)
|
297 |
-
with gr.Column():
|
298 |
-
with gr.Row():
|
299 |
-
with gr.Column():
|
300 |
-
total_epochs = gr.Slider(label=translations["total_epoch"], info=translations["total_epoch_info"], minimum=1, maximum=10000, value=300, step=1, interactive=True)
|
301 |
-
save_epochs = gr.Slider(label=translations["save_epoch"], info=translations["save_epoch_info"], minimum=1, maximum=10000, value=50, step=1, interactive=True)
|
302 |
-
with gr.Column():
|
303 |
-
with gr.Row():
|
304 |
-
index_button = gr.Button(f"3. {translations['create_index']}", variant="primary", scale=2)
|
305 |
-
training_button = gr.Button(f"4. {translations['training_model']}", variant="primary", scale=2)
|
306 |
-
with gr.Row():
|
307 |
-
with gr.Accordion(label=translations["setting"], open=False):
|
308 |
-
with gr.Row():
|
309 |
-
index_algorithm = gr.Radio(label=translations["index_algorithm"], info=translations["index_algorithm_info"], choices=["Auto", "Faiss", "KMeans"], value="Auto", interactive=True)
|
310 |
-
with gr.Row():
|
311 |
-
custom_dataset = gr.Checkbox(label=translations["custom_dataset"], info=translations["custom_dataset_info"], value=False, interactive=True)
|
312 |
-
overtraining_detector = gr.Checkbox(label=translations["overtraining_detector"], info=translations["overtraining_detector_info"], value=False, interactive=True)
|
313 |
-
clean_up = gr.Checkbox(label=translations["cleanup_training"], info=translations["cleanup_training_info"], value=False, interactive=True)
|
314 |
-
cache_in_gpu = gr.Checkbox(label=translations["cache_in_gpu"], info=translations["cache_in_gpu_info"], value=False, interactive=True)
|
315 |
-
with gr.Column():
|
316 |
-
dataset_path = gr.Textbox(label=translations["dataset_folder"], value="dataset", interactive=True, visible=custom_dataset.value)
|
317 |
-
with gr.Column():
|
318 |
-
threshold = gr.Slider(minimum=1, maximum=100, value=50, step=1, label=translations["threshold"], interactive=True, visible=overtraining_detector.value)
|
319 |
-
with gr.Accordion(translations["setting_cpu_gpu"], open=False):
|
320 |
-
with gr.Column():
|
321 |
-
gpu_number = gr.Textbox(label=translations["gpu_number"], value=str("-".join(map(str, range(torch.cuda.device_count()))) if torch.cuda.is_available() else "-"), info=translations["gpu_number_info"], interactive=True)
|
322 |
-
gpu_info = gr.Textbox(label=translations["gpu_info"], value=get_gpu_info(), info=translations["gpu_info_2"], interactive=False)
|
323 |
-
cpu_core = gr.Slider(label=translations["cpu_core"], info=translations["cpu_core_info"], minimum=0, maximum=cpu_count(), value=cpu_count(), step=1, interactive=True)
|
324 |
-
train_batch_size = gr.Slider(label=translations["batch_size"], info=translations["batch_size_info"], minimum=1, maximum=64, value=8, step=1, interactive=True)
|
325 |
-
with gr.Row():
|
326 |
-
save_only_latest = gr.Checkbox(label=translations["save_only_latest"], info=translations["save_only_latest_info"], value=True, interactive=True)
|
327 |
-
save_every_weights = gr.Checkbox(label=translations["save_every_weights"], info=translations["save_every_weights_info"], value=True, interactive=True)
|
328 |
-
not_use_pretrain = gr.Checkbox(label=translations["not_use_pretrain_2"], info=translations["not_use_pretrain_info"], value=False, interactive=True)
|
329 |
-
custom_pretrain = gr.Checkbox(label=translations["custom_pretrain"], info=translations["custom_pretrain_info"], value=False, interactive=True)
|
330 |
-
with gr.Row():
|
331 |
-
vocoders = gr.Radio(label=translations["vocoder"], info=translations["vocoder_info"], choices=["Default", "MRF-HiFi-GAN", "RefineGAN"], value="Default", interactive=True)
|
332 |
-
with gr.Row():
|
333 |
-
deterministic = gr.Checkbox(label=translations["deterministic"], info=translations["deterministic_info"], value=False, interactive=True)
|
334 |
-
benchmark = gr.Checkbox(label=translations["benchmark"], info=translations["benchmark_info"], value=False, interactive=True)
|
335 |
-
with gr.Row():
|
336 |
-
model_author = gr.Textbox(label=translations["training_author"], info=translations["training_author_info"], value="", placeholder=translations["training_author"], interactive=True)
|
337 |
-
with gr.Row():
|
338 |
-
with gr.Column():
|
339 |
-
with gr.Accordion(translations["custom_pretrain_info"], open=False, visible=custom_pretrain.value and not not_use_pretrain.value) as pretrain_setting:
|
340 |
-
pretrained_D = gr.Dropdown(label=translations["pretrain_file"].format(dg="D"), choices=pretrainedD, value=pretrainedD[0] if len(pretrainedD) > 0 else '', interactive=True, allow_custom_value=True)
|
341 |
-
pretrained_G = gr.Dropdown(label=translations["pretrain_file"].format(dg="G"), choices=pretrainedG, value=pretrainedG[0] if len(pretrainedG) > 0 else '', interactive=True, allow_custom_value=True)
|
342 |
-
refesh_pretrain = gr.Button(translations["refesh"], scale=2)
|
343 |
-
with gr.Row():
|
344 |
-
training_info = gr.Textbox(label=translations["train_info"], value="", interactive=False)
|
345 |
-
with gr.Row():
|
346 |
-
with gr.Column():
|
347 |
-
with gr.Accordion(translations["export_model"], open=False):
|
348 |
-
with gr.Row():
|
349 |
-
model_file= gr.Dropdown(label=translations["model_name"], choices=model_name, value=model_name[0] if len(model_name) >= 1 else "", interactive=True, allow_custom_value=True)
|
350 |
-
index_file = gr.Dropdown(label=translations["index_path"], choices=index_path, value=index_path[0] if len(index_path) >= 1 else "", interactive=True, allow_custom_value=True)
|
351 |
-
with gr.Row():
|
352 |
-
refesh_file = gr.Button(f"1. {translations['refesh']}", scale=2)
|
353 |
-
zip_model = gr.Button(translations["zip_model"], variant="primary", scale=2)
|
354 |
-
with gr.Row():
|
355 |
-
zip_output = gr.File(label=translations["output_zip"], file_types=[".zip"], interactive=False, visible=False)
|
356 |
-
with gr.Row():
|
357 |
-
vocoders.change(fn=pitch_guidance_lock, inputs=[vocoders], outputs=[training_f0])
|
358 |
-
training_f0.change(fn=vocoders_lock, inputs=[training_f0, vocoders], outputs=[vocoders])
|
359 |
-
unlock_full_method4.change(fn=unlock_f0, inputs=[unlock_full_method4], outputs=[extract_method])
|
360 |
-
with gr.Row():
|
361 |
-
refesh_file.click(fn=change_models_choices, inputs=[], outputs=[model_file, index_file])
|
362 |
-
zip_model.click(fn=zip_file, inputs=[training_name, model_file, index_file], outputs=[zip_output])
|
363 |
-
dataset_path.change(fn=lambda folder: os.makedirs(folder, exist_ok=True), inputs=[dataset_path], outputs=[])
|
364 |
-
with gr.Row():
|
365 |
-
upload.change(fn=visible, inputs=[upload], outputs=[upload_dataset])
|
366 |
-
overtraining_detector.change(fn=visible, inputs=[overtraining_detector], outputs=[threshold])
|
367 |
-
clean_dataset.change(fn=visible, inputs=[clean_dataset], outputs=[clean_dataset_strength])
|
368 |
-
with gr.Row():
|
369 |
-
custom_dataset.change(fn=lambda custom_dataset: [visible(custom_dataset), "dataset"],inputs=[custom_dataset], outputs=[dataset_path, dataset_path])
|
370 |
-
training_ver.change(fn=unlock_vocoder, inputs=[training_ver, vocoders], outputs=[vocoders])
|
371 |
-
vocoders.change(fn=unlock_ver, inputs=[training_ver, vocoders], outputs=[training_ver])
|
372 |
-
upload_dataset.upload(
|
373 |
-
fn=lambda files, folder: [shutil.move(f.name, os.path.join(folder, os.path.split(f.name)[1])) for f in files] if folder != "" else gr_warning(translations["dataset_folder1"]),
|
374 |
-
inputs=[upload_dataset, dataset_path],
|
375 |
-
outputs=[],
|
376 |
-
api_name="upload_dataset"
|
377 |
-
)
|
378 |
-
with gr.Row():
|
379 |
-
not_use_pretrain.change(fn=lambda a, b: visible(a and not b), inputs=[custom_pretrain, not_use_pretrain], outputs=[pretrain_setting])
|
380 |
-
custom_pretrain.change(fn=lambda a, b: visible(a and not b), inputs=[custom_pretrain, not_use_pretrain], outputs=[pretrain_setting])
|
381 |
-
refesh_pretrain.click(fn=change_pretrained_choices, inputs=[], outputs=[pretrained_D, pretrained_G])
|
382 |
-
with gr.Row():
|
383 |
-
preprocess_button.click(
|
384 |
-
fn=preprocess,
|
385 |
-
inputs=[
|
386 |
-
training_name,
|
387 |
-
training_sr,
|
388 |
-
cpu_core,
|
389 |
-
preprocess_cut,
|
390 |
-
process_effects,
|
391 |
-
dataset_path,
|
392 |
-
clean_dataset,
|
393 |
-
clean_dataset_strength
|
394 |
-
],
|
395 |
-
outputs=[preprocess_info],
|
396 |
-
api_name="preprocess"
|
397 |
-
)
|
398 |
-
with gr.Row():
|
399 |
-
embed_mode2.change(fn=visible_embedders, inputs=[embed_mode2], outputs=[extract_embedders])
|
400 |
-
extract_method.change(fn=hoplength_show, inputs=[extract_method], outputs=[extract_hop_length])
|
401 |
-
extract_embedders.change(fn=lambda extract_embedders: visible(extract_embedders == "custom"), inputs=[extract_embedders], outputs=[extract_embedders_custom])
|
402 |
-
with gr.Row():
|
403 |
-
extract_button.click(
|
404 |
-
fn=extract,
|
405 |
-
inputs=[
|
406 |
-
training_name,
|
407 |
-
training_ver,
|
408 |
-
extract_method,
|
409 |
-
training_f0,
|
410 |
-
extract_hop_length,
|
411 |
-
cpu_core,
|
412 |
-
gpu_number,
|
413 |
-
training_sr,
|
414 |
-
extract_embedders,
|
415 |
-
extract_embedders_custom,
|
416 |
-
onnx_f0_mode2,
|
417 |
-
embed_mode2
|
418 |
-
],
|
419 |
-
outputs=[extract_info],
|
420 |
-
api_name="extract"
|
421 |
-
)
|
422 |
-
with gr.Row():
|
423 |
-
index_button.click(
|
424 |
-
fn=create_index,
|
425 |
-
inputs=[
|
426 |
-
training_name,
|
427 |
-
training_ver,
|
428 |
-
index_algorithm
|
429 |
-
],
|
430 |
-
outputs=[training_info],
|
431 |
-
api_name="create_index"
|
432 |
-
)
|
433 |
-
with gr.Row():
|
434 |
-
training_button.click(
|
435 |
-
fn=training,
|
436 |
-
inputs=[
|
437 |
-
training_name,
|
438 |
-
training_ver,
|
439 |
-
save_epochs,
|
440 |
-
save_only_latest,
|
441 |
-
save_every_weights,
|
442 |
-
total_epochs,
|
443 |
-
training_sr,
|
444 |
-
train_batch_size,
|
445 |
-
gpu_number,
|
446 |
-
training_f0,
|
447 |
-
not_use_pretrain,
|
448 |
-
custom_pretrain,
|
449 |
-
pretrained_G,
|
450 |
-
pretrained_D,
|
451 |
-
overtraining_detector,
|
452 |
-
threshold,
|
453 |
-
clean_up,
|
454 |
-
cache_in_gpu,
|
455 |
-
model_author,
|
456 |
-
vocoders,
|
457 |
-
checkpointing1,
|
458 |
-
deterministic,
|
459 |
-
benchmark
|
460 |
-
],
|
461 |
-
outputs=[training_info],
|
462 |
-
api_name="training_model"
|
463 |
-
)
|
464 |
-
|
465 |
|
466 |
|
467 |
-
with gr.TabItem(translations["audio_editing"], visible=configs.get("audioldm2", True)):
|
468 |
-
gr.Markdown(translations["audio_editing_info"])
|
469 |
-
with gr.Row():
|
470 |
-
gr.Markdown(translations["audio_editing_markdown"])
|
471 |
-
with gr.Row():
|
472 |
-
with gr.Column():
|
473 |
-
with gr.Group():
|
474 |
-
with gr.Row():
|
475 |
-
save_compute = gr.Checkbox(label=translations["save_compute"], value=True, interactive=True)
|
476 |
-
tar_prompt = gr.Textbox(label=translations["target_prompt"], info=translations["target_prompt_info"], placeholder="Piano and violin cover", lines=5, interactive=True)
|
477 |
-
with gr.Column():
|
478 |
-
cfg_scale_src = gr.Slider(value=3, minimum=0.5, maximum=25, label=translations["cfg_scale_src"], info=translations["cfg_scale_src_info"], interactive=True)
|
479 |
-
cfg_scale_tar = gr.Slider(value=12, minimum=0.5, maximum=25, label=translations["cfg_scale_tar"], info=translations["cfg_scale_tar_info"], interactive=True)
|
480 |
-
with gr.Row():
|
481 |
-
edit_button = gr.Button(translations["editing"], variant="primary")
|
482 |
-
with gr.Row():
|
483 |
-
with gr.Column():
|
484 |
-
drop_audio_file = gr.File(label=translations["drop_audio"], file_types=[".wav", ".mp3", ".flac", ".ogg", ".opus", ".m4a", ".mp4", ".aac", ".alac", ".wma", ".aiff", ".webm", ".ac3"])
|
485 |
-
display_audio = gr.Audio(show_download_button=True, interactive=False, label=translations["input_audio"])
|
486 |
-
with gr.Column():
|
487 |
-
with gr.Accordion(translations["input_output"], open=False):
|
488 |
-
with gr.Column():
|
489 |
-
export_audio_format = gr.Radio(label=translations["export_format"], info=translations["export_info"], choices=["wav", "mp3", "flac", "ogg", "opus", "m4a", "mp4", "aac", "alac", "wma", "aiff", "webm", "ac3"], value="wav", interactive=True)
|
490 |
-
input_audiopath = gr.Dropdown(label=translations["audio_path"], value="", choices=paths_for_files, info=translations["provide_audio"], allow_custom_value=True, interactive=True)
|
491 |
-
output_audiopath = gr.Textbox(label=translations["output_path"], value="audios/output.wav", placeholder="audios/output.wav", info=translations["output_path_info"], interactive=True)
|
492 |
-
with gr.Column():
|
493 |
-
refesh_audio = gr.Button(translations["refesh"])
|
494 |
-
with gr.Accordion(translations["setting"], open=False):
|
495 |
-
audioldm2_model = gr.Radio(label=translations["audioldm2_model"], info=translations["audioldm2_model_info"], choices=["audioldm2", "audioldm2-large", "audioldm2-music"], value="audioldm2-music", interactive=True)
|
496 |
-
with gr.Row():
|
497 |
-
src_prompt = gr.Textbox(label=translations["source_prompt"], lines=2, interactive=True, info=translations["source_prompt_info"], placeholder="A recording of a happy upbeat classical music piece")
|
498 |
-
with gr.Row():
|
499 |
-
with gr.Column():
|
500 |
-
audioldm2_sample_rate = gr.Slider(minimum=8000, maximum=96000, label=translations["sr"], info=translations["sr_info"], value=44100, step=1, interactive=True)
|
501 |
-
t_start = gr.Slider(minimum=15, maximum=85, value=45, step=1, label=translations["t_start"], interactive=True, info=translations["t_start_info"])
|
502 |
-
steps = gr.Slider(value=50, step=1, minimum=10, maximum=300, label=translations["steps_label"], info=translations["steps_info"], interactive=True)
|
503 |
-
with gr.Row():
|
504 |
-
gr.Markdown(translations["output_audio"])
|
505 |
-
with gr.Row():
|
506 |
-
output_audioldm2 = gr.Audio(show_download_button=True, interactive=False, label=translations["output_audio"])
|
507 |
-
with gr.Row():
|
508 |
-
refesh_audio.click(fn=change_audios_choices, inputs=[input_audiopath], outputs=[input_audiopath])
|
509 |
-
drop_audio_file.upload(fn=lambda audio_in: shutil.move(audio_in.name, os.path.join("audios")), inputs=[drop_audio_file], outputs=[input_audiopath])
|
510 |
-
input_audiopath.change(fn=lambda audio: audio if os.path.isfile(audio) else None, inputs=[input_audiopath], outputs=[display_audio])
|
511 |
-
with gr.Row():
|
512 |
-
edit_button.click(
|
513 |
-
fn=run_audioldm2,
|
514 |
-
inputs=[
|
515 |
-
input_audiopath,
|
516 |
-
output_audiopath,
|
517 |
-
export_audio_format,
|
518 |
-
audioldm2_sample_rate,
|
519 |
-
audioldm2_model,
|
520 |
-
src_prompt,
|
521 |
-
tar_prompt,
|
522 |
-
steps,
|
523 |
-
cfg_scale_src,
|
524 |
-
cfg_scale_tar,
|
525 |
-
t_start,
|
526 |
-
save_compute
|
527 |
-
],
|
528 |
-
outputs=[output_audioldm2],
|
529 |
-
api_name="audioldm2"
|
530 |
-
)
|
531 |
-
|
532 |
-
with gr.TabItem(translations["audio_effects"], visible=configs.get("effects_tab", True)):
|
533 |
-
gr.Markdown(translations["apply_audio_effects"])
|
534 |
-
with gr.Row():
|
535 |
-
gr.Markdown(translations["audio_effects_edit"])
|
536 |
-
with gr.Row():
|
537 |
-
with gr.Column():
|
538 |
-
with gr.Row():
|
539 |
-
reverb_check_box = gr.Checkbox(label=translations["reverb"], value=False, interactive=True)
|
540 |
-
chorus_check_box = gr.Checkbox(label=translations["chorus"], value=False, interactive=True)
|
541 |
-
delay_check_box = gr.Checkbox(label=translations["delay"], value=False, interactive=True)
|
542 |
-
phaser_check_box = gr.Checkbox(label=translations["phaser"], value=False, interactive=True)
|
543 |
-
compressor_check_box = gr.Checkbox(label=translations["compressor"], value=False, interactive=True)
|
544 |
-
more_options = gr.Checkbox(label=translations["more_option"], value=False, interactive=True)
|
545 |
-
with gr.Row():
|
546 |
-
with gr.Accordion(translations["input_output"], open=False):
|
547 |
-
with gr.Row():
|
548 |
-
upload_audio = gr.File(label=translations["drop_audio"], file_types=[".wav", ".mp3", ".flac", ".ogg", ".opus", ".m4a", ".mp4", ".aac", ".alac", ".wma", ".aiff", ".webm", ".ac3"])
|
549 |
-
with gr.Row():
|
550 |
-
audio_in_path = gr.Dropdown(label=translations["input_audio"], value="", choices=paths_for_files, info=translations["provide_audio"], interactive=True, allow_custom_value=True)
|
551 |
-
audio_out_path = gr.Textbox(label=translations["output_audio"], value="audios/audio_effects.wav", placeholder="audios/audio_effects.wav", info=translations["provide_output"], interactive=True)
|
552 |
-
with gr.Row():
|
553 |
-
with gr.Column():
|
554 |
-
audio_combination = gr.Checkbox(label=translations["merge_instruments"], value=False, interactive=True)
|
555 |
-
audio_combination_input = gr.Dropdown(label=translations["input_audio"], value="", choices=paths_for_files, info=translations["provide_audio"], interactive=True, allow_custom_value=True, visible=audio_combination.value)
|
556 |
-
with gr.Row():
|
557 |
-
audio_effects_refesh = gr.Button(translations["refesh"])
|
558 |
-
with gr.Row():
|
559 |
-
audio_output_format = gr.Radio(label=translations["export_format"], info=translations["export_info"], choices=["wav", "mp3", "flac", "ogg", "opus", "m4a", "mp4", "aac", "alac", "wma", "aiff", "webm", "ac3"], value="wav", interactive=True)
|
560 |
-
with gr.Row():
|
561 |
-
apply_effects_button = gr.Button(translations["apply"], variant="primary", scale=2)
|
562 |
-
with gr.Row():
|
563 |
-
with gr.Column():
|
564 |
-
with gr.Row():
|
565 |
-
with gr.Accordion(translations["reverb"], open=False, visible=reverb_check_box.value) as reverb_accordion:
|
566 |
-
reverb_freeze_mode = gr.Checkbox(label=translations["reverb_freeze"], info=translations["reverb_freeze_info"], value=False, interactive=True)
|
567 |
-
reverb_room_size = gr.Slider(minimum=0, maximum=1, step=0.01, value=0.15, label=translations["room_size"], info=translations["room_size_info"], interactive=True)
|
568 |
-
reverb_damping = gr.Slider(minimum=0, maximum=1, step=0.01, value=0.7, label=translations["damping"], info=translations["damping_info"], interactive=True)
|
569 |
-
reverb_wet_level = gr.Slider(minimum=0, maximum=1, step=0.01, value=0.2, label=translations["wet_level"], info=translations["wet_level_info"], interactive=True)
|
570 |
-
reverb_dry_level = gr.Slider(minimum=0, maximum=1, step=0.01, value=0.8, label=translations["dry_level"], info=translations["dry_level_info"], interactive=True)
|
571 |
-
reverb_width = gr.Slider(minimum=0, maximum=1, step=0.01, value=1, label=translations["width"], info=translations["width_info"], interactive=True)
|
572 |
-
with gr.Row():
|
573 |
-
with gr.Accordion(translations["chorus"], open=False, visible=chorus_check_box.value) as chorus_accordion:
|
574 |
-
chorus_depth = gr.Slider(minimum=0, maximum=1, step=0.01, value=0.5, label=translations["chorus_depth"], info=translations["chorus_depth_info"], interactive=True)
|
575 |
-
chorus_rate_hz = gr.Slider(minimum=0.1, maximum=10, step=0.1, value=1.5, label=translations["chorus_rate_hz"], info=translations["chorus_rate_hz_info"], interactive=True)
|
576 |
-
chorus_mix = gr.Slider(minimum=0, maximum=1, step=0.01, value=0.5, label=translations["chorus_mix"], info=translations["chorus_mix_info"], interactive=True)
|
577 |
-
chorus_centre_delay_ms = gr.Slider(minimum=0, maximum=50, step=1, value=10, label=translations["chorus_centre_delay_ms"], info=translations["chorus_centre_delay_ms_info"], interactive=True)
|
578 |
-
chorus_feedback = gr.Slider(minimum=-1, maximum=1, step=0.01, value=0, label=translations["chorus_feedback"], info=translations["chorus_feedback_info"], interactive=True)
|
579 |
-
with gr.Row():
|
580 |
-
with gr.Accordion(translations["delay"], open=False, visible=delay_check_box.value) as delay_accordion:
|
581 |
-
delay_second = gr.Slider(minimum=0, maximum=5, step=0.01, value=0.5, label=translations["delay_seconds"], info=translations["delay_seconds_info"], interactive=True)
|
582 |
-
delay_feedback = gr.Slider(minimum=0, maximum=1, step=0.01, value=0.5, label=translations["delay_feedback"], info=translations["delay_feedback_info"], interactive=True)
|
583 |
-
delay_mix = gr.Slider(minimum=0, maximum=1, step=0.01, value=0.5, label=translations["delay_mix"], info=translations["delay_mix_info"], interactive=True)
|
584 |
-
with gr.Column():
|
585 |
-
with gr.Row():
|
586 |
-
with gr.Accordion(translations["more_option"], open=False, visible=more_options.value) as more_accordion:
|
587 |
-
with gr.Row():
|
588 |
-
fade = gr.Checkbox(label=translations["fade"], value=False, interactive=True)
|
589 |
-
bass_or_treble = gr.Checkbox(label=translations["bass_or_treble"], value=False, interactive=True)
|
590 |
-
limiter = gr.Checkbox(label=translations["limiter"], value=False, interactive=True)
|
591 |
-
resample_checkbox = gr.Checkbox(label=translations["resample"], value=False, interactive=True)
|
592 |
-
with gr.Row():
|
593 |
-
distortion_checkbox = gr.Checkbox(label=translations["distortion"], value=False, interactive=True)
|
594 |
-
gain_checkbox = gr.Checkbox(label=translations["gain"], value=False, interactive=True)
|
595 |
-
bitcrush_checkbox = gr.Checkbox(label=translations["bitcrush"], value=False, interactive=True)
|
596 |
-
clipping_checkbox = gr.Checkbox(label=translations["clipping"], value=False, interactive=True)
|
597 |
-
with gr.Accordion(translations["fade"], open=True, visible=fade.value) as fade_accordion:
|
598 |
-
with gr.Row():
|
599 |
-
fade_in = gr.Slider(minimum=0, maximum=10000, step=100, value=0, label=translations["fade_in"], info=translations["fade_in_info"], interactive=True)
|
600 |
-
fade_out = gr.Slider(minimum=0, maximum=10000, step=100, value=0, label=translations["fade_out"], info=translations["fade_out_info"], interactive=True)
|
601 |
-
with gr.Accordion(translations["bass_or_treble"], open=True, visible=bass_or_treble.value) as bass_treble_accordion:
|
602 |
-
with gr.Row():
|
603 |
-
bass_boost = gr.Slider(minimum=0, maximum=20, step=1, value=0, label=translations["bass_boost"], info=translations["bass_boost_info"], interactive=True)
|
604 |
-
bass_frequency = gr.Slider(minimum=20, maximum=200, step=10, value=100, label=translations["bass_frequency"], info=translations["bass_frequency_info"], interactive=True)
|
605 |
-
with gr.Row():
|
606 |
-
treble_boost = gr.Slider(minimum=0, maximum=20, step=1, value=0, label=translations["treble_boost"], info=translations["treble_boost_info"], interactive=True)
|
607 |
-
treble_frequency = gr.Slider(minimum=1000, maximum=10000, step=500, value=3000, label=translations["treble_frequency"], info=translations["treble_frequency_info"], interactive=True)
|
608 |
-
with gr.Accordion(translations["limiter"], open=True, visible=limiter.value) as limiter_accordion:
|
609 |
-
with gr.Row():
|
610 |
-
limiter_threashold_db = gr.Slider(minimum=-60, maximum=0, step=1, value=-1, label=translations["limiter_threashold_db"], info=translations["limiter_threashold_db_info"], interactive=True)
|
611 |
-
limiter_release_ms = gr.Slider(minimum=10, maximum=1000, step=1, value=100, label=translations["limiter_release_ms"], info=translations["limiter_release_ms_info"], interactive=True)
|
612 |
-
with gr.Column():
|
613 |
-
pitch_shift_semitones = gr.Slider(minimum=-20, maximum=20, step=1, value=0, label=translations["pitch"], info=translations["pitch_info"], interactive=True)
|
614 |
-
audio_effect_resample_sr = gr.Slider(minimum=0, maximum=96000, step=1, value=0, label=translations["resample"], info=translations["resample_info"], interactive=True, visible=resample_checkbox.value)
|
615 |
-
distortion_drive_db = gr.Slider(minimum=0, maximum=50, step=1, value=20, label=translations["distortion"], info=translations["distortion_info"], interactive=True, visible=distortion_checkbox.value)
|
616 |
-
gain_db = gr.Slider(minimum=-60, maximum=60, step=1, value=0, label=translations["gain"], info=translations["gain_info"], interactive=True, visible=gain_checkbox.value)
|
617 |
-
clipping_threashold_db = gr.Slider(minimum=-60, maximum=0, step=1, value=-1, label=translations["clipping_threashold_db"], info=translations["clipping_threashold_db_info"], interactive=True, visible=clipping_checkbox.value)
|
618 |
-
bitcrush_bit_depth = gr.Slider(minimum=1, maximum=24, step=1, value=16, label=translations["bitcrush_bit_depth"], info=translations["bitcrush_bit_depth_info"], interactive=True, visible=bitcrush_checkbox.value)
|
619 |
-
with gr.Row():
|
620 |
-
with gr.Accordion(translations["phaser"], open=False, visible=phaser_check_box.value) as phaser_accordion:
|
621 |
-
phaser_depth = gr.Slider(minimum=0, maximum=1, step=0.01, value=0.5, label=translations["phaser_depth"], info=translations["phaser_depth_info"], interactive=True)
|
622 |
-
phaser_rate_hz = gr.Slider(minimum=0.1, maximum=10, step=0.1, value=1, label=translations["phaser_rate_hz"], info=translations["phaser_rate_hz_info"], interactive=True)
|
623 |
-
phaser_mix = gr.Slider(minimum=0, maximum=1, step=0.01, value=0.5, label=translations["phaser_mix"], info=translations["phaser_mix_info"], interactive=True)
|
624 |
-
phaser_centre_frequency_hz = gr.Slider(minimum=50, maximum=5000, step=10, value=1000, label=translations["phaser_centre_frequency_hz"], info=translations["phaser_centre_frequency_hz_info"], interactive=True)
|
625 |
-
phaser_feedback = gr.Slider(minimum=-1, maximum=1, step=0.01, value=0, label=translations["phaser_feedback"], info=translations["phaser_feedback_info"], interactive=True)
|
626 |
-
with gr.Row():
|
627 |
-
with gr.Accordion(translations["compressor"], open=False, visible=compressor_check_box.value) as compressor_accordion:
|
628 |
-
compressor_threashold_db = gr.Slider(minimum=-60, maximum=0, step=1, value=-20, label=translations["compressor_threashold_db"], info=translations["compressor_threashold_db_info"], interactive=True)
|
629 |
-
compressor_ratio = gr.Slider(minimum=1, maximum=20, step=0.1, value=1, label=translations["compressor_ratio"], info=translations["compressor_ratio_info"], interactive=True)
|
630 |
-
compressor_attack_ms = gr.Slider(minimum=0.1, maximum=100, step=0.1, value=10, label=translations["compressor_attack_ms"], info=translations["compressor_attack_ms_info"], interactive=True)
|
631 |
-
compressor_release_ms = gr.Slider(minimum=10, maximum=1000, step=1, value=100, label=translations["compressor_release_ms"], info=translations["compressor_release_ms_info"], interactive=True)
|
632 |
-
with gr.Row():
|
633 |
-
gr.Markdown(translations["output_audio"])
|
634 |
-
with gr.Row():
|
635 |
-
audio_play_input = gr.Audio(show_download_button=True, interactive=False, label=translations["input_audio"])
|
636 |
-
audio_play_output = gr.Audio(show_download_button=True, interactive=False, label=translations["output_audio"])
|
637 |
-
with gr.Row():
|
638 |
-
reverb_check_box.change(fn=visible, inputs=[reverb_check_box], outputs=[reverb_accordion])
|
639 |
-
chorus_check_box.change(fn=visible, inputs=[chorus_check_box], outputs=[chorus_accordion])
|
640 |
-
delay_check_box.change(fn=visible, inputs=[delay_check_box], outputs=[delay_accordion])
|
641 |
-
with gr.Row():
|
642 |
-
compressor_check_box.change(fn=visible, inputs=[compressor_check_box], outputs=[compressor_accordion])
|
643 |
-
phaser_check_box.change(fn=visible, inputs=[phaser_check_box], outputs=[phaser_accordion])
|
644 |
-
more_options.change(fn=visible, inputs=[more_options], outputs=[more_accordion])
|
645 |
-
with gr.Row():
|
646 |
-
fade.change(fn=visible, inputs=[fade], outputs=[fade_accordion])
|
647 |
-
bass_or_treble.change(fn=visible, inputs=[bass_or_treble], outputs=[bass_treble_accordion])
|
648 |
-
limiter.change(fn=visible, inputs=[limiter], outputs=[limiter_accordion])
|
649 |
-
resample_checkbox.change(fn=visible, inputs=[resample_checkbox], outputs=[audio_effect_resample_sr])
|
650 |
-
with gr.Row():
|
651 |
-
distortion_checkbox.change(fn=visible, inputs=[distortion_checkbox], outputs=[distortion_drive_db])
|
652 |
-
gain_checkbox.change(fn=visible, inputs=[gain_checkbox], outputs=[gain_db])
|
653 |
-
clipping_checkbox.change(fn=visible, inputs=[clipping_checkbox], outputs=[clipping_threashold_db])
|
654 |
-
bitcrush_checkbox.change(fn=visible, inputs=[bitcrush_checkbox], outputs=[bitcrush_bit_depth])
|
655 |
-
with gr.Row():
|
656 |
-
upload_audio.upload(fn=lambda audio_in: shutil.move(audio_in.name, os.path.join("audios")), inputs=[upload_audio], outputs=[audio_in_path])
|
657 |
-
audio_in_path.change(fn=lambda audio: audio if audio else None, inputs=[audio_in_path], outputs=[audio_play_input])
|
658 |
-
audio_effects_refesh.click(fn=lambda a, b: [change_audios_choices(a), change_audios_choices(b)], inputs=[audio_in_path, audio_combination_input], outputs=[audio_in_path, audio_combination_input])
|
659 |
-
with gr.Row():
|
660 |
-
more_options.change(fn=lambda: [False]*8, inputs=[], outputs=[fade, bass_or_treble, limiter, resample_checkbox, distortion_checkbox, gain_checkbox, clipping_checkbox, bitcrush_checkbox])
|
661 |
-
audio_combination.change(fn=visible, inputs=[audio_combination], outputs=[audio_combination_input])
|
662 |
-
with gr.Row():
|
663 |
-
apply_effects_button.click(
|
664 |
-
fn=audio_effects,
|
665 |
-
inputs=[
|
666 |
-
audio_in_path,
|
667 |
-
audio_out_path,
|
668 |
-
resample_checkbox,
|
669 |
-
audio_effect_resample_sr,
|
670 |
-
chorus_depth,
|
671 |
-
chorus_rate_hz,
|
672 |
-
chorus_mix,
|
673 |
-
chorus_centre_delay_ms,
|
674 |
-
chorus_feedback,
|
675 |
-
distortion_drive_db,
|
676 |
-
reverb_room_size,
|
677 |
-
reverb_damping,
|
678 |
-
reverb_wet_level,
|
679 |
-
reverb_dry_level,
|
680 |
-
reverb_width,
|
681 |
-
reverb_freeze_mode,
|
682 |
-
pitch_shift_semitones,
|
683 |
-
delay_second,
|
684 |
-
delay_feedback,
|
685 |
-
delay_mix,
|
686 |
-
compressor_threashold_db,
|
687 |
-
compressor_ratio,
|
688 |
-
compressor_attack_ms,
|
689 |
-
compressor_release_ms,
|
690 |
-
limiter_threashold_db,
|
691 |
-
limiter_release_ms,
|
692 |
-
gain_db,
|
693 |
-
bitcrush_bit_depth,
|
694 |
-
clipping_threashold_db,
|
695 |
-
phaser_rate_hz,
|
696 |
-
phaser_depth,
|
697 |
-
phaser_centre_frequency_hz,
|
698 |
-
phaser_feedback,
|
699 |
-
phaser_mix,
|
700 |
-
bass_boost,
|
701 |
-
bass_frequency,
|
702 |
-
treble_boost,
|
703 |
-
treble_frequency,
|
704 |
-
fade_in,
|
705 |
-
fade_out,
|
706 |
-
audio_output_format,
|
707 |
-
chorus_check_box,
|
708 |
-
distortion_checkbox,
|
709 |
-
reverb_check_box,
|
710 |
-
delay_check_box,
|
711 |
-
compressor_check_box,
|
712 |
-
limiter,
|
713 |
-
gain_checkbox,
|
714 |
-
bitcrush_checkbox,
|
715 |
-
clipping_checkbox,
|
716 |
-
phaser_check_box,
|
717 |
-
bass_or_treble,
|
718 |
-
fade,
|
719 |
-
audio_combination,
|
720 |
-
audio_combination_input
|
721 |
-
],
|
722 |
-
outputs=[audio_play_output],
|
723 |
-
api_name="audio_effects"
|
724 |
-
)
|
725 |
-
|
726 |
-
with gr.TabItem(translations["createdataset"], visible=configs.get("create_dataset_tab", True)):
|
727 |
-
gr.Markdown(translations["create_dataset_markdown"])
|
728 |
-
with gr.Row():
|
729 |
-
gr.Markdown(translations["create_dataset_markdown_2"])
|
730 |
-
with gr.Row():
|
731 |
-
dataset_url = gr.Textbox(label=translations["url_audio"], info=translations["create_dataset_url"], value="", placeholder="https://www.youtube.com/...", interactive=True)
|
732 |
-
output_dataset = gr.Textbox(label=translations["output_data"], info=translations["output_data_info"], value="dataset", placeholder="dataset", interactive=True)
|
733 |
-
with gr.Row():
|
734 |
-
with gr.Column():
|
735 |
-
with gr.Group():
|
736 |
-
with gr.Row():
|
737 |
-
separator_reverb = gr.Checkbox(label=translations["dereveb_audio"], value=False, interactive=True)
|
738 |
-
denoise_mdx = gr.Checkbox(label=translations["denoise"], value=False, interactive=True)
|
739 |
-
with gr.Row():
|
740 |
-
kim_vocal_version = gr.Radio(label=translations["model_ver"], info=translations["model_ver_info"], choices=["Version-1", "Version-2"], value="Version-2", interactive=True)
|
741 |
-
kim_vocal_overlap = gr.Radio(label=translations["overlap"], info=translations["overlap_info"], choices=["0.25", "0.5", "0.75", "0.99"], value="0.25", interactive=True)
|
742 |
-
with gr.Row():
|
743 |
-
kim_vocal_hop_length = gr.Slider(label="Hop length", info=translations["hop_length_info"], minimum=1, maximum=8192, value=1024, step=1, interactive=True)
|
744 |
-
kim_vocal_batch_size = gr.Slider(label=translations["batch_size"], info=translations["mdx_batch_size_info"], minimum=1, maximum=64, value=1, step=1, interactive=True)
|
745 |
-
with gr.Row():
|
746 |
-
kim_vocal_segments_size = gr.Slider(label=translations["segments_size"], info=translations["segments_size_info"], minimum=32, maximum=3072, value=256, step=32, interactive=True)
|
747 |
-
with gr.Row():
|
748 |
-
sample_rate0 = gr.Slider(minimum=8000, maximum=96000, step=1, value=44100, label=translations["sr"], info=translations["sr_info"], interactive=True)
|
749 |
-
with gr.Column():
|
750 |
-
create_button = gr.Button(translations["createdataset"], variant="primary", scale=2, min_width=4000)
|
751 |
-
with gr.Group():
|
752 |
-
with gr.Row():
|
753 |
-
clean_audio = gr.Checkbox(label=translations["clear_audio"], value=False, interactive=True)
|
754 |
-
skip = gr.Checkbox(label=translations["skip"], value=False, interactive=True)
|
755 |
-
with gr.Row():
|
756 |
-
dataset_clean_strength = gr.Slider(minimum=0, maximum=1, step=0.1, value=0.5, label=translations["clean_strength"], info=translations["clean_strength_info"], interactive=True, visible=clean_audio.value)
|
757 |
-
with gr.Row():
|
758 |
-
skip_start = gr.Textbox(label=translations["skip_start"], info=translations["skip_start_info"], value="", placeholder="0,...", interactive=True, visible=skip.value)
|
759 |
-
skip_end = gr.Textbox(label=translations["skip_end"], info=translations["skip_end_info"], value="", placeholder="0,...", interactive=True, visible=skip.value)
|
760 |
-
create_dataset_info = gr.Textbox(label=translations["create_dataset_info"], value="", interactive=False)
|
761 |
-
with gr.Row():
|
762 |
-
clean_audio.change(fn=visible, inputs=[clean_audio], outputs=[dataset_clean_strength])
|
763 |
-
skip.change(fn=lambda a: [valueEmpty_visible1(a)]*2, inputs=[skip], outputs=[skip_start, skip_end])
|
764 |
-
with gr.Row():
|
765 |
-
create_button.click(
|
766 |
-
fn=create_dataset,
|
767 |
-
inputs=[
|
768 |
-
dataset_url,
|
769 |
-
output_dataset,
|
770 |
-
clean_audio,
|
771 |
-
dataset_clean_strength,
|
772 |
-
separator_reverb,
|
773 |
-
kim_vocal_version,
|
774 |
-
kim_vocal_overlap,
|
775 |
-
kim_vocal_segments_size,
|
776 |
-
denoise_mdx,
|
777 |
-
skip,
|
778 |
-
skip_start,
|
779 |
-
skip_end,
|
780 |
-
kim_vocal_hop_length,
|
781 |
-
kim_vocal_batch_size,
|
782 |
-
sample_rate0
|
783 |
-
],
|
784 |
-
outputs=[create_dataset_info],
|
785 |
-
api_name="create_dataset"
|
786 |
-
)
|
787 |
-
|
788 |
-
with gr.TabItem(translations["fushion"], visible=configs.get("fushion_tab", True)):
|
789 |
-
gr.Markdown(translations["fushion_markdown"])
|
790 |
-
with gr.Row():
|
791 |
-
gr.Markdown(translations["fushion_markdown_2"])
|
792 |
-
with gr.Row():
|
793 |
-
name_to_save = gr.Textbox(label=translations["modelname"], placeholder="Model.pth", value="", max_lines=1, interactive=True)
|
794 |
-
with gr.Row():
|
795 |
-
fushion_button = gr.Button(translations["fushion"], variant="primary", scale=4)
|
796 |
-
with gr.Column():
|
797 |
-
with gr.Row():
|
798 |
-
model_a = gr.File(label=f"{translations['model_name']} 1", file_types=[".pth", ".onnx"])
|
799 |
-
model_b = gr.File(label=f"{translations['model_name']} 2", file_types=[".pth", ".onnx"])
|
800 |
-
with gr.Row():
|
801 |
-
model_path_a = gr.Textbox(label=f"{translations['model_path']} 1", value="", placeholder="assets/weights/Model_1.pth")
|
802 |
-
model_path_b = gr.Textbox(label=f"{translations['model_path']} 2", value="", placeholder="assets/weights/Model_2.pth")
|
803 |
-
with gr.Row():
|
804 |
-
ratio = gr.Slider(minimum=0, maximum=1, label=translations["model_ratio"], info=translations["model_ratio_info"], value=0.5, interactive=True)
|
805 |
-
with gr.Row():
|
806 |
-
output_model = gr.File(label=translations["output_model_path"], file_types=[".pth", ".onnx"], interactive=False, visible=False)
|
807 |
-
with gr.Row():
|
808 |
-
model_a.upload(fn=lambda model: shutil.move(model.name, os.path.join("assets", "weights")), inputs=[model_a], outputs=[model_path_a])
|
809 |
-
model_b.upload(fn=lambda model: shutil.move(model.name, os.path.join("assets", "weights")), inputs=[model_b], outputs=[model_path_b])
|
810 |
-
with gr.Row():
|
811 |
-
fushion_button.click(
|
812 |
-
fn=fushion_model,
|
813 |
-
inputs=[
|
814 |
-
name_to_save,
|
815 |
-
model_path_a,
|
816 |
-
model_path_b,
|
817 |
-
ratio
|
818 |
-
],
|
819 |
-
outputs=[name_to_save, output_model],
|
820 |
-
api_name="fushion_model"
|
821 |
-
)
|
822 |
-
fushion_button.click(fn=lambda: visible(True), inputs=[], outputs=[output_model])
|
823 |
-
|
824 |
-
with gr.TabItem(translations["read_model"], visible=configs.get("read_tab", True)):
|
825 |
-
gr.Markdown(translations["read_model_markdown"])
|
826 |
-
with gr.Row():
|
827 |
-
gr.Markdown(translations["read_model_markdown_2"])
|
828 |
-
with gr.Row():
|
829 |
-
model = gr.File(label=translations["drop_model"], file_types=[".pth", ".onnx"])
|
830 |
-
with gr.Row():
|
831 |
-
read_button = gr.Button(translations["readmodel"], variant="primary", scale=2)
|
832 |
-
with gr.Column():
|
833 |
-
model_path = gr.Textbox(label=translations["model_path"], value="", placeholder="assets/weights/Model.pth", info=translations["model_path_info"], interactive=True)
|
834 |
-
output_info = gr.Textbox(label=translations["modelinfo"], value="", interactive=False, scale=6)
|
835 |
-
with gr.Row():
|
836 |
-
model.upload(fn=lambda model: shutil.move(model.name, os.path.join("assets", "weights")), inputs=[model], outputs=[model_path])
|
837 |
-
read_button.click(
|
838 |
-
fn=model_info,
|
839 |
-
inputs=[model_path],
|
840 |
-
outputs=[output_info],
|
841 |
-
api_name="read_model"
|
842 |
-
)
|
843 |
-
|
844 |
-
with gr.TabItem(translations["convert_model"], visible=configs.get("onnx_tab", True)):
|
845 |
-
gr.Markdown(translations["pytorch2onnx"])
|
846 |
-
with gr.Row():
|
847 |
-
gr.Markdown(translations["pytorch2onnx_markdown"])
|
848 |
-
with gr.Row():
|
849 |
-
model_pth_upload = gr.File(label=translations["drop_model"], file_types=[".pth"])
|
850 |
-
with gr.Row():
|
851 |
-
convert_onnx = gr.Button(translations["convert_model"], variant="primary", scale=2)
|
852 |
-
with gr.Row():
|
853 |
-
model_pth_path = gr.Textbox(label=translations["model_path"], value="", placeholder="assets/weights/Model.pth", info=translations["model_path_info"], interactive=True)
|
854 |
-
with gr.Row():
|
855 |
-
output_model2 = gr.File(label=translations["output_model_path"], file_types=[".pth", ".onnx"], interactive=False, visible=False)
|
856 |
-
with gr.Row():
|
857 |
-
model_pth_upload.upload(fn=lambda model_pth_upload: shutil.move(model_pth_upload.name, os.path.join("assets", "weights")), inputs=[model_pth_upload], outputs=[model_pth_path])
|
858 |
-
convert_onnx.click(
|
859 |
-
fn=onnx_export,
|
860 |
-
inputs=[model_pth_path],
|
861 |
-
outputs=[output_model2, output_info],
|
862 |
-
api_name="model_onnx_export"
|
863 |
-
)
|
864 |
-
convert_onnx.click(fn=lambda: visible(True), inputs=[], outputs=[output_model2])
|
865 |
-
|
866 |
-
with gr.TabItem(translations["f0_extractor_tab"], visible=configs.get("f0_extractor_tab", True)):
|
867 |
-
gr.Markdown(translations["f0_extractor_markdown"])
|
868 |
-
with gr.Row():
|
869 |
-
gr.Markdown(translations["f0_extractor_markdown_2"])
|
870 |
-
with gr.Row():
|
871 |
-
extractor_button = gr.Button(translations["extract_button"].replace("2. ", ""), variant="primary")
|
872 |
-
with gr.Row():
|
873 |
-
with gr.Column():
|
874 |
-
upload_audio_file = gr.File(label=translations["drop_audio"], file_types=[".wav", ".mp3", ".flac", ".ogg", ".opus", ".m4a", ".mp4", ".aac", ".alac", ".wma", ".aiff", ".webm", ".ac3"])
|
875 |
-
audioplay = gr.Audio(show_download_button=True, interactive=False, label=translations["input_audio"])
|
876 |
-
with gr.Column():
|
877 |
-
with gr.Accordion(translations["f0_method"], open=False):
|
878 |
-
with gr.Group():
|
879 |
-
onnx_f0_mode3 = gr.Checkbox(label=translations["f0_onnx_mode"], info=translations["f0_onnx_mode_info"], value=False, interactive=True)
|
880 |
-
f0_method_extract = gr.Radio(label=translations["f0_method"], info=translations["f0_method_info"], choices=method_f0, value="rmvpe", interactive=True)
|
881 |
-
with gr.Accordion(translations["audio_path"], open=True):
|
882 |
-
input_audio_path = gr.Dropdown(label=translations["audio_path"], value="", choices=paths_for_files, allow_custom_value=True, interactive=True)
|
883 |
-
refesh_audio_button = gr.Button(translations["refesh"])
|
884 |
-
with gr.Row():
|
885 |
-
gr.Markdown("___")
|
886 |
-
with gr.Row():
|
887 |
-
file_output = gr.File(label="", file_types=[".txt"], interactive=False)
|
888 |
-
image_output = gr.Image(label="", interactive=False, show_download_button=True)
|
889 |
-
with gr.Row():
|
890 |
-
upload_audio_file.upload(fn=lambda audio_in: shutil.move(audio_in.name, os.path.join("audios")), inputs=[upload_audio_file], outputs=[input_audio_path])
|
891 |
-
input_audio_path.change(fn=lambda audio: audio if os.path.isfile(audio) else None, inputs=[input_audio_path], outputs=[audioplay])
|
892 |
-
refesh_audio_button.click(fn=change_audios_choices, inputs=[input_audio_path], outputs=[input_audio_path])
|
893 |
-
with gr.Row():
|
894 |
-
extractor_button.click(
|
895 |
-
fn=f0_extract,
|
896 |
-
inputs=[
|
897 |
-
input_audio_path,
|
898 |
-
f0_method_extract,
|
899 |
-
onnx_f0_mode3
|
900 |
-
],
|
901 |
-
outputs=[file_output, image_output],
|
902 |
-
api_name="f0_extract"
|
903 |
-
)
|
904 |
-
|
905 |
with gr.TabItem(translations["settings"], visible=configs.get("settings_tab", True)):
|
906 |
gr.Markdown(translations["settings_markdown"])
|
907 |
with gr.Row():
|
|
|
25 |
from time import sleep
|
26 |
from multiprocessing import cpu_count
|
27 |
from main.app.tabs.inference.inference import inference_tabs
|
28 |
+
from main.app.tabs.models.model import model_tabs
|
29 |
+
|
30 |
sys.path.append(os.getcwd())
|
31 |
|
32 |
from main.tools import huggingface
|
|
|
145 |
inference_tabs()
|
146 |
|
147 |
|
148 |
+
with gr.TabItem("Model Options"):
|
149 |
+
model_tabs()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
150 |
|
151 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
152 |
with gr.TabItem(translations["settings"], visible=configs.get("settings_tab", True)):
|
153 |
gr.Markdown(translations["settings_markdown"])
|
154 |
with gr.Row():
|