nevreal commited on
Commit
6b1d5b4
·
verified ·
1 Parent(s): 059cdff

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -1374
app.py DELETED
@@ -1,1374 +0,0 @@
1
- import os
2
- import sys
3
- from dotenv import load_dotenv
4
-
5
- now_dir = os.getcwd()
6
- sys.path.append(now_dir)
7
- load_dotenv()
8
- from infer.modules.vc.modules import VC
9
- from infer.modules.uvr5.modules import uvr
10
- from infer.lib.train.process_ckpt import (
11
- change_info,
12
- extract_small_model,
13
- merge,
14
- show_info,
15
- )
16
- from i18n.i18n import I18nAuto
17
- from configs.config import Config
18
- from sklearn.cluster import MiniBatchKMeans
19
- import torch, platform
20
- import numpy as np
21
- import gradio as gr
22
- import faiss
23
- import fairseq
24
- import pathlib
25
- import json
26
- from time import sleep
27
- from subprocess import Popen
28
- from random import shuffle
29
- import warnings
30
- import traceback
31
- import threading
32
- import shutil
33
- import logging
34
-
35
- os.system("python tools/download_models.py")
36
-
37
-
38
- logging.getLogger("numba").setLevel(logging.WARNING)
39
- logging.getLogger("httpx").setLevel(logging.WARNING)
40
-
41
- logger = logging.getLogger(__name__)
42
-
43
- tmp = os.path.join(now_dir, "TEMP")
44
- shutil.rmtree(tmp, ignore_errors=True)
45
- shutil.rmtree("%s/runtime/Lib/site-packages/infer_pack" % (now_dir), ignore_errors=True)
46
- shutil.rmtree("%s/runtime/Lib/site-packages/uvr5_pack" % (now_dir), ignore_errors=True)
47
- os.makedirs(tmp, exist_ok=True)
48
- os.makedirs(os.path.join(now_dir, "logs"), exist_ok=True)
49
- os.makedirs(os.path.join(now_dir, "assets/weights"), exist_ok=True)
50
- os.environ["TEMP"] = tmp
51
- warnings.filterwarnings("ignore")
52
- torch.manual_seed(114514)
53
-
54
-
55
- config = Config()
56
- vc = VC(config)
57
-
58
-
59
- if config.dml == True:
60
-
61
- def forward_dml(ctx, x, scale):
62
- ctx.scale = scale
63
- res = x.clone().detach()
64
- return res
65
-
66
- fairseq.modules.grad_multiply.GradMultiply.forward = forward_dml
67
- i18n = I18nAuto()
68
- logger.info(i18n)
69
- # 判断是否有能用来训练和加速推理的N卡
70
- ngpu = torch.cuda.device_count()
71
- gpu_infos = []
72
- mem = []
73
- if_gpu_ok = False
74
-
75
- if torch.cuda.is_available() or ngpu != 0:
76
- for i in range(ngpu):
77
- gpu_name = torch.cuda.get_device_name(i)
78
- if any(
79
- value in gpu_name.upper()
80
- for value in [
81
- "10",
82
- "16",
83
- "20",
84
- "30",
85
- "40",
86
- "A2",
87
- "A3",
88
- "A4",
89
- "P4",
90
- "A50",
91
- "500",
92
- "A60",
93
- "70",
94
- "80",
95
- "90",
96
- "M4",
97
- "T4",
98
- "TITAN",
99
- "4060",
100
- "L",
101
- "6000",
102
- ]
103
- ):
104
- # A10#A100#V100#A40#P40#M40#K80#A4500
105
- if_gpu_ok = True # 至少有一张能用的N卡
106
- gpu_infos.append("%s\t%s" % (i, gpu_name))
107
- mem.append(
108
- int(
109
- torch.cuda.get_device_properties(i).total_memory
110
- / 1024
111
- / 1024
112
- / 1024
113
- + 0.4
114
- )
115
- )
116
- if if_gpu_ok and len(gpu_infos) > 0:
117
- gpu_info = "\n".join(gpu_infos)
118
- default_batch_size = min(mem) // 2
119
- else:
120
- gpu_info = i18n("很遗憾您这没有能用的显卡来支持您训练")
121
- default_batch_size = 1
122
- gpus = "-".join([i[0] for i in gpu_infos])
123
-
124
-
125
- class ToolButton(gr.Button, gr.components.FormComponent):
126
- """Small button with single emoji as text, fits inside gradio forms"""
127
-
128
- def __init__(self, **kwargs):
129
- super().__init__(variant="tool", **kwargs)
130
-
131
- def get_block_name(self):
132
- return "button"
133
-
134
-
135
- weight_root = os.getenv("weight_root")
136
- weight_uvr5_root = os.getenv("weight_uvr5_root")
137
- index_root = os.getenv("index_root")
138
- outside_index_root = os.getenv("outside_index_root")
139
-
140
- names = []
141
- for name in os.listdir(weight_root):
142
- if name.endswith(".pth"):
143
- names.append(name)
144
- index_paths = []
145
-
146
-
147
- def lookup_indices(index_root):
148
- global index_paths
149
- for root, dirs, files in os.walk(index_root, topdown=False):
150
- for name in files:
151
- if name.endswith(".index") and "trained" not in name:
152
- index_paths.append("%s/%s" % (root, name))
153
-
154
-
155
- lookup_indices(index_root)
156
- lookup_indices(outside_index_root)
157
- uvr5_names = []
158
- for name in os.listdir(weight_uvr5_root):
159
- if name.endswith(".pth") or "onnx" in name:
160
- uvr5_names.append(name.replace(".pth", ""))
161
-
162
-
163
- def change_choices():
164
- names = []
165
- for name in os.listdir(weight_root):
166
- if name.endswith(".pth"):
167
- names.append(name)
168
- index_paths = []
169
- for root, dirs, files in os.walk(index_root, topdown=False):
170
- for name in files:
171
- if name.endswith(".index") and "trained" not in name:
172
- index_paths.append("%s/%s" % (root, name))
173
- return {"choices": sorted(names), "__type__": "update"}, {
174
- "choices": sorted(index_paths),
175
- "__type__": "update",
176
- }
177
-
178
-
179
- def clean():
180
- return {"value": "", "__type__": "update"}
181
-
182
-
183
- def export_onnx(ModelPath, ExportedPath):
184
- from infer.modules.onnx.export import export_onnx as eo
185
-
186
- eo(ModelPath, ExportedPath)
187
-
188
-
189
- sr_dict = {
190
- "32k": 32000,
191
- "40k": 40000,
192
- "48k": 48000,
193
- }
194
-
195
-
196
- def if_done(done, p):
197
- while 1:
198
- if p.poll() is None:
199
- sleep(0.5)
200
- else:
201
- break
202
- done[0] = True
203
-
204
-
205
- def if_done_multi(done, ps):
206
- while 1:
207
- # poll==None代表进程未结束
208
- # 只要有一个进程未结束都不停
209
- flag = 1
210
- for p in ps:
211
- if p.poll() is None:
212
- flag = 0
213
- sleep(0.5)
214
- break
215
- if flag == 1:
216
- break
217
- done[0] = True
218
-
219
-
220
- def preprocess_dataset(trainset_dir, exp_dir, sr, n_p):
221
- sr = sr_dict[sr]
222
- os.makedirs("%s/logs/%s" % (now_dir, exp_dir), exist_ok=True)
223
- f = open("%s/logs/%s/preprocess.log" % (now_dir, exp_dir), "w")
224
- f.close()
225
- cmd = '"%s" infer/modules/train/preprocess.py "%s" %s %s "%s/logs/%s" %s %.1f' % (
226
- config.python_cmd,
227
- trainset_dir,
228
- sr,
229
- n_p,
230
- now_dir,
231
- exp_dir,
232
- config.noparallel,
233
- config.preprocess_per,
234
- )
235
- logger.info("Execute: " + cmd)
236
- # , stdin=PIPE, stdout=PIPE,stderr=PIPE,cwd=now_dir
237
- p = Popen(cmd, shell=True)
238
- # 煞笔gr, popen read都非得全跑完了再一次性读取, 不用gr就正常读一句输出一句;只能额外弄出一个文本流定时读
239
- done = [False]
240
- threading.Thread(
241
- target=if_done,
242
- args=(
243
- done,
244
- p,
245
- ),
246
- ).start()
247
- while 1:
248
- with open("%s/logs/%s/preprocess.log" % (now_dir, exp_dir), "r") as f:
249
- yield (f.read())
250
- sleep(1)
251
- if done[0]:
252
- break
253
- with open("%s/logs/%s/preprocess.log" % (now_dir, exp_dir), "r") as f:
254
- log = f.read()
255
- logger.info(log)
256
- yield log
257
-
258
-
259
- # but2.click(extract_f0,[gpus6,np7,f0method8,if_f0_3,trainset_dir4],[info2])
260
- def extract_f0_feature(gpus, n_p, f0method, if_f0, exp_dir, version19, gpus_rmvpe):
261
- gpus = gpus.split("-")
262
- os.makedirs("%s/logs/%s" % (now_dir, exp_dir), exist_ok=True)
263
- f = open("%s/logs/%s/extract_f0_feature.log" % (now_dir, exp_dir), "w")
264
- f.close()
265
- if if_f0:
266
- if f0method != "rmvpe_gpu":
267
- cmd = (
268
- '"%s" infer/modules/train/extract/extract_f0_print.py "%s/logs/%s" %s %s'
269
- % (
270
- config.python_cmd,
271
- now_dir,
272
- exp_dir,
273
- n_p,
274
- f0method,
275
- )
276
- )
277
- logger.info("Execute: " + cmd)
278
- p = Popen(
279
- cmd, shell=True, cwd=now_dir
280
- ) # , stdin=PIPE, stdout=PIPE,stderr=PIPE
281
- # 煞笔gr, popen read都非得全跑完了再一次性读取, 不用gr就正常读一句输出一句;只能额外弄出一个文本流定时读
282
- done = [False]
283
- threading.Thread(
284
- target=if_done,
285
- args=(
286
- done,
287
- p,
288
- ),
289
- ).start()
290
- else:
291
- if gpus_rmvpe != "-":
292
- gpus_rmvpe = gpus_rmvpe.split("-")
293
- leng = len(gpus_rmvpe)
294
- ps = []
295
- for idx, n_g in enumerate(gpus_rmvpe):
296
- cmd = (
297
- '"%s" infer/modules/train/extract/extract_f0_rmvpe.py %s %s %s "%s/logs/%s" %s '
298
- % (
299
- config.python_cmd,
300
- leng,
301
- idx,
302
- n_g,
303
- now_dir,
304
- exp_dir,
305
- config.is_half,
306
- )
307
- )
308
- logger.info("Execute: " + cmd)
309
- p = Popen(
310
- cmd, shell=True, cwd=now_dir
311
- ) # , shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE, cwd=now_dir
312
- ps.append(p)
313
- # 煞笔gr, popen read都非得全跑完了再一次性读取, 不用gr就正常读一句输出一句;只能额外弄出一个文本流定时读
314
- done = [False]
315
- threading.Thread(
316
- target=if_done_multi, #
317
- args=(
318
- done,
319
- ps,
320
- ),
321
- ).start()
322
- else:
323
- cmd = (
324
- config.python_cmd
325
- + ' infer/modules/train/extract/extract_f0_rmvpe_dml.py "%s/logs/%s" '
326
- % (
327
- now_dir,
328
- exp_dir,
329
- )
330
- )
331
- logger.info("Execute: " + cmd)
332
- p = Popen(
333
- cmd, shell=True, cwd=now_dir
334
- ) # , shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE, cwd=now_dir
335
- p.wait()
336
- done = [True]
337
- while 1:
338
- with open(
339
- "%s/logs/%s/extract_f0_feature.log" % (now_dir, exp_dir), "r"
340
- ) as f:
341
- yield (f.read())
342
- sleep(1)
343
- if done[0]:
344
- break
345
- with open("%s/logs/%s/extract_f0_feature.log" % (now_dir, exp_dir), "r") as f:
346
- log = f.read()
347
- logger.info(log)
348
- yield log
349
- # 对不同part分别开多进程
350
- """
351
- n_part=int(sys.argv[1])
352
- i_part=int(sys.argv[2])
353
- i_gpu=sys.argv[3]
354
- exp_dir=sys.argv[4]
355
- os.environ["CUDA_VISIBLE_DEVICES"]=str(i_gpu)
356
- """
357
- leng = len(gpus)
358
- ps = []
359
- for idx, n_g in enumerate(gpus):
360
- cmd = (
361
- '"%s" infer/modules/train/extract_feature_print.py %s %s %s %s "%s/logs/%s" %s %s'
362
- % (
363
- config.python_cmd,
364
- config.device,
365
- leng,
366
- idx,
367
- n_g,
368
- now_dir,
369
- exp_dir,
370
- version19,
371
- config.is_half,
372
- )
373
- )
374
- logger.info("Execute: " + cmd)
375
- p = Popen(
376
- cmd, shell=True, cwd=now_dir
377
- ) # , shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE, cwd=now_dir
378
- ps.append(p)
379
- # 煞笔gr, popen read都非得全跑完了再一次性读取, 不用gr就正常读一句输出一句;只能额外弄出一个文本流定时读
380
- done = [False]
381
- threading.Thread(
382
- target=if_done_multi,
383
- args=(
384
- done,
385
- ps,
386
- ),
387
- ).start()
388
- while 1:
389
- with open("%s/logs/%s/extract_f0_feature.log" % (now_dir, exp_dir), "r") as f:
390
- yield (f.read())
391
- sleep(1)
392
- if done[0]:
393
- break
394
- with open("%s/logs/%s/extract_f0_feature.log" % (now_dir, exp_dir), "r") as f:
395
- log = f.read()
396
- logger.info(log)
397
- yield log
398
-
399
-
400
- def get_pretrained_models(path_str, f0_str, sr2):
401
- if_pretrained_generator_exist = os.access(
402
- "assets/pretrained%s/%sG%s.pth" % (path_str, f0_str, sr2), os.F_OK
403
- )
404
- if_pretrained_discriminator_exist = os.access(
405
- "assets/pretrained%s/%sD%s.pth" % (path_str, f0_str, sr2), os.F_OK
406
- )
407
- if not if_pretrained_generator_exist:
408
- logger.warning(
409
- "assets/pretrained%s/%sG%s.pth not exist, will not use pretrained model",
410
- path_str,
411
- f0_str,
412
- sr2,
413
- )
414
- if not if_pretrained_discriminator_exist:
415
- logger.warning(
416
- "assets/pretrained%s/%sD%s.pth not exist, will not use pretrained model",
417
- path_str,
418
- f0_str,
419
- sr2,
420
- )
421
- return (
422
- (
423
- "assets/pretrained%s/%sG%s.pth" % (path_str, f0_str, sr2)
424
- if if_pretrained_generator_exist
425
- else ""
426
- ),
427
- (
428
- "assets/pretrained%s/%sD%s.pth" % (path_str, f0_str, sr2)
429
- if if_pretrained_discriminator_exist
430
- else ""
431
- ),
432
- )
433
-
434
-
435
- def change_sr2(sr2, if_f0_3, version19):
436
- path_str = "" if version19 == "v1" else "_v2"
437
- f0_str = "f0" if if_f0_3 else ""
438
- return get_pretrained_models(path_str, f0_str, sr2)
439
-
440
-
441
- def change_version19(sr2, if_f0_3, version19):
442
- path_str = "" if version19 == "v1" else "_v2"
443
- if sr2 == "32k" and version19 == "v1":
444
- sr2 = "40k"
445
- to_return_sr2 = (
446
- {"choices": ["40k", "48k"], "__type__": "update", "value": sr2}
447
- if version19 == "v1"
448
- else {"choices": ["40k", "48k", "32k"], "__type__": "update", "value": sr2}
449
- )
450
- f0_str = "f0" if if_f0_3 else ""
451
- return (
452
- *get_pretrained_models(path_str, f0_str, sr2),
453
- to_return_sr2,
454
- )
455
-
456
-
457
- def change_f0(if_f0_3, sr2, version19): # f0method8,pretrained_G14,pretrained_D15
458
- path_str = "" if version19 == "v1" else "_v2"
459
- return (
460
- {"visible": if_f0_3, "__type__": "update"},
461
- {"visible": if_f0_3, "__type__": "update"},
462
- *get_pretrained_models(path_str, "f0" if if_f0_3 == True else "", sr2),
463
- )
464
-
465
-
466
- # but3.click(click_train,[exp_dir1,sr2,if_f0_3,save_epoch10,total_epoch11,batch_size12,if_save_latest13,pretrained_G14,pretrained_D15,gpus16])
467
- def click_train(
468
- exp_dir1,
469
- sr2,
470
- if_f0_3,
471
- spk_id5,
472
- save_epoch10,
473
- total_epoch11,
474
- batch_size12,
475
- if_save_latest13,
476
- pretrained_G14,
477
- pretrained_D15,
478
- gpus16,
479
- if_cache_gpu17,
480
- if_save_every_weights18,
481
- version19,
482
- ):
483
- # 生成filelist
484
- exp_dir = "%s/logs/%s" % (now_dir, exp_dir1)
485
- os.makedirs(exp_dir, exist_ok=True)
486
- gt_wavs_dir = "%s/0_gt_wavs" % (exp_dir)
487
- feature_dir = (
488
- "%s/3_feature256" % (exp_dir)
489
- if version19 == "v1"
490
- else "%s/3_feature768" % (exp_dir)
491
- )
492
- if if_f0_3:
493
- f0_dir = "%s/2a_f0" % (exp_dir)
494
- f0nsf_dir = "%s/2b-f0nsf" % (exp_dir)
495
- names = (
496
- set([name.split(".")[0] for name in os.listdir(gt_wavs_dir)])
497
- & set([name.split(".")[0] for name in os.listdir(feature_dir)])
498
- & set([name.split(".")[0] for name in os.listdir(f0_dir)])
499
- & set([name.split(".")[0] for name in os.listdir(f0nsf_dir)])
500
- )
501
- else:
502
- names = set([name.split(".")[0] for name in os.listdir(gt_wavs_dir)]) & set(
503
- [name.split(".")[0] for name in os.listdir(feature_dir)]
504
- )
505
- opt = []
506
- for name in names:
507
- if if_f0_3:
508
- opt.append(
509
- "%s/%s.wav|%s/%s.npy|%s/%s.wav.npy|%s/%s.wav.npy|%s"
510
- % (
511
- gt_wavs_dir.replace("\\", "\\\\"),
512
- name,
513
- feature_dir.replace("\\", "\\\\"),
514
- name,
515
- f0_dir.replace("\\", "\\\\"),
516
- name,
517
- f0nsf_dir.replace("\\", "\\\\"),
518
- name,
519
- spk_id5,
520
- )
521
- )
522
- else:
523
- opt.append(
524
- "%s/%s.wav|%s/%s.npy|%s"
525
- % (
526
- gt_wavs_dir.replace("\\", "\\\\"),
527
- name,
528
- feature_dir.replace("\\", "\\\\"),
529
- name,
530
- spk_id5,
531
- )
532
- )
533
- fea_dim = 256 if version19 == "v1" else 768
534
- if if_f0_3:
535
- for _ in range(2):
536
- opt.append(
537
- "%s/logs/mute/0_gt_wavs/mute%s.wav|%s/logs/mute/3_feature%s/mute.npy|%s/logs/mute/2a_f0/mute.wav.npy|%s/logs/mute/2b-f0nsf/mute.wav.npy|%s"
538
- % (now_dir, sr2, now_dir, fea_dim, now_dir, now_dir, spk_id5)
539
- )
540
- else:
541
- for _ in range(2):
542
- opt.append(
543
- "%s/logs/mute/0_gt_wavs/mute%s.wav|%s/logs/mute/3_feature%s/mute.npy|%s"
544
- % (now_dir, sr2, now_dir, fea_dim, spk_id5)
545
- )
546
- shuffle(opt)
547
- with open("%s/filelist.txt" % exp_dir, "w") as f:
548
- f.write("\n".join(opt))
549
- logger.debug("Write filelist done")
550
- # 生成config#无需生成config
551
- # cmd = python_cmd + " train_nsf_sim_cache_sid_load_pretrain.py -e mi-test -sr 40k -f0 1 -bs 4 -g 0 -te 10 -se 5 -pg pretrained/f0G40k.pth -pd pretrained/f0D40k.pth -l 1 -c 0"
552
- logger.info("Use gpus: %s", str(gpus16))
553
- if pretrained_G14 == "":
554
- logger.info("No pretrained Generator")
555
- if pretrained_D15 == "":
556
- logger.info("No pretrained Discriminator")
557
- if version19 == "v1" or sr2 == "40k":
558
- config_path = "v1/%s.json" % sr2
559
- else:
560
- config_path = "v2/%s.json" % sr2
561
- config_save_path = os.path.join(exp_dir, "config.json")
562
- if not pathlib.Path(config_save_path).exists():
563
- with open(config_save_path, "w", encoding="utf-8") as f:
564
- json.dump(
565
- config.json_config[config_path],
566
- f,
567
- ensure_ascii=False,
568
- indent=4,
569
- sort_keys=True,
570
- )
571
- f.write("\n")
572
- if gpus16:
573
- cmd = (
574
- '"%s" infer/modules/train/train.py -e "%s" -sr %s -f0 %s -bs %s -g %s -te %s -se %s %s %s -l %s -c %s -sw %s -v %s'
575
- % (
576
- config.python_cmd,
577
- exp_dir1,
578
- sr2,
579
- 1 if if_f0_3 else 0,
580
- batch_size12,
581
- gpus16,
582
- total_epoch11,
583
- save_epoch10,
584
- "-pg %s" % pretrained_G14 if pretrained_G14 != "" else "",
585
- "-pd %s" % pretrained_D15 if pretrained_D15 != "" else "",
586
- 1 if if_save_latest13 == i18n("是") else 0,
587
- 1 if if_cache_gpu17 == i18n("是") else 0,
588
- 1 if if_save_every_weights18 == i18n("是") else 0,
589
- version19,
590
- )
591
- )
592
- else:
593
- cmd = (
594
- '"%s" infer/modules/train/train.py -e "%s" -sr %s -f0 %s -bs %s -te %s -se %s %s %s -l %s -c %s -sw %s -v %s'
595
- % (
596
- config.python_cmd,
597
- exp_dir1,
598
- sr2,
599
- 1 if if_f0_3 else 0,
600
- batch_size12,
601
- total_epoch11,
602
- save_epoch10,
603
- "-pg %s" % pretrained_G14 if pretrained_G14 != "" else "",
604
- "-pd %s" % pretrained_D15 if pretrained_D15 != "" else "",
605
- 1 if if_save_latest13 == i18n("是") else 0,
606
- 1 if if_cache_gpu17 == i18n("是") else 0,
607
- 1 if if_save_every_weights18 == i18n("是") else 0,
608
- version19,
609
- )
610
- )
611
- logger.info("Execute: " + cmd)
612
- p = Popen(cmd, shell=True, cwd=now_dir)
613
- p.wait()
614
- return "训练结束, 您可查看控制台训练日志或实验文件夹下的train.log"
615
-
616
-
617
- # but4.click(train_index, [exp_dir1], info3)
618
- def train_index(exp_dir1, version19):
619
- # exp_dir = "%s/logs/%s" % (now_dir, exp_dir1)
620
- exp_dir = "logs/%s" % (exp_dir1)
621
- os.makedirs(exp_dir, exist_ok=True)
622
- feature_dir = (
623
- "%s/3_feature256" % (exp_dir)
624
- if version19 == "v1"
625
- else "%s/3_feature768" % (exp_dir)
626
- )
627
- if not os.path.exists(feature_dir):
628
- return "请先进行特征提取!"
629
- listdir_res = list(os.listdir(feature_dir))
630
- if len(listdir_res) == 0:
631
- return "请先进行特征提取!"
632
- infos = []
633
- npys = []
634
- for name in sorted(listdir_res):
635
- phone = np.load("%s/%s" % (feature_dir, name))
636
- npys.append(phone)
637
- big_npy = np.concatenate(npys, 0)
638
- big_npy_idx = np.arange(big_npy.shape[0])
639
- np.random.shuffle(big_npy_idx)
640
- big_npy = big_npy[big_npy_idx]
641
- if big_npy.shape[0] > 2e5:
642
- infos.append("Trying doing kmeans %s shape to 10k centers." % big_npy.shape[0])
643
- yield "\n".join(infos)
644
- try:
645
- big_npy = (
646
- MiniBatchKMeans(
647
- n_clusters=10000,
648
- verbose=True,
649
- batch_size=256 * config.n_cpu,
650
- compute_labels=False,
651
- init="random",
652
- )
653
- .fit(big_npy)
654
- .cluster_centers_
655
- )
656
- except:
657
- info = traceback.format_exc()
658
- logger.info(info)
659
- infos.append(info)
660
- yield "\n".join(infos)
661
-
662
- np.save("%s/total_fea.npy" % exp_dir, big_npy)
663
- n_ivf = min(int(16 * np.sqrt(big_npy.shape[0])), big_npy.shape[0] // 39)
664
- infos.append("%s,%s" % (big_npy.shape, n_ivf))
665
- yield "\n".join(infos)
666
- index = faiss.index_factory(256 if version19 == "v1" else 768, "IVF%s,Flat" % n_ivf)
667
- # index = faiss.index_factory(256if version19=="v1"else 768, "IVF%s,PQ128x4fs,RFlat"%n_ivf)
668
- infos.append("training")
669
- yield "\n".join(infos)
670
- index_ivf = faiss.extract_index_ivf(index) #
671
- index_ivf.nprobe = 1
672
- index.train(big_npy)
673
- faiss.write_index(
674
- index,
675
- "%s/trained_IVF%s_Flat_nprobe_%s_%s_%s.index"
676
- % (exp_dir, n_ivf, index_ivf.nprobe, exp_dir1, version19),
677
- )
678
- infos.append("adding")
679
- yield "\n".join(infos)
680
- batch_size_add = 8192
681
- for i in range(0, big_npy.shape[0], batch_size_add):
682
- index.add(big_npy[i : i + batch_size_add])
683
- faiss.write_index(
684
- index,
685
- "%s/added_IVF%s_Flat_nprobe_%s_%s_%s.index"
686
- % (exp_dir, n_ivf, index_ivf.nprobe, exp_dir1, version19),
687
- )
688
- infos.append(
689
- "成功构建索引 added_IVF%s_Flat_nprobe_%s_%s_%s.index"
690
- % (n_ivf, index_ivf.nprobe, exp_dir1, version19)
691
- )
692
- try:
693
- link = os.link if platform.system() == "Windows" else os.symlink
694
- link(
695
- "%s/added_IVF%s_Flat_nprobe_%s_%s_%s.index"
696
- % (exp_dir, n_ivf, index_ivf.nprobe, exp_dir1, version19),
697
- "%s/%s_IVF%s_Flat_nprobe_%s_%s_%s.index"
698
- % (
699
- outside_index_root,
700
- exp_dir1,
701
- n_ivf,
702
- index_ivf.nprobe,
703
- exp_dir1,
704
- version19,
705
- ),
706
- )
707
- infos.append("链接索引到外部-%s" % (outside_index_root))
708
- except:
709
- infos.append("链接索引到外部-%s失败" % (outside_index_root))
710
-
711
- # faiss.write_index(index, '%s/added_IVF%s_Flat_FastScan_%s.index'%(exp_dir,n_ivf,version19))
712
- # infos.append("成功构建索引,added_IVF%s_Flat_FastScan_%s.index"%(n_ivf,version19))
713
- yield "\n".join(infos)
714
-
715
-
716
- # but5.click(train1key, [exp_dir1, sr2, if_f0_3, trainset_dir4, spk_id5, gpus6, np7, f0method8, save_epoch10, total_epoch11, batch_size12, if_save_latest13, pretrained_G14, pretrained_D15, gpus16, if_cache_gpu17], info3)
717
- def train1key(
718
- exp_dir1,
719
- sr2,
720
- if_f0_3,
721
- trainset_dir4,
722
- spk_id5,
723
- np7,
724
- f0method8,
725
- save_epoch10,
726
- total_epoch11,
727
- batch_size12,
728
- if_save_latest13,
729
- pretrained_G14,
730
- pretrained_D15,
731
- gpus16,
732
- if_cache_gpu17,
733
- if_save_every_weights18,
734
- version19,
735
- gpus_rmvpe,
736
- ):
737
- infos = []
738
-
739
- def get_info_str(strr):
740
- infos.append(strr)
741
- return "\n".join(infos)
742
-
743
- # step1:处理数据
744
- yield get_info_str(i18n("step1:正在处理数据"))
745
- [get_info_str(_) for _ in preprocess_dataset(trainset_dir4, exp_dir1, sr2, np7)]
746
-
747
- # step2a:提取音高
748
- yield get_info_str(i18n("step2:正在提取音高&正在提取特征"))
749
- [
750
- get_info_str(_)
751
- for _ in extract_f0_feature(
752
- gpus16, np7, f0method8, if_f0_3, exp_dir1, version19, gpus_rmvpe
753
- )
754
- ]
755
-
756
- # step3a:训练模型
757
- yield get_info_str(i18n("step3a:正在训练模型"))
758
- click_train(
759
- exp_dir1,
760
- sr2,
761
- if_f0_3,
762
- spk_id5,
763
- save_epoch10,
764
- total_epoch11,
765
- batch_size12,
766
- if_save_latest13,
767
- pretrained_G14,
768
- pretrained_D15,
769
- gpus16,
770
- if_cache_gpu17,
771
- if_save_every_weights18,
772
- version19,
773
- )
774
- yield get_info_str(
775
- i18n("训练结束, 您可查看控制台训练日志或实验文件夹下的train.log")
776
- )
777
-
778
- # step3b:训练索引
779
- [get_info_str(_) for _ in train_index(exp_dir1, version19)]
780
- yield get_info_str(i18n("全流程结束!"))
781
-
782
-
783
- # ckpt_path2.change(change_info_,[ckpt_path2],[sr__,if_f0__])
784
- def change_info_(ckpt_path):
785
- if not os.path.exists(ckpt_path.replace(os.path.basename(ckpt_path), "train.log")):
786
- return {"__type__": "update"}, {"__type__": "update"}, {"__type__": "update"}
787
- try:
788
- with open(
789
- ckpt_path.replace(os.path.basename(ckpt_path), "train.log"), "r"
790
- ) as f:
791
- info = eval(f.read().strip("\n").split("\n")[0].split("\t")[-1])
792
- sr, f0 = info["sample_rate"], info["if_f0"]
793
- version = "v2" if ("version" in info and info["version"] == "v2") else "v1"
794
- return sr, str(f0), version
795
- except:
796
- traceback.print_exc()
797
- return {"__type__": "update"}, {"__type__": "update"}, {"__type__": "update"}
798
-
799
-
800
- F0GPUVisible = config.dml == False
801
-
802
-
803
- def change_f0_method(f0method8):
804
- if f0method8 == "rmvpe_gpu":
805
- visible = F0GPUVisible
806
- else:
807
- visible = False
808
- return {"visible": visible, "__type__": "update"}
809
-
810
-
811
- with gr.Blocks(title="NEX RVC WebUI", theme="nevreal/blues") as app:
812
- gr.Markdown("# NEX RVC WebUI")
813
- gr.Markdown(
814
- value=i18n(
815
- "本软件以MIT协议开源, 作者不对软件具备任何控制力, 使用软件者、传播软件导出的声音者自负全责. <br>如不认可该条款, 则不能使用或引用软件包内任何代码和文件. 详见根目录<b>LICENSE</b>."
816
- )
817
- )
818
- with gr.Tabs():
819
- with gr.TabItem(i18n("模型推理")):
820
- with gr.Row():
821
- sid0 = gr.Dropdown(label=i18n("推理音色"), choices=sorted(names))
822
- with gr.Column():
823
- refresh_button = gr.Button(
824
- i18n("刷新音色列表和索引路径"), variant="primary"
825
- )
826
- with gr.Row():
827
- clean_button = gr.Button(i18n("卸载音色省显存"), variant="primary")
828
- spk_item = gr.Slider(
829
- minimum=0,
830
- maximum=2333,
831
- step=1,
832
- label=i18n("请选择说话人id"),
833
- value=0,
834
- visible=False,
835
- interactive=False,
836
- )
837
- with gr.Column():
838
- with gr.Row():
839
- vc_transform0 = gr.Number(
840
- label=i18n("变调(整数, 半音数量, 升八度12降八度-12)"),
841
- value=0,
842
- )
843
- f0methodt = gr.Radio(
844
- label=(
845
- "select your f0 method. crepe and rmvpe"
846
- ),
847
- choices=(
848
- ["crepe", "rmvpe"]
849
- ),
850
- value="rmvpe",
851
- interactive=True,
852
- )
853
- clean_button.click(
854
- fn=clean, inputs=[], outputs=[sid0], api_name="infer_clean"
855
- )
856
- with gr.TabItem(i18n("单次推理")):
857
- with gr.Group():
858
- with gr.Row():
859
- with gr.Column():
860
- input_audio0 = gr.Textbox(
861
- label=i18n(
862
- "输入待处理音频文件路径(默认是正确格式示例)"
863
- ),
864
- placeholder="C:\\Users\\Desktop\\audio_example.wav",
865
- )
866
- file_index1 = gr.Textbox(
867
- label=i18n(
868
- "特征检索库文件路径,为空则使用下拉的选择结果"
869
- ),
870
- placeholder="C:\\Users\\Desktop\\model_example.index",
871
- interactive=True,
872
- )
873
- file_index2 = gr.Dropdown(
874
- label=i18n("自动检测index路径,下拉式选择(dropdown)"),
875
- choices=sorted(index_paths),
876
- interactive=True,
877
- )
878
-
879
-
880
- with gr.Column():
881
- resample_sr0 = gr.Slider(
882
- minimum=0,
883
- maximum=48000,
884
- label=i18n("后处理重采样至最终采样率,0为不进行重采样"),
885
- value=0,
886
- step=1,
887
- interactive=True,
888
- )
889
- rms_mix_rate0 = gr.Slider(
890
- minimum=0,
891
- maximum=1,
892
- label=i18n(
893
- "输入源音量包络替换输出音量包络融合比例,越靠近1越使用输出包络"
894
- ),
895
- value=0.25,
896
- interactive=True,
897
- )
898
- protect0 = gr.Slider(
899
- minimum=0,
900
- maximum=0.5,
901
- label=i18n(
902
- "保护清辅音和呼吸声,防止电音撕裂等artifact,拉满0.5不开启,调低加大保护力度但可能降低索引效果"
903
- ),
904
- value=0.33,
905
- step=0.01,
906
- interactive=True,
907
- )
908
- filter_radius0 = gr.Slider(
909
- minimum=0,
910
- maximum=7,
911
- label=i18n(
912
- ">=3则使用对harvest音高识别的结果使用中值滤波,数值为滤波半径,使用可以削弱哑音"
913
- ),
914
- value=3,
915
- step=1,
916
- interactive=True,
917
- )
918
- index_rate1 = gr.Slider(
919
- minimum=0,
920
- maximum=1,
921
- label=i18n("检索特征占比"),
922
- value=0.75,
923
- interactive=True,
924
- )
925
- f0_file = gr.File(
926
- label=i18n(
927
- "F0曲线文件, 可选, 一行一个音高, 代替默认F0及升降调"
928
- ),
929
- visible=False,
930
- )
931
-
932
- refresh_button.click(
933
- fn=change_choices,
934
- inputs=[],
935
- outputs=[sid0, file_index2],
936
- api_name="infer_refresh",
937
- )
938
- # file_big_npy1 = gr.Textbox(
939
- # label=i18n("特征文件路径"),
940
- # value="E:\\codes\py39\\vits_vc_gpu_train\\logs\\mi-test-1key\\total_fea.npy",
941
- # interactive=True,
942
- # )
943
- with gr.Group():
944
- with gr.Column():
945
- but0 = gr.Button(i18n("转换"), variant="primary")
946
- with gr.Row():
947
- vc_output1 = gr.Textbox(label=i18n("输出信息"))
948
- with gr.Row():
949
- vc_output2 = gr.Audio(
950
- label=i18n("输出音频(右下角三个点,点了可以下载)")
951
- )
952
-
953
- but0.click(
954
- vc.vc_single,
955
- [
956
- spk_item,
957
- input_audio0,
958
- vc_transform0,
959
- f0_file,
960
- f0methodt,
961
- file_index1,
962
- file_index2,
963
- # file_big_npy1,
964
- index_rate1,
965
- filter_radius0,
966
- resample_sr0,
967
- rms_mix_rate0,
968
- protect0,
969
- ],
970
- [vc_output1, vc_output2],
971
- api_name="infer_convert",
972
- )
973
- with gr.TabItem(i18n("批量推理")):
974
- gr.Markdown(
975
- value=i18n(
976
- "批量转换, 输入待转换音频文件夹, 或上传多个音频文件, 在指定文件夹(默认opt)下输出转换的音频. "
977
- )
978
- )
979
- with gr.Row():
980
- with gr.Column():
981
- vc_transform1 = gr.Number(
982
- label=i18n("变调(整数, 半音数量, 升八度12降八度-12)"),
983
- value=0,
984
- )
985
- opt_input = gr.Textbox(
986
- label=i18n("指定输出文件夹"), value="opt"
987
- )
988
- file_index3 = gr.Textbox(
989
- label=i18n("特征检索库文件路径,为空则使用下拉的选择结果"),
990
- value="",
991
- interactive=True,
992
- )
993
- file_index4 = gr.Dropdown(
994
- label=i18n("自动检测index路径,下拉式选择(dropdown)"),
995
- choices=sorted(index_paths),
996
- interactive=True,
997
- )
998
-
999
- format1 = gr.Radio(
1000
- label=i18n("导出文件格式"),
1001
- choices=["wav", "flac", "mp3", "m4a"],
1002
- value="wav",
1003
- interactive=True,
1004
- )
1005
-
1006
- refresh_button.click(
1007
- fn=lambda: change_choices()[1],
1008
- inputs=[],
1009
- outputs=file_index4,
1010
- api_name="infer_refresh_batch",
1011
- )
1012
- # file_big_npy2 = gr.Textbox(
1013
- # label=i18n("特征文件路径"),
1014
- # value="E:\\codes\\py39\\vits_vc_gpu_train\\logs\\mi-test-1key\\total_fea.npy",
1015
- # interactive=True,
1016
- # )
1017
-
1018
- with gr.Column():
1019
- resample_sr1 = gr.Slider(
1020
- minimum=0,
1021
- maximum=48000,
1022
- label=i18n("后处理重采样至最终采样率,0为不进行重采样"),
1023
- value=0,
1024
- step=1,
1025
- interactive=True,
1026
- )
1027
- rms_mix_rate1 = gr.Slider(
1028
- minimum=0,
1029
- maximum=1,
1030
- label=i18n(
1031
- "输入源音量包络替换输出音量包络融合比例,越靠近1越使用输出包络"
1032
- ),
1033
- value=1,
1034
- interactive=True,
1035
- )
1036
- protect1 = gr.Slider(
1037
- minimum=0,
1038
- maximum=0.5,
1039
- label=i18n(
1040
- "保护清辅音和呼吸声,防止电音撕裂等artifact,拉满0.5不开启,调低加大保护力度但可能降低索引效果"
1041
- ),
1042
- value=0.33,
1043
- step=0.01,
1044
- interactive=True,
1045
- )
1046
- filter_radius1 = gr.Slider(
1047
- minimum=0,
1048
- maximum=7,
1049
- label=i18n(
1050
- ">=3则使用对harvest音高识别的结果使用中值滤波,数值为滤波半径,使用可以削弱哑音"
1051
- ),
1052
- value=3,
1053
- step=1,
1054
- interactive=True,
1055
- )
1056
- index_rate2 = gr.Slider(
1057
- minimum=0,
1058
- maximum=1,
1059
- label=i18n("检索特征占比"),
1060
- value=1,
1061
- interactive=True,
1062
- )
1063
- with gr.Row():
1064
- dir_input = gr.Textbox(
1065
- label=i18n(
1066
- "输入待处理音频文件夹路径(去文件管理器地址栏拷就行了)"
1067
- ),
1068
- placeholder="C:\\Users\\Desktop\\input_vocal_dir",
1069
- )
1070
- inputs = gr.File(
1071
- file_count="multiple",
1072
- label=i18n("也可批量输入音频文件, 二选一, 优先读文件夹"),
1073
- )
1074
-
1075
- with gr.Row():
1076
- but1 = gr.Button(i18n("转换"), variant="primary")
1077
- vc_output3 = gr.Textbox(label=i18n("输出信息"))
1078
-
1079
- but1.click(
1080
- vc.vc_multi,
1081
- [
1082
- spk_item,
1083
- dir_input,
1084
- opt_input,
1085
- inputs,
1086
- vc_transform1,
1087
- f0methodt,
1088
- file_index3,
1089
- file_index4,
1090
- # file_big_npy2,
1091
- index_rate2,
1092
- filter_radius1,
1093
- resample_sr1,
1094
- rms_mix_rate1,
1095
- protect1,
1096
- format1,
1097
- ],
1098
- [vc_output3],
1099
- api_name="infer_convert_batch",
1100
- )
1101
- sid0.change(
1102
- fn=vc.get_vc,
1103
- inputs=[sid0, protect0, protect1],
1104
- outputs=[spk_item, protect0, protect1, file_index2, file_index4],
1105
- api_name="infer_change_voice",
1106
- )
1107
- with gr.TabItem(i18n("训练")):
1108
- gr.Markdown(
1109
- value=i18n(
1110
- "step1: 填写实验配置. 实验数据放在logs下, 每个实验一个文件夹, 需手工输入实验名路径, 内含实验配置, 日志, 训练得到的模型文件. "
1111
- )
1112
- )
1113
- with gr.Row():
1114
- exp_dir1 = gr.Textbox(label=i18n("输入实验名"), value="mi-test")
1115
- sr2 = gr.Radio(
1116
- label=i18n("目标采样率"),
1117
- choices=["40k", "48k"],
1118
- value="40k",
1119
- interactive=True,
1120
- )
1121
- if_f0_3 = gr.Radio(
1122
- label=i18n("模型是否带音高指导(唱歌一定要, 语音可以不要)"),
1123
- choices=[True, False],
1124
- value=True,
1125
- interactive=True,
1126
- )
1127
- version19 = gr.Radio(
1128
- label=i18n("版本"),
1129
- choices=["v1", "v2"],
1130
- value="v2",
1131
- interactive=True,
1132
- visible=True,
1133
- )
1134
- np7 = gr.Slider(
1135
- minimum=0,
1136
- maximum=config.n_cpu,
1137
- step=1,
1138
- label=i18n("提取音高和处理数据使用的CPU进程数"),
1139
- value=int(np.ceil(config.n_cpu / 1.5)),
1140
- interactive=True,
1141
- )
1142
- with gr.Group(): # 暂时单人的, 后面支持最多4人的#数据处理
1143
- gr.Markdown(
1144
- value=i18n(
1145
- "step2a: 自动遍历训练文件夹下所有可解码成音频的文件并进行切片归一化, 在实验目录下生成2个wav文件夹; 暂时只支持单人训练. "
1146
- )
1147
- )
1148
- with gr.Row():
1149
- trainset_dir4 = gr.Textbox(
1150
- label=i18n("输入训练文件夹路径"),
1151
- value=i18n("E:\\语音音频+标注\\米津玄师\\src"),
1152
- )
1153
- spk_id5 = gr.Slider(
1154
- minimum=0,
1155
- maximum=4,
1156
- step=1,
1157
- label=i18n("请指定说话人id"),
1158
- value=0,
1159
- interactive=True,
1160
- )
1161
-
1162
-
1163
- with gr.Group():
1164
- gr.Markdown(
1165
- value=i18n(
1166
- "step2b: 使用CPU提取音高(如果模型带音高), 使用GPU提取特征(选择卡号)"
1167
- )
1168
- )
1169
- with gr.Row():
1170
- with gr.Column():
1171
- gpus6 = gr.Textbox(
1172
- label=i18n(
1173
- "以-分隔输入使用的卡号, 例如 0-1-2 使用卡0和卡1和卡2"
1174
- ),
1175
- value=gpus,
1176
- interactive=True,
1177
- visible=F0GPUVisible,
1178
- )
1179
- gpu_info9 = gr.Textbox(
1180
- label=i18n("显卡信息"), value=gpu_info, visible=F0GPUVisible
1181
- )
1182
- with gr.Column():
1183
- f0method8 = gr.Radio(
1184
- label=i18n(
1185
- "选择音高提取算法:输入歌声可用pm提速,高质量语音但CPU差可用dio提速,harvest质量更好但慢,rmvpe效果最好且微吃CPU/GPU"
1186
- ),
1187
- choices=["pm", "harvest", "dio", "rmvpe", "rmvpe_gpu"],
1188
- value="rmvpe_gpu",
1189
- interactive=True,
1190
- )
1191
- gpus_rmvpe = gr.Textbox(
1192
- label=i18n(
1193
- "rmvpe卡号配置:以-分隔输入使用的不同进程卡号,例如0-0-1使用在卡0上跑2个进程并在卡1上跑1个进程"
1194
- ),
1195
- value="%s-%s" % (gpus, gpus),
1196
- interactive=True,
1197
- visible=F0GPUVisible,
1198
- )
1199
-
1200
- f0method8.change(
1201
- fn=change_f0_method,
1202
- inputs=[f0method8],
1203
- outputs=[gpus_rmvpe],
1204
- )
1205
-
1206
- with gr.Group():
1207
- gr.Markdown(value=i18n("step3: 填写训练设置, 开始训练模型和索引"))
1208
- with gr.Row():
1209
- save_epoch10 = gr.Slider(
1210
- minimum=1,
1211
- maximum=50,
1212
- step=1,
1213
- label=i18n("保存频率save_every_epoch"),
1214
- value=5,
1215
- interactive=True,
1216
- )
1217
- total_epoch11 = gr.Slider(
1218
- minimum=2,
1219
- maximum=1000,
1220
- step=1,
1221
- label=i18n("总训练轮数total_epoch"),
1222
- value=20,
1223
- interactive=True,
1224
- )
1225
- batch_size12 = gr.Slider(
1226
- minimum=1,
1227
- maximum=40,
1228
- step=1,
1229
- label=i18n("每张显卡的batch_size"),
1230
- value=default_batch_size,
1231
- interactive=True,
1232
- )
1233
- if_save_latest13 = gr.Radio(
1234
- label=i18n("是否仅保存最新的ckpt文件以节省硬盘空间"),
1235
- choices=[i18n("是"), i18n("否")],
1236
- value=i18n("否"),
1237
- interactive=True,
1238
- )
1239
- if_cache_gpu17 = gr.Radio(
1240
- label=i18n(
1241
- "是否缓存所有训练集至显存. 10min以下小数据可缓存以加速训练, 大数据缓存会炸显存也加不了多少速"
1242
- ),
1243
- choices=[i18n("是"), i18n("否")],
1244
- value=i18n("否"),
1245
- interactive=True,
1246
- )
1247
- if_save_every_weights18 = gr.Radio(
1248
- label=i18n(
1249
- "是否在每次保存时间点将最终小模型保存至weights文件夹"
1250
- ),
1251
- choices=[i18n("是"), i18n("否")],
1252
- value=i18n("否"),
1253
- interactive=True,
1254
- )
1255
- with gr.Row():
1256
- pretrained_G14 = gr.Textbox(
1257
- label=i18n("加载预训练底模G路径"),
1258
- value="assets/pretrained_v2/f0G40k.pth",
1259
- interactive=True,
1260
- )
1261
- pretrained_D15 = gr.Textbox(
1262
- label=i18n("加载预训练底模D路径"),
1263
- value="assets/pretrained_v2/f0D40k.pth",
1264
- interactive=True,
1265
- )
1266
- sr2.change(
1267
- change_sr2,
1268
- [sr2, if_f0_3, version19],
1269
- [pretrained_G14, pretrained_D15],
1270
- )
1271
- version19.change(
1272
- change_version19,
1273
- [sr2, if_f0_3, version19],
1274
- [pretrained_G14, pretrained_D15, sr2],
1275
- )
1276
- if_f0_3.change(
1277
- change_f0,
1278
- [if_f0_3, sr2, version19],
1279
- [f0method8, gpus_rmvpe, pretrained_G14, pretrained_D15],
1280
- )
1281
- gpus16 = gr.Textbox(
1282
- label=i18n(
1283
- "以-分隔输入使用的卡号, 例如 0-1-2 使用卡0和卡1和卡2"
1284
- ),
1285
- value=gpus,
1286
- interactive=True,
1287
- )
1288
- but1 = gr.Button(i18n("处理数据"), variant="primary")
1289
- info1 = gr.Textbox(label=i18n("输出信息"), value="")
1290
- but2 = gr.Button(i18n("特征提取"), variant="primary")
1291
- info2 = gr.Textbox(label=i18n("输出信息"), value="", max_lines=8)
1292
- but3 = gr.Button(i18n("训练模型"), variant="primary")
1293
- but4 = gr.Button(i18n("训练特征索引"), variant="primary")
1294
- but5 = gr.Button(i18n("一键训练"), variant="primary")
1295
- info3 = gr.Textbox(label=i18n("输出信息"), value="", max_lines=10)
1296
- but1.click(
1297
- preprocess_dataset,
1298
- [trainset_dir4, exp_dir1, sr2, np7],
1299
- [info1],
1300
- api_name="train_preprocess",
1301
- )
1302
- but2.click(
1303
- extract_f0_feature,
1304
- [
1305
- gpus6,
1306
- np7,
1307
- f0method8,
1308
- if_f0_3,
1309
- exp_dir1,
1310
- version19,
1311
- gpus_rmvpe,
1312
- ],
1313
- [info2],
1314
- api_name="train_extract_f0_feature",
1315
- )
1316
- but3.click(
1317
- click_train,
1318
- [
1319
- exp_dir1,
1320
- sr2,
1321
- if_f0_3,
1322
- spk_id5,
1323
- save_epoch10,
1324
- total_epoch11,
1325
- batch_size12,
1326
- if_save_latest13,
1327
- pretrained_G14,
1328
- pretrained_D15,
1329
- gpus16,
1330
- if_cache_gpu17,
1331
- if_save_every_weights18,
1332
- version19,
1333
- ],
1334
- info3,
1335
- api_name="train_start",
1336
- )
1337
- but4.click(train_index, [exp_dir1, version19], info3)
1338
- but5.click(
1339
- train1key,
1340
- [
1341
- exp_dir1,
1342
- sr2,
1343
- if_f0_3,
1344
- trainset_dir4,
1345
- spk_id5,
1346
- np7,
1347
- f0method8,
1348
- save_epoch10,
1349
- total_epoch11,
1350
- batch_size12,
1351
- if_save_latest13,
1352
- pretrained_G14,
1353
- pretrained_D15,
1354
- gpus16,
1355
- if_cache_gpu17,
1356
- if_save_every_weights18,
1357
- version19,
1358
- gpus_rmvpe,
1359
- ],
1360
- info3,
1361
- api_name="train_start_all",
1362
- )
1363
-
1364
-
1365
-
1366
- tab_faq = i18n("常见问题解答")
1367
- with gr.TabItem(tab_faq):
1368
- with open("docs/en/faq_en.md", "r", encoding="utf8") as f:
1369
- info = f.read()
1370
- gr.Markdown(value=info)
1371
-
1372
-
1373
-
1374
- app.launch(debug=True)