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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from original import *
|
| 2 |
+
|
| 3 |
+
import shutil, glob
|
| 4 |
+
|
| 5 |
+
from easyfuncs import download_from_url, CachedModels
|
| 6 |
+
|
| 7 |
+
os.makedirs("dataset",exist_ok=True)
|
| 8 |
+
|
| 9 |
+
model_library = CachedModels()
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
with gr.Blocks(title="🔊",theme=gr.themes.Base(primary_hue="sky",neutral_hue="zinc")) as app:
|
| 14 |
+
|
| 15 |
+
with gr.Row():
|
| 16 |
+
|
| 17 |
+
gr.HTML("<img src='file/a.png' alt='image'>")
|
| 18 |
+
|
| 19 |
+
with gr.Tabs():
|
| 20 |
+
|
| 21 |
+
with gr.TabItem("Inference"):
|
| 22 |
+
|
| 23 |
+
with gr.Row():
|
| 24 |
+
|
| 25 |
+
voice_model = gr.Dropdown(label="Model Voice", choices=sorted(names), value=lambda:sorted(names)[0] if len(sorted(names)) > 0 else '', interactive=True)
|
| 26 |
+
|
| 27 |
+
refresh_button = gr.Button("Refresh", variant="primary")
|
| 28 |
+
|
| 29 |
+
spk_item = gr.Slider(
|
| 30 |
+
|
| 31 |
+
minimum=0,
|
| 32 |
+
|
| 33 |
+
maximum=2333,
|
| 34 |
+
|
| 35 |
+
step=1,
|
| 36 |
+
|
| 37 |
+
label="Speaker ID",
|
| 38 |
+
|
| 39 |
+
value=0,
|
| 40 |
+
|
| 41 |
+
visible=False,
|
| 42 |
+
|
| 43 |
+
interactive=True,
|
| 44 |
+
|
| 45 |
+
)
|
| 46 |
+
|
| 47 |
+
vc_transform0 = gr.Number(
|
| 48 |
+
|
| 49 |
+
label="Pitch",
|
| 50 |
+
|
| 51 |
+
value=0
|
| 52 |
+
|
| 53 |
+
)
|
| 54 |
+
|
| 55 |
+
but0 = gr.Button(value="Convert", variant="primary")
|
| 56 |
+
|
| 57 |
+
with gr.Row():
|
| 58 |
+
|
| 59 |
+
with gr.Column():
|
| 60 |
+
|
| 61 |
+
with gr.Row():
|
| 62 |
+
|
| 63 |
+
dropbox = gr.File(label="Drop your audio here & hit the Reload button.")
|
| 64 |
+
|
| 65 |
+
with gr.Row():
|
| 66 |
+
|
| 67 |
+
record_button=gr.Audio(source="microphone", label="OR Record audio.", type="filepath")
|
| 68 |
+
|
| 69 |
+
with gr.Row():
|
| 70 |
+
|
| 71 |
+
paths_for_files = lambda path:[os.path.abspath(os.path.join(path, f)) for f in os.listdir(path) if os.path.splitext(f)[1].lower() in ('.mp3', '.wav', '.flac', '.ogg')]
|
| 72 |
+
|
| 73 |
+
input_audio0 = gr.Dropdown(
|
| 74 |
+
|
| 75 |
+
label="Input Path",
|
| 76 |
+
|
| 77 |
+
value=paths_for_files('audios')[0] if len(paths_for_files('audios')) > 0 else '',
|
| 78 |
+
|
| 79 |
+
choices=paths_for_files('audios'), # Only show absolute paths for audio files ending in .mp3, .wav, .flac or .ogg
|
| 80 |
+
|
| 81 |
+
allow_custom_value=True
|
| 82 |
+
|
| 83 |
+
)
|
| 84 |
+
|
| 85 |
+
with gr.Row():
|
| 86 |
+
|
| 87 |
+
audio_player = gr.Audio()
|
| 88 |
+
|
| 89 |
+
input_audio0.change(
|
| 90 |
+
|
| 91 |
+
inputs=[input_audio0],
|
| 92 |
+
|
| 93 |
+
outputs=[audio_player],
|
| 94 |
+
|
| 95 |
+
fn=lambda path: {"value":path,"__type__":"update"} if os.path.exists(path) else None
|
| 96 |
+
|
| 97 |
+
)
|
| 98 |
+
|
| 99 |
+
record_button.stop_recording(
|
| 100 |
+
|
| 101 |
+
fn=lambda audio:audio, #TODO save wav lambda
|
| 102 |
+
|
| 103 |
+
inputs=[record_button],
|
| 104 |
+
|
| 105 |
+
outputs=[input_audio0])
|
| 106 |
+
|
| 107 |
+
dropbox.upload(
|
| 108 |
+
|
| 109 |
+
fn=lambda audio:audio.name,
|
| 110 |
+
|
| 111 |
+
inputs=[dropbox],
|
| 112 |
+
|
| 113 |
+
outputs=[input_audio0])
|
| 114 |
+
|
| 115 |
+
with gr.Column():
|
| 116 |
+
|
| 117 |
+
with gr.Accordion("Change Index", open=False):
|
| 118 |
+
|
| 119 |
+
file_index2 = gr.Dropdown(
|
| 120 |
+
|
| 121 |
+
label="Change Index",
|
| 122 |
+
|
| 123 |
+
choices=sorted(index_paths),
|
| 124 |
+
|
| 125 |
+
interactive=True,
|
| 126 |
+
|
| 127 |
+
value=sorted(index_paths)[0] if len(sorted(index_paths)) > 0 else ''
|
| 128 |
+
|
| 129 |
+
)
|
| 130 |
+
|
| 131 |
+
index_rate1 = gr.Slider(
|
| 132 |
+
|
| 133 |
+
minimum=0,
|
| 134 |
+
|
| 135 |
+
maximum=1,
|
| 136 |
+
|
| 137 |
+
label="Index Strength",
|
| 138 |
+
|
| 139 |
+
value=0.5,
|
| 140 |
+
|
| 141 |
+
interactive=True,
|
| 142 |
+
|
| 143 |
+
)
|
| 144 |
+
|
| 145 |
+
vc_output2 = gr.Audio(label="Output")
|
| 146 |
+
|
| 147 |
+
with gr.Accordion("General Settings", open=False):
|
| 148 |
+
|
| 149 |
+
f0method0 = gr.Radio(
|
| 150 |
+
|
| 151 |
+
label="Method",
|
| 152 |
+
|
| 153 |
+
choices=["pm", "harvest", "crepe", "rmvpe"]
|
| 154 |
+
|
| 155 |
+
if config.dml == False
|
| 156 |
+
|
| 157 |
+
else ["pm", "harvest", "rmvpe"],
|
| 158 |
+
|
| 159 |
+
value="rmvpe",
|
| 160 |
+
|
| 161 |
+
interactive=True,
|
| 162 |
+
|
| 163 |
+
)
|
| 164 |
+
|
| 165 |
+
filter_radius0 = gr.Slider(
|
| 166 |
+
|
| 167 |
+
minimum=0,
|
| 168 |
+
|
| 169 |
+
maximum=7,
|
| 170 |
+
|
| 171 |
+
label="Breathiness Reduction (Harvest only)",
|
| 172 |
+
|
| 173 |
+
value=3,
|
| 174 |
+
|
| 175 |
+
step=1,
|
| 176 |
+
|
| 177 |
+
interactive=True,
|
| 178 |
+
|
| 179 |
+
)
|
| 180 |
+
|
| 181 |
+
resample_sr0 = gr.Slider(
|
| 182 |
+
|
| 183 |
+
minimum=0,
|
| 184 |
+
|
| 185 |
+
maximum=48000,
|
| 186 |
+
|
| 187 |
+
label="Resample",
|
| 188 |
+
|
| 189 |
+
value=0,
|
| 190 |
+
|
| 191 |
+
step=1,
|
| 192 |
+
|
| 193 |
+
interactive=True,
|
| 194 |
+
|
| 195 |
+
visible=False
|
| 196 |
+
|
| 197 |
+
)
|
| 198 |
+
|
| 199 |
+
rms_mix_rate0 = gr.Slider(
|
| 200 |
+
|
| 201 |
+
minimum=0,
|
| 202 |
+
|
| 203 |
+
maximum=1,
|
| 204 |
+
|
| 205 |
+
label="Volume Normalization",
|
| 206 |
+
|
| 207 |
+
value=0,
|
| 208 |
+
|
| 209 |
+
interactive=True,
|
| 210 |
+
|
| 211 |
+
)
|
| 212 |
+
|
| 213 |
+
protect0 = gr.Slider(
|
| 214 |
+
|
| 215 |
+
minimum=0,
|
| 216 |
+
|
| 217 |
+
maximum=0.5,
|
| 218 |
+
|
| 219 |
+
label="Breathiness Protection (0 is enabled, 0.5 is disabled)",
|
| 220 |
+
|
| 221 |
+
value=0.33,
|
| 222 |
+
|
| 223 |
+
step=0.01,
|
| 224 |
+
|
| 225 |
+
interactive=True,
|
| 226 |
+
|
| 227 |
+
)
|
| 228 |
+
|
| 229 |
+
if voice_model != None: vc.get_vc(voice_model.value,protect0,protect0)
|
| 230 |
+
|
| 231 |
+
file_index1 = gr.Textbox(
|
| 232 |
+
|
| 233 |
+
label="Index Path",
|
| 234 |
+
|
| 235 |
+
interactive=True,
|
| 236 |
+
|
| 237 |
+
visible=False#Not used here
|
| 238 |
+
|
| 239 |
+
)
|
| 240 |
+
|
| 241 |
+
refresh_button.click(
|
| 242 |
+
|
| 243 |
+
fn=change_choices,
|
| 244 |
+
|
| 245 |
+
inputs=[],
|
| 246 |
+
|
| 247 |
+
outputs=[voice_model, file_index2],
|
| 248 |
+
|
| 249 |
+
api_name="infer_refresh",
|
| 250 |
+
|
| 251 |
+
)
|
| 252 |
+
|
| 253 |
+
refresh_button.click(
|
| 254 |
+
|
| 255 |
+
fn=lambda:{"choices":paths_for_files('audios'),"__type__":"update"}, #TODO check if properly returns a sorted list of audio files in the 'audios' folder that have the extensions '.wav', '.mp3', '.ogg', or '.flac'
|
| 256 |
+
|
| 257 |
+
inputs=[],
|
| 258 |
+
|
| 259 |
+
outputs = [input_audio0],
|
| 260 |
+
|
| 261 |
+
)
|
| 262 |
+
|
| 263 |
+
refresh_button.click(
|
| 264 |
+
|
| 265 |
+
fn=lambda:{"value":paths_for_files('audios')[0],"__type__":"update"} if len(paths_for_files('audios')) > 0 else {"value":"","__type__":"update"}, #TODO check if properly returns a sorted list of audio files in the 'audios' folder that have the extensions '.wav', '.mp3', '.ogg', or '.flac'
|
| 266 |
+
|
| 267 |
+
inputs=[],
|
| 268 |
+
|
| 269 |
+
outputs = [input_audio0],
|
| 270 |
+
|
| 271 |
+
)
|
| 272 |
+
|
| 273 |
+
with gr.Row():
|
| 274 |
+
|
| 275 |
+
f0_file = gr.File(label="F0 Path", visible=False)
|
| 276 |
+
|
| 277 |
+
with gr.Row():
|
| 278 |
+
|
| 279 |
+
vc_output1 = gr.Textbox(label="Information", placeholder="Welcome!",visible=False)
|
| 280 |
+
|
| 281 |
+
but0.click(
|
| 282 |
+
|
| 283 |
+
vc.vc_single,
|
| 284 |
+
|
| 285 |
+
[
|
| 286 |
+
|
| 287 |
+
spk_item,
|
| 288 |
+
|
| 289 |
+
input_audio0,
|
| 290 |
+
|
| 291 |
+
vc_transform0,
|
| 292 |
+
|
| 293 |
+
f0_file,
|
| 294 |
+
|
| 295 |
+
f0method0,
|
| 296 |
+
|
| 297 |
+
file_index1,
|
| 298 |
+
|
| 299 |
+
file_index2,
|
| 300 |
+
|
| 301 |
+
index_rate1,
|
| 302 |
+
|
| 303 |
+
filter_radius0,
|
| 304 |
+
|
| 305 |
+
resample_sr0,
|
| 306 |
+
|
| 307 |
+
rms_mix_rate0,
|
| 308 |
+
|
| 309 |
+
protect0,
|
| 310 |
+
|
| 311 |
+
],
|
| 312 |
+
|
| 313 |
+
[vc_output1, vc_output2],
|
| 314 |
+
|
| 315 |
+
api_name="infer_convert",
|
| 316 |
+
|
| 317 |
+
)
|
| 318 |
+
|
| 319 |
+
voice_model.change(
|
| 320 |
+
|
| 321 |
+
fn=vc.get_vc,
|
| 322 |
+
|
| 323 |
+
inputs=[voice_model, protect0, protect0],
|
| 324 |
+
|
| 325 |
+
outputs=[spk_item, protect0, protect0, file_index2, file_index2],
|
| 326 |
+
|
| 327 |
+
api_name="infer_change_voice",
|
| 328 |
+
|
| 329 |
+
)
|
| 330 |
+
|
| 331 |
+
with gr.TabItem("Download Models"):
|
| 332 |
+
|
| 333 |
+
with gr.Row():
|
| 334 |
+
|
| 335 |
+
url_input = gr.Textbox(label="URL to model", value="",placeholder="https://...", scale=6)
|
| 336 |
+
|
| 337 |
+
name_output = gr.Textbox(label="Save as", value="",placeholder="MyModel",scale=2)
|
| 338 |
+
|
| 339 |
+
url_download = gr.Button(value="Download Model",scale=2)
|
| 340 |
+
|
| 341 |
+
url_download.click(
|
| 342 |
+
|
| 343 |
+
inputs=[url_input,name_output],
|
| 344 |
+
|
| 345 |
+
outputs=[url_input],
|
| 346 |
+
|
| 347 |
+
fn=download_from_url,
|
| 348 |
+
|
| 349 |
+
)
|
| 350 |
+
|
| 351 |
+
with gr.Row():
|
| 352 |
+
|
| 353 |
+
model_browser = gr.Dropdown(choices=list(model_library.models.keys()),label="OR Search Models (Quality UNKNOWN)",scale=5)
|
| 354 |
+
|
| 355 |
+
download_from_browser = gr.Button(value="Get",scale=2)
|
| 356 |
+
|
| 357 |
+
download_from_browser.click(
|
| 358 |
+
|
| 359 |
+
inputs=[model_browser],
|
| 360 |
+
|
| 361 |
+
outputs=[model_browser],
|
| 362 |
+
|
| 363 |
+
fn=lambda model: download_from_url(model_library.models[model],model),
|
| 364 |
+
|
| 365 |
+
)
|
| 366 |
+
|
| 367 |
+
with gr.TabItem("Train"):
|
| 368 |
+
|
| 369 |
+
with gr.Row():
|
| 370 |
+
|
| 371 |
+
with gr.Column():
|
| 372 |
+
|
| 373 |
+
training_name = gr.Textbox(label="Name your model", value="My-Voice",placeholder="My-Voice")
|
| 374 |
+
|
| 375 |
+
np7 = gr.Slider(
|
| 376 |
+
|
| 377 |
+
minimum=0,
|
| 378 |
+
|
| 379 |
+
maximum=config.n_cpu,
|
| 380 |
+
|
| 381 |
+
step=1,
|
| 382 |
+
|
| 383 |
+
label="Number of CPU processes used to extract pitch features",
|
| 384 |
+
|
| 385 |
+
value=int(np.ceil(config.n_cpu / 1.5)),
|
| 386 |
+
|
| 387 |
+
interactive=True,
|
| 388 |
+
|
| 389 |
+
)
|
| 390 |
+
|
| 391 |
+
sr2 = gr.Radio(
|
| 392 |
+
|
| 393 |
+
label="Sampling Rate",
|
| 394 |
+
|
| 395 |
+
choices=["40k", "32k"],
|
| 396 |
+
|
| 397 |
+
value="32k",
|
| 398 |
+
|
| 399 |
+
interactive=True,
|
| 400 |
+
|
| 401 |
+
visible=False
|
| 402 |
+
|
| 403 |
+
)
|
| 404 |
+
|
| 405 |
+
if_f0_3 = gr.Radio(
|
| 406 |
+
|
| 407 |
+
label="Will your model be used for singing? If not, you can ignore this.",
|
| 408 |
+
|
| 409 |
+
choices=[True, False],
|
| 410 |
+
|
| 411 |
+
value=True,
|
| 412 |
+
|
| 413 |
+
interactive=True,
|
| 414 |
+
|
| 415 |
+
visible=False
|
| 416 |
+
|
| 417 |
+
)
|
| 418 |
+
|
| 419 |
+
version19 = gr.Radio(
|
| 420 |
+
|
| 421 |
+
label="Version",
|
| 422 |
+
|
| 423 |
+
choices=["v1", "v2"],
|
| 424 |
+
|
| 425 |
+
value="v2",
|
| 426 |
+
|
| 427 |
+
interactive=True,
|
| 428 |
+
|
| 429 |
+
visible=False,
|
| 430 |
+
|
| 431 |
+
)
|
| 432 |
+
|
| 433 |
+
dataset_folder = gr.Textbox(
|
| 434 |
+
|
| 435 |
+
label="dataset folder", value='dataset'
|
| 436 |
+
|
| 437 |
+
)
|
| 438 |
+
|
| 439 |
+
easy_uploader = gr.Files(label="Drop your audio files here",file_types=['audio'])
|
| 440 |
+
|
| 441 |
+
but1 = gr.Button("1. Process", variant="primary")
|
| 442 |
+
|
| 443 |
+
info1 = gr.Textbox(label="Information", value="",visible=True)
|
| 444 |
+
|
| 445 |
+
easy_uploader.upload(inputs=[dataset_folder],outputs=[],fn=lambda folder:os.makedirs(folder,exist_ok=True))
|
| 446 |
+
|
| 447 |
+
easy_uploader.upload(
|
| 448 |
+
|
| 449 |
+
fn=lambda files,folder: [shutil.copy2(f.name,os.path.join(folder,os.path.split(f.name)[1])) for f in files] if folder != "" else gr.Warning('Please enter a folder name for your dataset'),
|
| 450 |
+
|
| 451 |
+
inputs=[easy_uploader, dataset_folder],
|
| 452 |
+
|
| 453 |
+
outputs=[])
|
| 454 |
+
|
| 455 |
+
gpus6 = gr.Textbox(
|
| 456 |
+
|
| 457 |
+
label="Enter the GPU numbers to use separated by -, (e.g. 0-1-2)",
|
| 458 |
+
|
| 459 |
+
value=gpus,
|
| 460 |
+
|
| 461 |
+
interactive=True,
|
| 462 |
+
|
| 463 |
+
visible=F0GPUVisible,
|
| 464 |
+
|
| 465 |
+
)
|
| 466 |
+
|
| 467 |
+
gpu_info9 = gr.Textbox(
|
| 468 |
+
|
| 469 |
+
label="GPU Info", value=gpu_info, visible=F0GPUVisible
|
| 470 |
+
|
| 471 |
+
)
|
| 472 |
+
|
| 473 |
+
spk_id5 = gr.Slider(
|
| 474 |
+
|
| 475 |
+
minimum=0,
|
| 476 |
+
|
| 477 |
+
maximum=4,
|
| 478 |
+
|
| 479 |
+
step=1,
|
| 480 |
+
|
| 481 |
+
label="Speaker ID",
|
| 482 |
+
|
| 483 |
+
value=0,
|
| 484 |
+
|
| 485 |
+
interactive=True,
|
| 486 |
+
|
| 487 |
+
visible=False
|
| 488 |
+
|
| 489 |
+
)
|
| 490 |
+
|
| 491 |
+
but1.click(
|
| 492 |
+
|
| 493 |
+
preprocess_dataset,
|
| 494 |
+
|
| 495 |
+
[dataset_folder, training_name, sr2, np7],
|
| 496 |
+
|
| 497 |
+
[info1],
|
| 498 |
+
|
| 499 |
+
api_name="train_preprocess",
|
| 500 |
+
|
| 501 |
+
)
|
| 502 |
+
|
| 503 |
+
with gr.Column():
|
| 504 |
+
|
| 505 |
+
f0method8 = gr.Radio(
|
| 506 |
+
|
| 507 |
+
label="F0 extraction method",
|
| 508 |
+
|
| 509 |
+
choices=["pm", "harvest", "dio", "rmvpe", "rmvpe_gpu"],
|
| 510 |
+
|
| 511 |
+
value="rmvpe_gpu",
|
| 512 |
+
|
| 513 |
+
interactive=True,
|
| 514 |
+
|
| 515 |
+
)
|
| 516 |
+
|
| 517 |
+
gpus_rmvpe = gr.Textbox(
|
| 518 |
+
|
| 519 |
+
label="GPU numbers to use separated by -, (e.g. 0-1-2)",
|
| 520 |
+
|
| 521 |
+
value="%s-%s" % (gpus, gpus),
|
| 522 |
+
|
| 523 |
+
interactive=True,
|
| 524 |
+
|
| 525 |
+
visible=F0GPUVisible,
|
| 526 |
+
|
| 527 |
+
)
|
| 528 |
+
|
| 529 |
+
but2 = gr.Button("2. Extract Features", variant="primary")
|
| 530 |
+
|
| 531 |
+
info2 = gr.Textbox(label="Information", value="", max_lines=8)
|
| 532 |
+
|
| 533 |
+
f0method8.change(
|
| 534 |
+
|
| 535 |
+
fn=change_f0_method,
|
| 536 |
+
|
| 537 |
+
inputs=[f0method8],
|
| 538 |
+
|
| 539 |
+
outputs=[gpus_rmvpe],
|
| 540 |
+
|
| 541 |
+
)
|
| 542 |
+
|
| 543 |
+
but2.click(
|
| 544 |
+
|
| 545 |
+
extract_f0_feature,
|
| 546 |
+
|
| 547 |
+
[
|
| 548 |
+
|
| 549 |
+
gpus6,
|
| 550 |
+
|
| 551 |
+
np7,
|
| 552 |
+
|
| 553 |
+
f0method8,
|
| 554 |
+
|
| 555 |
+
if_f0_3,
|
| 556 |
+
|
| 557 |
+
training_name,
|
| 558 |
+
|
| 559 |
+
version19,
|
| 560 |
+
|
| 561 |
+
gpus_rmvpe,
|
| 562 |
+
|
| 563 |
+
],
|
| 564 |
+
|
| 565 |
+
[info2],
|
| 566 |
+
|
| 567 |
+
api_name="train_extract_f0_feature",
|
| 568 |
+
|
| 569 |
+
)
|
| 570 |
+
|
| 571 |
+
with gr.Column():
|
| 572 |
+
|
| 573 |
+
total_epoch11 = gr.Slider(
|
| 574 |
+
|
| 575 |
+
minimum=2,
|
| 576 |
+
|
| 577 |
+
maximum=1000,
|
| 578 |
+
|
| 579 |
+
step=1,
|
| 580 |
+
|
| 581 |
+
label="Epochs (more epochs may improve quality but takes longer)",
|
| 582 |
+
|
| 583 |
+
value=150,
|
| 584 |
+
|
| 585 |
+
interactive=True,
|
| 586 |
+
|
| 587 |
+
)
|
| 588 |
+
|
| 589 |
+
but4 = gr.Button("3. Train Index", variant="primary")
|
| 590 |
+
|
| 591 |
+
but3 = gr.Button("4. Train Model", variant="primary")
|
| 592 |
+
|
| 593 |
+
info3 = gr.Textbox(label="Information", value="", max_lines=10)
|
| 594 |
+
|
| 595 |
+
with gr.Accordion(label="General Settings", open=False):
|
| 596 |
+
|
| 597 |
+
gpus16 = gr.Textbox(
|
| 598 |
+
|
| 599 |
+
label="GPUs separated by -, (e.g. 0-1-2)",
|
| 600 |
+
|
| 601 |
+
value="0",
|
| 602 |
+
|
| 603 |
+
interactive=True,
|
| 604 |
+
|
| 605 |
+
visible=True
|
| 606 |
+
|
| 607 |
+
)
|
| 608 |
+
|
| 609 |
+
save_epoch10 = gr.Slider(
|
| 610 |
+
|
| 611 |
+
minimum=1,
|
| 612 |
+
|
| 613 |
+
maximum=50,
|
| 614 |
+
|
| 615 |
+
step=1,
|
| 616 |
+
|
| 617 |
+
label="Weight Saving Frequency",
|
| 618 |
+
|
| 619 |
+
value=25,
|
| 620 |
+
|
| 621 |
+
interactive=True,
|
| 622 |
+
|
| 623 |
+
)
|
| 624 |
+
|
| 625 |
+
batch_size12 = gr.Slider(
|
| 626 |
+
|
| 627 |
+
minimum=1,
|
| 628 |
+
|
| 629 |
+
maximum=40,
|
| 630 |
+
|
| 631 |
+
step=1,
|
| 632 |
+
|
| 633 |
+
label="Batch Size",
|
| 634 |
+
|
| 635 |
+
value=default_batch_size,
|
| 636 |
+
|
| 637 |
+
interactive=True,
|
| 638 |
+
|
| 639 |
+
)
|
| 640 |
+
|
| 641 |
+
if_save_latest13 = gr.Radio(
|
| 642 |
+
|
| 643 |
+
label="Only save the latest model",
|
| 644 |
+
|
| 645 |
+
choices=["yes", "no"],
|
| 646 |
+
|
| 647 |
+
value="yes",
|
| 648 |
+
|
| 649 |
+
interactive=True,
|
| 650 |
+
|
| 651 |
+
visible=False
|
| 652 |
+
|
| 653 |
+
)
|
| 654 |
+
|
| 655 |
+
if_cache_gpu17 = gr.Radio(
|
| 656 |
+
|
| 657 |
+
label="If your dataset is UNDER 10 minutes, cache it to train faster",
|
| 658 |
+
|
| 659 |
+
choices=["yes", "no"],
|
| 660 |
+
|
| 661 |
+
value="no",
|
| 662 |
+
|
| 663 |
+
interactive=True,
|
| 664 |
+
|
| 665 |
+
)
|
| 666 |
+
|
| 667 |
+
if_save_every_weights18 = gr.Radio(
|
| 668 |
+
|
| 669 |
+
label="Save small model at every save point",
|
| 670 |
+
|
| 671 |
+
choices=["yes", "no"],
|
| 672 |
+
|
| 673 |
+
value="yes",
|
| 674 |
+
|
| 675 |
+
interactive=True,
|
| 676 |
+
|
| 677 |
+
)
|
| 678 |
+
|
| 679 |
+
with gr.Accordion(label="Change pretrains", open=False):
|
| 680 |
+
pretrained_G14 = gr.Textbox(
|
| 681 |
+
|
| 682 |
+
label="pretrained G path",
|
| 683 |
+
|
| 684 |
+
|
| 685 |
+
)
|
| 686 |
+
|
| 687 |
+
pretrained_D15 = gr.Textbox(
|
| 688 |
+
|
| 689 |
+
label="pretrained D path",
|
| 690 |
+
)
|
| 691 |
+
|
| 692 |
+
with gr.Row():
|
| 693 |
+
|
| 694 |
+
download_model = gr.Button('5.Download Model')
|
| 695 |
+
|
| 696 |
+
with gr.Row():
|
| 697 |
+
|
| 698 |
+
model_files = gr.Files(label='Your Model and Index file can be downloaded here:')
|
| 699 |
+
|
| 700 |
+
download_model.click(
|
| 701 |
+
|
| 702 |
+
fn=lambda name: os.listdir(f'assets/weights/{name}') + glob.glob(f'logs/{name.split(".")[0]}/added_*.index'),
|
| 703 |
+
|
| 704 |
+
inputs=[training_name],
|
| 705 |
+
|
| 706 |
+
outputs=[model_files, info3])
|
| 707 |
+
|
| 708 |
+
with gr.Row():
|
| 709 |
+
|
| 710 |
+
sr2.change(
|
| 711 |
+
|
| 712 |
+
change_sr2,
|
| 713 |
+
|
| 714 |
+
[sr2, if_f0_3, version19],
|
| 715 |
+
|
| 716 |
+
[pretrained_G14, pretrained_D15],
|
| 717 |
+
|
| 718 |
+
)
|
| 719 |
+
|
| 720 |
+
version19.change(
|
| 721 |
+
|
| 722 |
+
change_version19,
|
| 723 |
+
|
| 724 |
+
[sr2, if_f0_3, version19],
|
| 725 |
+
|
| 726 |
+
[pretrained_G14, pretrained_D15, sr2],
|
| 727 |
+
|
| 728 |
+
)
|
| 729 |
+
|
| 730 |
+
if_f0_3.change(
|
| 731 |
+
|
| 732 |
+
change_f0,
|
| 733 |
+
|
| 734 |
+
[if_f0_3, sr2, version19],
|
| 735 |
+
|
| 736 |
+
[f0method8, pretrained_G14, pretrained_D15],
|
| 737 |
+
|
| 738 |
+
)
|
| 739 |
+
|
| 740 |
+
with gr.Row():
|
| 741 |
+
|
| 742 |
+
but5 = gr.Button("1 Click Training", variant="primary", visible=False)
|
| 743 |
+
|
| 744 |
+
but3.click(
|
| 745 |
+
|
| 746 |
+
click_train,
|
| 747 |
+
|
| 748 |
+
[
|
| 749 |
+
|
| 750 |
+
training_name,
|
| 751 |
+
|
| 752 |
+
sr2,
|
| 753 |
+
|
| 754 |
+
if_f0_3,
|
| 755 |
+
|
| 756 |
+
spk_id5,
|
| 757 |
+
|
| 758 |
+
save_epoch10,
|
| 759 |
+
|
| 760 |
+
total_epoch11,
|
| 761 |
+
|
| 762 |
+
batch_size12,
|
| 763 |
+
|
| 764 |
+
if_save_latest13,
|
| 765 |
+
|
| 766 |
+
pretrained_G14,
|
| 767 |
+
|
| 768 |
+
pretrained_D15,
|
| 769 |
+
|
| 770 |
+
gpus16,
|
| 771 |
+
|
| 772 |
+
if_cache_gpu17,
|
| 773 |
+
|
| 774 |
+
if_save_every_weights18,
|
| 775 |
+
|
| 776 |
+
version19,
|
| 777 |
+
|
| 778 |
+
],
|
| 779 |
+
|
| 780 |
+
info3,
|
| 781 |
+
|
| 782 |
+
api_name="train_start",
|
| 783 |
+
|
| 784 |
+
)
|
| 785 |
+
|
| 786 |
+
but4.click(train_index, [training_name, version19], info3)
|
| 787 |
+
|
| 788 |
+
but5.click(
|
| 789 |
+
|
| 790 |
+
train1key,
|
| 791 |
+
|
| 792 |
+
[
|
| 793 |
+
|
| 794 |
+
training_name,
|
| 795 |
+
|
| 796 |
+
sr2,
|
| 797 |
+
|
| 798 |
+
if_f0_3,
|
| 799 |
+
|
| 800 |
+
dataset_folder,
|
| 801 |
+
|
| 802 |
+
spk_id5,
|
| 803 |
+
|
| 804 |
+
np7,
|
| 805 |
+
|
| 806 |
+
f0method8,
|
| 807 |
+
|
| 808 |
+
save_epoch10,
|
| 809 |
+
|
| 810 |
+
total_epoch11,
|
| 811 |
+
|
| 812 |
+
batch_size12,
|
| 813 |
+
|
| 814 |
+
if_save_latest13,
|
| 815 |
+
|
| 816 |
+
pretrained_G14,
|
| 817 |
+
|
| 818 |
+
pretrained_D15,
|
| 819 |
+
|
| 820 |
+
gpus16,
|
| 821 |
+
|
| 822 |
+
if_cache_gpu17,
|
| 823 |
+
|
| 824 |
+
if_save_every_weights18,
|
| 825 |
+
|
| 826 |
+
version19,
|
| 827 |
+
|
| 828 |
+
gpus_rmvpe,
|
| 829 |
+
|
| 830 |
+
],
|
| 831 |
+
|
| 832 |
+
info3,
|
| 833 |
+
|
| 834 |
+
api_name="train_start_all",
|
| 835 |
+
|
| 836 |
+
)
|
| 837 |
+
|
| 838 |
+
|
| 839 |
+
|
| 840 |
+
if config.iscolab:
|
| 841 |
+
|
| 842 |
+
app.queue(concurrency_count=511, max_size=1022).launch(share=True)
|
| 843 |
+
|
| 844 |
+
else:
|
| 845 |
+
|
| 846 |
+
app.queue(concurrency_count=511, max_size=1022).launch(
|
| 847 |
+
|
| 848 |
+
server_name="0.0.0.0",
|
| 849 |
+
|
| 850 |
+
inbrowser=not config.noautoopen,
|
| 851 |
+
|
| 852 |
+
server_port=config.listen_port,
|
| 853 |
+
|
| 854 |
+
quiet=True,
|
| 855 |
+
|
| 856 |
+
)
|