PhoenixStormJr commited on
Commit
683098e
·
verified ·
1 Parent(s): 0bd1b69

Update infer-web.py

Browse files
Files changed (1) hide show
  1. infer-web.py +194 -194
infer-web.py CHANGED
@@ -58,7 +58,7 @@ torch.manual_seed(114514)
58
  config = Config()
59
  i18n = I18nAuto()
60
  i18n.print()
61
- # 判断是否有能用来训练和加速推理的N
62
  ngpu = torch.cuda.device_count()
63
  gpu_infos = []
64
  mem = []
@@ -91,7 +91,7 @@ if torch.cuda.is_available() or ngpu != 0:
91
  ]
92
  ):
93
  # A10#A100#V100#A40#P40#M40#K80#A4500
94
- if_gpu_ok = True # 至少有一张能用的N卡
95
  gpu_infos.append("%s\t%s" % (i, gpu_name))
96
  mem.append(
97
  int(
@@ -106,7 +106,7 @@ if if_gpu_ok and len(gpu_infos) > 0:
106
  gpu_info = "\n".join(gpu_infos)
107
  default_batch_size = min(mem) // 2
108
  else:
109
- gpu_info = i18n("很遗憾您这没有能用的显卡来支持您训练")
110
  default_batch_size = 1
111
  gpus = "-".join([i[0] for i in gpu_infos])
112
 
@@ -197,7 +197,7 @@ def vc_single(
197
  )
198
  if file_index != ""
199
  else file_index2
200
- ) # 防止小白写错,自动帮他替换掉
201
  # file_big_npy = (
202
  # file_big_npy.strip(" ").strip('"').strip("\n").strip('"').strip(" ")
203
  # )
@@ -263,7 +263,7 @@ def vc_multi(
263
  try:
264
  dir_path = (
265
  dir_path.strip(" ").strip('"').strip("\n").strip('"').strip(" ")
266
- ) # 防止小白拷路径头尾带了空格和"和回车
267
  opt_root = opt_root.strip(" ").strip('"').strip("\n").strip('"').strip(" ")
268
  os.makedirs(opt_root, exist_ok=True)
269
  try:
@@ -402,18 +402,18 @@ def uvr(model_name, inp_root, save_root_vocal, paths, save_root_ins, agg, format
402
  yield "\n".join(infos)
403
 
404
 
405
- # 一个选项卡全局只能有一个音色
406
  def get_vc(sid, to_return_protect0, to_return_protect1):
407
  global n_spk, tgt_sr, net_g, vc, cpt, version
408
  if sid == "" or sid == []:
409
  global hubert_model
410
- if hubert_model is not None: # 考虑到轮询, 需要加个判断看是否 sid 是由有模型切换到无模型的
411
  print("clean_empty_cache")
412
  del net_g, n_spk, vc, hubert_model, tgt_sr # ,cpt
413
  hubert_model = net_g = n_spk = vc = hubert_model = tgt_sr = None
414
  if torch.cuda.is_available():
415
  torch.cuda.empty_cache()
416
- ###楼下不这么折腾清理不干净
417
  if_f0 = cpt.get("f0", 1)
418
  version = cpt.get("version", "v1")
419
  if version == "v1":
@@ -523,8 +523,8 @@ def if_done(done, p):
523
 
524
  def if_done_multi(done, ps):
525
  while 1:
526
- # poll==None代表进程未结束
527
- # 只要有一个进程未结束都不停
528
  flag = 1
529
  for p in ps:
530
  if p.poll() is None:
@@ -549,7 +549,7 @@ def preprocess_dataset(trainset_dir, exp_dir, sr, n_p):
549
  )
550
  print(cmd)
551
  p = Popen(cmd, shell=True) # , stdin=PIPE, stdout=PIPE,stderr=PIPE,cwd=now_dir
552
- ###煞笔gr, popen read都非得全跑完了再一次性读取, 不用gr就正常读一句输出一句;只能额外弄出一个文本流定时读
553
  done = [False]
554
  threading.Thread(
555
  target=if_done,
@@ -586,7 +586,7 @@ def extract_f0_feature(gpus, n_p, f0method, if_f0, exp_dir, version19, echl):
586
  )
587
  print(cmd)
588
  p = Popen(cmd, shell=True, cwd=now_dir) # , stdin=PIPE, stdout=PIPE,stderr=PIPE
589
- ###煞笔gr, popen read都非得全跑完了再一次性读取, 不用gr就正常读一句输出一句;只能额外弄出一个文本流定时读
590
  done = [False]
591
  threading.Thread(
592
  target=if_done,
@@ -607,7 +607,7 @@ def extract_f0_feature(gpus, n_p, f0method, if_f0, exp_dir, version19, echl):
607
  log = f.read()
608
  print(log)
609
  yield log
610
- ####对不同part分别开多进程
611
  """
612
  n_part=int(sys.argv[1])
613
  i_part=int(sys.argv[2])
@@ -636,7 +636,7 @@ def extract_f0_feature(gpus, n_p, f0method, if_f0, exp_dir, version19, echl):
636
  cmd, shell=True, cwd=now_dir
637
  ) # , shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE, cwd=now_dir
638
  ps.append(p)
639
- ###煞笔gr, popen read都非得全跑完了再一次性读取, 不用gr就正常读一句输出一句;只能额外弄出一个文本流定时读
640
  done = [False]
641
  threading.Thread(
642
  target=if_done_multi,
@@ -779,7 +779,7 @@ def click_train(
779
  if_save_every_weights18,
780
  version19,
781
  ):
782
- # 生成filelist
783
  exp_dir = "%s/logs/%s" % (now_dir, exp_dir1)
784
  os.makedirs(exp_dir, exist_ok=True)
785
  gt_wavs_dir = "%s/0_gt_wavs" % (exp_dir)
@@ -846,7 +846,7 @@ def click_train(
846
  with open("%s/filelist.txt" % exp_dir, "w") as f:
847
  f.write("\n".join(opt))
848
  print("write filelist done")
849
- # 生成config#无需生成config
850
  # 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"
851
  print("use gpus:", gpus16)
852
  if pretrained_G14 == "":
@@ -867,9 +867,9 @@ def click_train(
867
  save_epoch10,
868
  "-pg %s" % pretrained_G14 if pretrained_G14 != "" else "",
869
  "-pd %s" % pretrained_D15 if pretrained_D15 != "" else "",
870
- 1 if if_save_latest13 == i18n("") else 0,
871
- 1 if if_cache_gpu17 == i18n("") else 0,
872
- 1 if if_save_every_weights18 == i18n("") else 0,
873
  version19,
874
  )
875
  )
@@ -886,16 +886,16 @@ def click_train(
886
  save_epoch10,
887
  "-pg %s" % pretrained_G14 if pretrained_G14 != "" else "\b",
888
  "-pd %s" % pretrained_D15 if pretrained_D15 != "" else "\b",
889
- 1 if if_save_latest13 == i18n("") else 0,
890
- 1 if if_cache_gpu17 == i18n("") else 0,
891
- 1 if if_save_every_weights18 == i18n("") else 0,
892
  version19,
893
  )
894
  )
895
  print(cmd)
896
  p = Popen(cmd, shell=True, cwd=now_dir)
897
  p.wait()
898
- return "训练结束, 您可查看控制台训练日志或实验文件夹下的train.log"
899
 
900
 
901
  # but4.click(train_index, [exp_dir1], info3)
@@ -908,10 +908,10 @@ def train_index(exp_dir1, version19):
908
  else "%s/3_feature768" % (exp_dir)
909
  )
910
  if not os.path.exists(feature_dir):
911
- return "请先进行特征提取!"
912
  listdir_res = list(os.listdir(feature_dir))
913
  if len(listdir_res) == 0:
914
- return "请先进行特征提取!"
915
  infos = []
916
  npys = []
917
  for name in sorted(listdir_res):
@@ -971,11 +971,11 @@ def train_index(exp_dir1, version19):
971
  % (exp_dir, n_ivf, index_ivf.nprobe, exp_dir1, version19),
972
  )
973
  infos.append(
974
- "成功构建索引,added_IVF%s_Flat_nprobe_%s_%s_%s.index"
975
  % (n_ivf, index_ivf.nprobe, exp_dir1, version19)
976
  )
977
  # faiss.write_index(index, '%s/added_IVF%s_Flat_FastScan_%s.index'%(exp_dir,n_ivf,version19))
978
- # infos.append("成功构建索引,added_IVF%s_Flat_FastScan_%s.index"%(n_ivf,version19))
979
  yield "\n".join(infos)
980
 
981
 
@@ -1017,7 +1017,7 @@ def train1key(
1017
  )
1018
 
1019
  os.makedirs(model_log_dir, exist_ok=True)
1020
- #########step1:处理数据
1021
  open(preprocess_log_path, "w").close()
1022
  cmd = (
1023
  config.python_cmd
@@ -1025,16 +1025,16 @@ def train1key(
1025
  % (trainset_dir4, sr_dict[sr2], np7, model_log_dir)
1026
  + str(config.noparallel)
1027
  )
1028
- yield get_info_str(i18n("step1:正在处理数据"))
1029
  yield get_info_str(cmd)
1030
  p = Popen(cmd, shell=True)
1031
  p.wait()
1032
  with open(preprocess_log_path, "r") as f:
1033
  print(f.read())
1034
- #########step2a:提取音高
1035
  open(extract_f0_feature_log_path, "w")
1036
  if if_f0_3:
1037
- yield get_info_str("step2a:正在提取音高")
1038
  cmd = config.python_cmd + " extract_f0_print.py %s %s %s %s" % (
1039
  model_log_dir,
1040
  np7,
@@ -1047,9 +1047,9 @@ def train1key(
1047
  with open(extract_f0_feature_log_path, "r") as f:
1048
  print(f.read())
1049
  else:
1050
- yield get_info_str(i18n("step2a:无需提取音高"))
1051
- #######step2b:提取特征
1052
- yield get_info_str(i18n("step2b:正在提取特征"))
1053
  gpus = gpus16.split("-")
1054
  leng = len(gpus)
1055
  ps = []
@@ -1071,9 +1071,9 @@ def train1key(
1071
  p.wait()
1072
  with open(extract_f0_feature_log_path, "r") as f:
1073
  print(f.read())
1074
- #######step3a:训练模型
1075
- yield get_info_str(i18n("step3a:正在训练模型"))
1076
- # 生成filelist
1077
  if if_f0_3:
1078
  f0_dir = "%s/2a_f0" % model_log_dir
1079
  f0nsf_dir = "%s/2b-f0nsf" % model_log_dir
@@ -1174,8 +1174,8 @@ def train1key(
1174
  yield get_info_str(cmd)
1175
  p = Popen(cmd, shell=True, cwd=now_dir)
1176
  p.wait()
1177
- yield get_info_str(i18n("训练结束, 您可查看控制台训练日志或实验文件夹下的train.log"))
1178
- #######step3b:训练索引
1179
  npys = []
1180
  listdir_res = list(os.listdir(feature_dir))
1181
  for name in sorted(listdir_res):
@@ -1234,10 +1234,10 @@ def train1key(
1234
  % (model_log_dir, n_ivf, index_ivf.nprobe, exp_dir1, version19),
1235
  )
1236
  yield get_info_str(
1237
- "成功构建索引, added_IVF%s_Flat_nprobe_%s_%s_%s.index"
1238
  % (n_ivf, index_ivf.nprobe, exp_dir1, version19)
1239
  )
1240
- yield get_info_str(i18n("全流程结束!"))
1241
 
1242
 
1243
  # ckpt_path2.change(change_info_,[ckpt_path2],[sr__,if_f0__])
@@ -1263,24 +1263,24 @@ def export_onnx(ModelPath, ExportedPath):
1263
  vec_channels = 256 if cpt.get("version", "v1") == "v1" else 768
1264
 
1265
  test_phone = torch.rand(1, 200, vec_channels) # hidden unit
1266
- test_phone_lengths = torch.tensor([200]).long() # hidden unit 长度(貌似没啥用)
1267
- test_pitch = torch.randint(size=(1, 200), low=5, high=255) # 基频(单位赫兹)
1268
- test_pitchf = torch.rand(1, 200) # nsf基频
1269
- test_ds = torch.LongTensor([0]) # 说话人ID
1270
- test_rnd = torch.rand(1, 192, 200) # 噪声(加入随机因子)
1271
 
1272
- device = "cpu" # 导出时设备(不影响使用模型)
1273
 
1274
 
1275
  net_g = SynthesizerTrnMsNSFsidM(
1276
  *cpt["config"], is_half=False, version=cpt.get("version", "v1")
1277
- ) # fp32导出(C++要支持fp16必须手动将内存重新排列所以暂时不用fp16
1278
  net_g.load_state_dict(cpt["weight"], strict=False)
1279
  input_names = ["phone", "phone_lengths", "pitch", "pitchf", "ds", "rnd"]
1280
  output_names = [
1281
  "audio",
1282
  ]
1283
- # net_g.construct_spkmixmap(n_speaker) 多角色混合轨道导出
1284
  torch.onnx.export(
1285
  net_g,
1286
  (
@@ -1421,9 +1421,9 @@ def cli_train(com):
1421
  total_epoch = int(com[5]) # 10000
1422
  batch_size = int(com[6])
1423
  gpu_card_slot_numbers = com[7]
1424
- if_save_latest = i18n("") if (int(com[8]) == 1) else i18n("")
1425
- if_cache_gpu = i18n("") if (int(com[9]) == 1) else i18n("")
1426
- if_save_every_weight = i18n("") if (int(com[10]) == 1) else i18n("")
1427
  version = com[11]
1428
 
1429
  pretrained_base = "pretrained/" if version == "v1" else "pretrained_v2/"
@@ -1621,11 +1621,11 @@ with gr.Blocks(theme=gr.themes.Soft()) as app:
1621
  gr.HTML("<h1> The Mangio-RVC-Fork 💻 </h1>")
1622
  gr.Markdown(
1623
  value=i18n(
1624
- "本软件以MIT协议开源, 作者不对软件具备任何控制力, 使用软件者、传播软件导出的声音者自负全责. <br>如不认可该条款, 则不能使用或引用软件包内任何代码和文件. 详见根目录<b>使用需遵守的协议-LICENSE.txt</b>."
1625
  )
1626
  )
1627
  with gr.Tabs():
1628
- with gr.TabItem(i18n("模型推理")):
1629
  # Inference Preset Row
1630
  # with gr.Row():
1631
  # mangio_preset = gr.Dropdown(label="Inference Preset", choices=sorted(get_presets()))
@@ -1636,14 +1636,14 @@ with gr.Blocks(theme=gr.themes.Soft()) as app:
1636
 
1637
  # Other RVC stuff
1638
  with gr.Row():
1639
- sid0 = gr.Dropdown(label=i18n("推理音色"), choices=sorted(names))
1640
- refresh_button = gr.Button(i18n("刷新音色列表和索引路径"), variant="primary")
1641
- clean_button = gr.Button(i18n("卸载音色省显存"), variant="primary")
1642
  spk_item = gr.Slider(
1643
  minimum=0,
1644
  maximum=2333,
1645
  step=1,
1646
- label=i18n("请选择说话人id"),
1647
  value=0,
1648
  visible=False,
1649
  interactive=True,
@@ -1651,20 +1651,20 @@ with gr.Blocks(theme=gr.themes.Soft()) as app:
1651
  clean_button.click(fn=clean, inputs=[], outputs=[sid0])
1652
  with gr.Group():
1653
  gr.Markdown(
1654
- value=i18n("男转女推荐+12key, 女转男推荐-12key, 如果音域爆炸导致音色失真也可以自己调整到合适音域. ")
1655
  )
1656
  with gr.Row():
1657
  with gr.Column():
1658
  vc_transform0 = gr.Number(
1659
- label=i18n("变调(整数, 半音数量, 升八度12降八度-12)"), value=0
1660
  )
1661
  input_audio0 = gr.Textbox(
1662
- label=i18n("输入待处理音频文件路径(默认是正确格式示例)"),
1663
- value="E:\\codes\\py39\\test-20230416b\\todo-songs\\冬之花clip1.wav",
1664
  )
1665
  f0method0 = gr.Radio(
1666
  label=i18n(
1667
- "选择音高提取算法,输入歌声可用pm提速,harvest低音好但巨慢无比,crepe效果好但吃GPU"
1668
  ),
1669
  choices=["pm", "harvest", "dio", "crepe", "crepe-tiny", "mangio-crepe", "mangio-crepe-tiny"], # Fork Feature. Add Crepe-Tiny
1670
  value="pm",
@@ -1681,19 +1681,19 @@ with gr.Blocks(theme=gr.themes.Soft()) as app:
1681
  filter_radius0 = gr.Slider(
1682
  minimum=0,
1683
  maximum=7,
1684
- label=i18n(">=3则使用对harvest音高识别的结果使用中值滤波,数值为滤波半径,使用可以削弱哑音"),
1685
  value=3,
1686
  step=1,
1687
  interactive=True,
1688
  )
1689
  with gr.Column():
1690
  file_index1 = gr.Textbox(
1691
- label=i18n("特征检索库文件路径,为空则使用下拉的选择结果"),
1692
  value="",
1693
  interactive=True,
1694
  )
1695
  file_index2 = gr.Dropdown(
1696
- label=i18n("自动检测index路径,下拉式选择(dropdown)"),
1697
  choices=sorted(index_paths),
1698
  interactive=True,
1699
  )
@@ -1701,14 +1701,14 @@ with gr.Blocks(theme=gr.themes.Soft()) as app:
1701
  fn=change_choices, inputs=[], outputs=[sid0, file_index2]
1702
  )
1703
  # file_big_npy1 = gr.Textbox(
1704
- # label=i18n("特征文件路径"),
1705
  # value="E:\\codes\py39\\vits_vc_gpu_train\\logs\\mi-test-1key\\total_fea.npy",
1706
  # interactive=True,
1707
  # )
1708
  index_rate1 = gr.Slider(
1709
  minimum=0,
1710
  maximum=1,
1711
- label=i18n("检索特征占比"),
1712
  value=0.88,
1713
  interactive=True,
1714
  )
@@ -1716,7 +1716,7 @@ with gr.Blocks(theme=gr.themes.Soft()) as app:
1716
  resample_sr0 = gr.Slider(
1717
  minimum=0,
1718
  maximum=48000,
1719
- label=i18n("后处理重采样至最终采样率,0为不进行重采样"),
1720
  value=0,
1721
  step=1,
1722
  interactive=True,
@@ -1724,7 +1724,7 @@ with gr.Blocks(theme=gr.themes.Soft()) as app:
1724
  rms_mix_rate0 = gr.Slider(
1725
  minimum=0,
1726
  maximum=1,
1727
- label=i18n("输入源音量包络替换输出音量包络融合比例,越靠近1越使用输出包络"),
1728
  value=1,
1729
  interactive=True,
1730
  )
@@ -1732,17 +1732,17 @@ with gr.Blocks(theme=gr.themes.Soft()) as app:
1732
  minimum=0,
1733
  maximum=0.5,
1734
  label=i18n(
1735
- "保护清辅音和呼吸声,防止电音撕裂等artifact,拉满0.5不开启,调低加大保护力度但可能降低索引效果"
1736
  ),
1737
  value=0.33,
1738
  step=0.01,
1739
  interactive=True,
1740
  )
1741
- f0_file = gr.File(label=i18n("F0曲线文件, 可选, 一行一个音高, 代替默认F0及升降调"))
1742
- but0 = gr.Button(i18n("转换"), variant="primary")
1743
  with gr.Row():
1744
- vc_output1 = gr.Textbox(label=i18n("输出信息"))
1745
- vc_output2 = gr.Audio(label=i18n("输出音频(右下角三个点,点了可以下载)"))
1746
  but0.click(
1747
  vc_single,
1748
  [
@@ -1765,17 +1765,17 @@ with gr.Blocks(theme=gr.themes.Soft()) as app:
1765
  )
1766
  with gr.Group():
1767
  gr.Markdown(
1768
- value=i18n("批量转换, 输入待转换音频文件夹, 或上传多个音频文件, 在指定文件夹(默认opt)下输出转换的音频. ")
1769
  )
1770
  with gr.Row():
1771
  with gr.Column():
1772
  vc_transform1 = gr.Number(
1773
- label=i18n("变调(整数, 半音数量, 升八度12降八度-12)"), value=0
1774
  )
1775
- opt_input = gr.Textbox(label=i18n("指定输出文件夹"), value="opt")
1776
  f0method1 = gr.Radio(
1777
  label=i18n(
1778
- "选择音高提取算法,输入歌声可用pm提速,harvest低音好但巨慢无比,crepe效果好但吃GPU"
1779
  ),
1780
  choices=["pm", "harvest", "crepe"],
1781
  value="pm",
@@ -1784,19 +1784,19 @@ with gr.Blocks(theme=gr.themes.Soft()) as app:
1784
  filter_radius1 = gr.Slider(
1785
  minimum=0,
1786
  maximum=7,
1787
- label=i18n(">=3则使用对harvest音高识别的结果使用中值滤波,数值为滤波半径,使用可以削弱哑音"),
1788
  value=3,
1789
  step=1,
1790
  interactive=True,
1791
  )
1792
  with gr.Column():
1793
  file_index3 = gr.Textbox(
1794
- label=i18n("特征检索库文件路径,为空则使用下拉的选择结果"),
1795
  value="",
1796
  interactive=True,
1797
  )
1798
  file_index4 = gr.Dropdown(
1799
- label=i18n("自动检测index路径,下拉式选择(dropdown)"),
1800
  choices=sorted(index_paths),
1801
  interactive=True,
1802
  )
@@ -1806,14 +1806,14 @@ with gr.Blocks(theme=gr.themes.Soft()) as app:
1806
  outputs=file_index4,
1807
  )
1808
  # file_big_npy2 = gr.Textbox(
1809
- # label=i18n("特征文件路径"),
1810
  # value="E:\\codes\\py39\\vits_vc_gpu_train\\logs\\mi-test-1key\\total_fea.npy",
1811
  # interactive=True,
1812
  # )
1813
  index_rate2 = gr.Slider(
1814
  minimum=0,
1815
  maximum=1,
1816
- label=i18n("检索特征占比"),
1817
  value=1,
1818
  interactive=True,
1819
  )
@@ -1821,7 +1821,7 @@ with gr.Blocks(theme=gr.themes.Soft()) as app:
1821
  resample_sr1 = gr.Slider(
1822
  minimum=0,
1823
  maximum=48000,
1824
- label=i18n("后处理重采样至最终采样率,0为不进行重采样"),
1825
  value=0,
1826
  step=1,
1827
  interactive=True,
@@ -1829,7 +1829,7 @@ with gr.Blocks(theme=gr.themes.Soft()) as app:
1829
  rms_mix_rate1 = gr.Slider(
1830
  minimum=0,
1831
  maximum=1,
1832
- label=i18n("输入源音量包络替换输出音量包络融合比例,越靠近1越使用输出包络"),
1833
  value=1,
1834
  interactive=True,
1835
  )
@@ -1837,7 +1837,7 @@ with gr.Blocks(theme=gr.themes.Soft()) as app:
1837
  minimum=0,
1838
  maximum=0.5,
1839
  label=i18n(
1840
- "保护清辅音和呼吸声,防止电音撕裂等artifact,拉满0.5不开启,调低加大保护力度但可能降低索引效果"
1841
  ),
1842
  value=0.33,
1843
  step=0.01,
@@ -1845,21 +1845,21 @@ with gr.Blocks(theme=gr.themes.Soft()) as app:
1845
  )
1846
  with gr.Column():
1847
  dir_input = gr.Textbox(
1848
- label=i18n("输入待处理音频文件夹路径(去文件管理器地址栏拷就行了)"),
1849
  value="E:\codes\py39\\test-20230416b\\todo-songs",
1850
  )
1851
  inputs = gr.File(
1852
- file_count="multiple", label=i18n("也可批量输入音频文件, 二选一, 优先读文件夹")
1853
  )
1854
  with gr.Row():
1855
  format1 = gr.Radio(
1856
- label=i18n("导出文件格式"),
1857
  choices=["wav", "flac", "mp3", "m4a"],
1858
  value="flac",
1859
  interactive=True,
1860
  )
1861
- but1 = gr.Button(i18n("转换"), variant="primary")
1862
- vc_output3 = gr.Textbox(label=i18n("输出信息"))
1863
  but1.click(
1864
  vc_multi,
1865
  [
@@ -1891,54 +1891,54 @@ with gr.Blocks(theme=gr.themes.Soft()) as app:
1891
  with gr.Group():
1892
  gr.Markdown(
1893
  value=i18n(
1894
- "人声伴奏分离批量处理, 使用UVR5模型。 <br>"
1895
- "合格的文件夹路径格式举例: E:\\codes\\py39\\vits_vc_gpu\\白鹭霜华测试样例(去文件管理器地址栏拷就行了) <br>"
1896
- "模型分为三类: <br>"
1897
- "1、保留人声:不带和声的音频选这个,对主人声保留比HP5更好。内置HP2HP3两个模型,HP3可能轻微漏伴奏但对主人声保留比HP2稍微好一丁点; <br>"
1898
- "2、仅保留主人声:带和声的音频选这个,对主人声可能有削弱。内置HP5一个模型; <br> "
1899
- "3、去混响、去延迟模型(by FoxJoy):<br>"
1900
- "  (1)MDX-Net(onnx_dereverb):对于双通道混响是最好的选择,不能去除单通道混响;<br>"
1901
- "&emsp;(234)DeEcho:去除延迟效果。AggressiveNormal去除得更彻底,DeReverb额外去除混响,可去除单声道混响,但是对高频重的板式混响去不干净。<br>"
1902
- "去混响/去延迟,附:<br>"
1903
- "1DeEcho-DeReverb模型的耗时是另外2个DeEcho模型的接近2倍;<br>"
1904
- "2MDX-Net-Dereverb模型挺慢的;<br>"
1905
- "3、个人推荐的最干净的配置是先MDX-NetDeEcho-Aggressive"
1906
  )
1907
  )
1908
  with gr.Row():
1909
  with gr.Column():
1910
  dir_wav_input = gr.Textbox(
1911
- label=i18n("输入待处理音频文件夹路径"),
1912
  value="E:\\codes\\py39\\test-20230416b\\todo-songs\\todo-songs",
1913
  )
1914
  wav_inputs = gr.File(
1915
- file_count="multiple", label=i18n("也可批量输入音频文件, 二选一, 优先读文件夹")
1916
  )
1917
  with gr.Column():
1918
- model_choose = gr.Dropdown(label=i18n("模型"), choices=uvr5_names)
1919
  agg = gr.Slider(
1920
  minimum=0,
1921
  maximum=20,
1922
  step=1,
1923
- label="人声提取激进程度",
1924
  value=10,
1925
  interactive=True,
1926
- visible=False, # 先不开放调整
1927
  )
1928
  opt_vocal_root = gr.Textbox(
1929
- label=i18n("指定输出主人声文件夹"), value="opt"
1930
  )
1931
  opt_ins_root = gr.Textbox(
1932
- label=i18n("指定输出非主人声文件夹"), value="opt"
1933
  )
1934
  format0 = gr.Radio(
1935
- label=i18n("导出文件格式"),
1936
  choices=["wav", "flac", "mp3", "m4a"],
1937
  value="flac",
1938
  interactive=True,
1939
  )
1940
- but2 = gr.Button(i18n("转换"), variant="primary")
1941
- vc_output4 = gr.Textbox(label=i18n("输出信息"))
1942
  but2.click(
1943
  uvr,
1944
  [
@@ -1952,28 +1952,28 @@ with gr.Blocks(theme=gr.themes.Soft()) as app:
1952
  ],
1953
  [vc_output4],
1954
  )
1955
- with gr.TabItem(i18n("训练")):
1956
  gr.Markdown(
1957
  value=i18n(
1958
- "step1: 填写实验配置. 实验数据放在logs下, 每个实验一个文件夹, 需手工输入实验名路径, 内含实验配置, 日志, 训练得到的模型文件. "
1959
  )
1960
  )
1961
  with gr.Row():
1962
- exp_dir1 = gr.Textbox(label=i18n("输入实验名"), value="mi-test")
1963
  sr2 = gr.Radio(
1964
- label=i18n("目标采样率"),
1965
  choices=["40k", "48k"],
1966
  value="40k",
1967
  interactive=True,
1968
  )
1969
  if_f0_3 = gr.Radio(
1970
- label=i18n("模型是否带音高指导(唱歌一定要, 语音可以不要)"),
1971
  choices=[True, False],
1972
  value=True,
1973
  interactive=True,
1974
  )
1975
  version19 = gr.Radio(
1976
- label=i18n("版本"),
1977
  choices=["v1", "v2"],
1978
  value="v1",
1979
  interactive=True,
@@ -1983,39 +1983,39 @@ with gr.Blocks(theme=gr.themes.Soft()) as app:
1983
  minimum=0,
1984
  maximum=config.n_cpu,
1985
  step=1,
1986
- label=i18n("提取音高和处理数据使用的CPU进程数"),
1987
  value=int(np.ceil(config.n_cpu / 1.5)),
1988
  interactive=True,
1989
  )
1990
- with gr.Group(): # 暂时单人的, 后面支持最多4人的#数据处理
1991
  gr.Markdown(
1992
  value=i18n(
1993
- "step2a: 自动遍历训练文件夹下所有可解码成音频的文件并进行切片归一化, 在实验目录下生成2wav文件夹; 暂时只支持单人训练. "
1994
  )
1995
  )
1996
  with gr.Row():
1997
  trainset_dir4 = gr.Textbox(
1998
- label=i18n("输入训练文件夹路径"), value="E:\\语音音频+标注\\米津玄师\\src"
1999
  )
2000
  spk_id5 = gr.Slider(
2001
  minimum=0,
2002
  maximum=4,
2003
  step=1,
2004
- label=i18n("请指定说话人id"),
2005
  value=0,
2006
  interactive=True,
2007
  )
2008
- but1 = gr.Button(i18n("处理数据"), variant="primary")
2009
- info1 = gr.Textbox(label=i18n("输出信息"), value="")
2010
  but1.click(
2011
  preprocess_dataset, [trainset_dir4, exp_dir1, sr2, np7], [info1]
2012
  )
2013
  with gr.Group():
2014
- gr.Markdown(value=i18n("step2b: 使用CPU提取音高(如果模型带音高), 使用GPU提取特征(选择卡号)"))
2015
  with gr.Row():
2016
  with gr.Column():
2017
  gpus6 = gr.Textbox(
2018
- label=i18n("以-分隔输入使用的卡号, 例如 0-1-2 使用卡0和卡1和卡2"),
2019
  value=gpus,
2020
  interactive=True,
2021
  )
@@ -2023,7 +2023,7 @@ with gr.Blocks(theme=gr.themes.Soft()) as app:
2023
  with gr.Column():
2024
  f0method8 = gr.Radio(
2025
  label=i18n(
2026
- "选择音高提取算法:输入歌声可用pm提速,高质量语音但CPU差可用dio提速,harvest质量更好但慢"
2027
  ),
2028
  choices=["pm", "harvest", "dio", "crepe", "mangio-crepe"], # Fork feature: Crepe on f0 extraction for training.
2029
  value="harvest",
@@ -2037,21 +2037,21 @@ with gr.Blocks(theme=gr.themes.Soft()) as app:
2037
  value=64,
2038
  interactive=True
2039
  )
2040
- but2 = gr.Button(i18n("特征提取"), variant="primary")
2041
- info2 = gr.Textbox(label=i18n("输出信息"), value="", max_lines=8)
2042
  but2.click(
2043
  extract_f0_feature,
2044
  [gpus6, np7, f0method8, if_f0_3, exp_dir1, version19, extraction_crepe_hop_length],
2045
  [info2],
2046
  )
2047
  with gr.Group():
2048
- gr.Markdown(value=i18n("step3: 填写训练设置, 开始训练模型和索引"))
2049
  with gr.Row():
2050
  save_epoch10 = gr.Slider(
2051
  minimum=0,
2052
  maximum=50,
2053
  step=1,
2054
- label=i18n("保存频率save_every_epoch"),
2055
  value=5,
2056
  interactive=True,
2057
  )
@@ -2059,7 +2059,7 @@ with gr.Blocks(theme=gr.themes.Soft()) as app:
2059
  minimum=0,
2060
  maximum=10000,
2061
  step=1,
2062
- label=i18n("总训练轮数total_epoch"),
2063
  value=20,
2064
  interactive=True,
2065
  )
@@ -2067,38 +2067,38 @@ with gr.Blocks(theme=gr.themes.Soft()) as app:
2067
  minimum=1,
2068
  maximum=40,
2069
  step=1,
2070
- label=i18n("每张显卡的batch_size"),
2071
  value=default_batch_size,
2072
  interactive=True,
2073
  )
2074
  if_save_latest13 = gr.Radio(
2075
- label=i18n("是否仅保存最新的ckpt文件以节省硬盘空间"),
2076
- choices=[i18n(""), i18n("")],
2077
- value=i18n(""),
2078
  interactive=True,
2079
  )
2080
  if_cache_gpu17 = gr.Radio(
2081
  label=i18n(
2082
- "是否缓存所有训练集至显存. 10min以下小数据可缓存以加速训练, 大数据缓存会炸显存也加不了多少速"
2083
  ),
2084
- choices=[i18n(""), i18n("")],
2085
- value=i18n(""),
2086
  interactive=True,
2087
  )
2088
  if_save_every_weights18 = gr.Radio(
2089
- label=i18n("是否在每次保存时间点将最终小模型保存至weights文件夹"),
2090
- choices=[i18n(""), i18n("")],
2091
- value=i18n(""),
2092
  interactive=True,
2093
  )
2094
  with gr.Row():
2095
  pretrained_G14 = gr.Textbox(
2096
- label=i18n("加载预训练底模G路径"),
2097
  value="pretrained/f0G40k.pth",
2098
  interactive=True,
2099
  )
2100
  pretrained_D15 = gr.Textbox(
2101
- label=i18n("加载预训练底模D路径"),
2102
  value="pretrained/f0D40k.pth",
2103
  interactive=True,
2104
  )
@@ -2118,14 +2118,14 @@ with gr.Blocks(theme=gr.themes.Soft()) as app:
2118
  [f0method8, pretrained_G14, pretrained_D15],
2119
  )
2120
  gpus16 = gr.Textbox(
2121
- label=i18n("以-分隔输入使用的卡号, 例如 0-1-2 使用卡0和卡1和卡2"),
2122
  value=gpus,
2123
  interactive=True,
2124
  )
2125
- but3 = gr.Button(i18n("训练模型"), variant="primary")
2126
- but4 = gr.Button(i18n("训练特征索引"), variant="primary")
2127
- but5 = gr.Button(i18n("一键训练"), variant="primary")
2128
- info3 = gr.Textbox(label=i18n("输出信息"), value="", max_lines=10)
2129
  but3.click(
2130
  click_train,
2131
  [
@@ -2172,50 +2172,50 @@ with gr.Blocks(theme=gr.themes.Soft()) as app:
2172
  info3,
2173
  )
2174
 
2175
- with gr.TabItem(i18n("ckpt处理")):
2176
  with gr.Group():
2177
- gr.Markdown(value=i18n("模型融合, 可用于测试音色融合"))
2178
  with gr.Row():
2179
- ckpt_a = gr.Textbox(label=i18n("A模型路径"), value="", interactive=True)
2180
- ckpt_b = gr.Textbox(label=i18n("B模型路径"), value="", interactive=True)
2181
  alpha_a = gr.Slider(
2182
  minimum=0,
2183
  maximum=1,
2184
- label=i18n("A模型权重"),
2185
  value=0.5,
2186
  interactive=True,
2187
  )
2188
  with gr.Row():
2189
  sr_ = gr.Radio(
2190
- label=i18n("目标采样率"),
2191
  choices=["40k", "48k"],
2192
  value="40k",
2193
  interactive=True,
2194
  )
2195
  if_f0_ = gr.Radio(
2196
- label=i18n("模型是否带音高指导"),
2197
- choices=[i18n(""), i18n("")],
2198
- value=i18n(""),
2199
  interactive=True,
2200
  )
2201
  info__ = gr.Textbox(
2202
- label=i18n("要置入的模型信息"), value="", max_lines=8, interactive=True
2203
  )
2204
  name_to_save0 = gr.Textbox(
2205
- label=i18n("保存的模型名不带后缀"),
2206
  value="",
2207
  max_lines=1,
2208
  interactive=True,
2209
  )
2210
  version_2 = gr.Radio(
2211
- label=i18n("模型版本型号"),
2212
  choices=["v1", "v2"],
2213
  value="v1",
2214
  interactive=True,
2215
  )
2216
  with gr.Row():
2217
- but6 = gr.Button(i18n("融合"), variant="primary")
2218
- info4 = gr.Textbox(label=i18n("输出信息"), value="", max_lines=8)
2219
  but6.click(
2220
  merge,
2221
  [
@@ -2231,71 +2231,71 @@ with gr.Blocks(theme=gr.themes.Soft()) as app:
2231
  info4,
2232
  ) # def merge(path1,path2,alpha1,sr,f0,info):
2233
  with gr.Group():
2234
- gr.Markdown(value=i18n("修改模型信息(仅支持weights文件夹下提取的小模型文件)"))
2235
  with gr.Row():
2236
  ckpt_path0 = gr.Textbox(
2237
- label=i18n("模型路径"), value="", interactive=True
2238
  )
2239
  info_ = gr.Textbox(
2240
- label=i18n("要改的模型信息"), value="", max_lines=8, interactive=True
2241
  )
2242
  name_to_save1 = gr.Textbox(
2243
- label=i18n("保存的文件名, 默认空为和源文件同名"),
2244
  value="",
2245
  max_lines=8,
2246
  interactive=True,
2247
  )
2248
  with gr.Row():
2249
- but7 = gr.Button(i18n("修改"), variant="primary")
2250
- info5 = gr.Textbox(label=i18n("输出信息"), value="", max_lines=8)
2251
  but7.click(change_info, [ckpt_path0, info_, name_to_save1], info5)
2252
  with gr.Group():
2253
- gr.Markdown(value=i18n("查看模型信息(仅支持weights文件夹下提取的小模型文件)"))
2254
  with gr.Row():
2255
  ckpt_path1 = gr.Textbox(
2256
- label=i18n("模型路径"), value="", interactive=True
2257
  )
2258
- but8 = gr.Button(i18n("查看"), variant="primary")
2259
- info6 = gr.Textbox(label=i18n("输出信息"), value="", max_lines=8)
2260
  but8.click(show_info, [ckpt_path1], info6)
2261
  with gr.Group():
2262
  gr.Markdown(
2263
  value=i18n(
2264
- "模型提取(输入logs文件夹下大文件模型路径),适用于训一半不想训了模型没有自动提取保存小文件模型,或者想测试中间模型的情况"
2265
  )
2266
  )
2267
  with gr.Row():
2268
  ckpt_path2 = gr.Textbox(
2269
- label=i18n("模型路径"),
2270
  value="E:\\codes\\py39\\logs\\mi-test_f0_48k\\G_23333.pth",
2271
  interactive=True,
2272
  )
2273
  save_name = gr.Textbox(
2274
- label=i18n("保存名"), value="", interactive=True
2275
  )
2276
  sr__ = gr.Radio(
2277
- label=i18n("目标采样率"),
2278
  choices=["32k", "40k", "48k"],
2279
  value="40k",
2280
  interactive=True,
2281
  )
2282
  if_f0__ = gr.Radio(
2283
- label=i18n("模型是否带音高指导,10"),
2284
  choices=["1", "0"],
2285
  value="1",
2286
  interactive=True,
2287
  )
2288
  version_1 = gr.Radio(
2289
- label=i18n("模型版本型号"),
2290
  choices=["v1", "v2"],
2291
  value="v2",
2292
  interactive=True,
2293
  )
2294
  info___ = gr.Textbox(
2295
- label=i18n("要置入的模型信息"), value="", max_lines=8, interactive=True
2296
  )
2297
- but9 = gr.Button(i18n("提取"), variant="primary")
2298
- info7 = gr.Textbox(label=i18n("输出信息"), value="", max_lines=8)
2299
  ckpt_path2.change(
2300
  change_info_, [ckpt_path2], [sr__, if_f0__, version_1]
2301
  )
@@ -2305,23 +2305,23 @@ with gr.Blocks(theme=gr.themes.Soft()) as app:
2305
  info7,
2306
  )
2307
 
2308
- with gr.TabItem(i18n("Onnx导出")):
2309
  with gr.Row():
2310
- ckpt_dir = gr.Textbox(label=i18n("RVC模型路径"), value="", interactive=True)
2311
  with gr.Row():
2312
  onnx_dir = gr.Textbox(
2313
- label=i18n("Onnx输出路径"), value="", interactive=True
2314
  )
2315
  with gr.Row():
2316
  infoOnnx = gr.Label(label="info")
2317
  with gr.Row():
2318
- butOnnx = gr.Button(i18n("导出Onnx模型"), variant="primary")
2319
  butOnnx.click(export_onnx, [ckpt_dir, onnx_dir], infoOnnx)
2320
 
2321
- tab_faq = i18n("常见问题解答")
2322
  with gr.TabItem(tab_faq):
2323
  try:
2324
- if tab_faq == "常见问题解答":
2325
  with open("docs/faq.md", "r", encoding="utf8") as f:
2326
  info = f.read()
2327
  else:
@@ -2453,9 +2453,9 @@ with gr.Blocks(theme=gr.themes.Soft()) as app:
2453
  # )
2454
  #endregion
2455
 
2456
- # with gr.TabItem(i18n("招募音高曲线前端编辑器")):
2457
- # gr.Markdown(value=i18n("加开发群联系我xxxxx"))
2458
- # with gr.TabItem(i18n("点击查看交流、问题反馈群号")):
2459
  # gr.Markdown(value=i18n("xxxxx"))
2460
 
2461
  if config.iscolab or config.paperspace: # Share gradio link for colab and paperspace (FORK FEATURE)
 
58
  config = Config()
59
  i18n = I18nAuto()
60
  i18n.print()
61
+ # Determine whether there is an N card that can be used for training and accelerated reasoning
62
  ngpu = torch.cuda.device_count()
63
  gpu_infos = []
64
  mem = []
 
91
  ]
92
  ):
93
  # A10#A100#V100#A40#P40#M40#K80#A4500
94
+ if_gpu_ok = True # At least one usable Nvidia card
95
  gpu_infos.append("%s\t%s" % (i, gpu_name))
96
  mem.append(
97
  int(
 
106
  gpu_info = "\n".join(gpu_infos)
107
  default_batch_size = min(mem) // 2
108
  else:
109
+ gpu_info = i18n("Unfortunately you don't have a working graphics card to support your training.")
110
  default_batch_size = 1
111
  gpus = "-".join([i[0] for i in gpu_infos])
112
 
 
197
  )
198
  if file_index != ""
199
  else file_index2
200
+ ) # Prevent newbies from making mistakes and automatically replace them for them
201
  # file_big_npy = (
202
  # file_big_npy.strip(" ").strip('"').strip("\n").strip('"').strip(" ")
203
  # )
 
263
  try:
264
  dir_path = (
265
  dir_path.strip(" ").strip('"').strip("\n").strip('"').strip(" ")
266
+ ) # Prevent newbies from copying the path with spaces, " and carriage returns at the beginning and end
267
  opt_root = opt_root.strip(" ").strip('"').strip("\n").strip('"').strip(" ")
268
  os.makedirs(opt_root, exist_ok=True)
269
  try:
 
402
  yield "\n".join(infos)
403
 
404
 
405
+ # A tab can only have one sound globally.
406
  def get_vc(sid, to_return_protect0, to_return_protect1):
407
  global n_spk, tgt_sr, net_g, vc, cpt, version
408
  if sid == "" or sid == []:
409
  global hubert_model
410
+ if hubert_model is not None: # Considering polling, we need to add a check to see if the sid is switched from a model to a model-free state.
411
  print("clean_empty_cache")
412
  del net_g, n_spk, vc, hubert_model, tgt_sr # ,cpt
413
  hubert_model = net_g = n_spk = vc = hubert_model = tgt_sr = None
414
  if torch.cuda.is_available():
415
  torch.cuda.empty_cache()
416
+ ###The downstairs won't be clean without this much trouble
417
  if_f0 = cpt.get("f0", 1)
418
  version = cpt.get("version", "v1")
419
  if version == "v1":
 
523
 
524
  def if_done_multi(done, ps):
525
  while 1:
526
+ # poll==None means the process is not finished
527
+ # As long as there is a process that has not ended, it will not stop.
528
  flag = 1
529
  for p in ps:
530
  if p.poll() is None:
 
549
  )
550
  print(cmd)
551
  p = Popen(cmd, shell=True) # , stdin=PIPE, stdout=PIPE,stderr=PIPE,cwd=now_dir
552
+ ###Damn, gr and popen read both have to run completely and then read at once. Without gr, it can just read and output one sentence at a time. I can only create an additional text stream to read at a fixed time.
553
  done = [False]
554
  threading.Thread(
555
  target=if_done,
 
586
  )
587
  print(cmd)
588
  p = Popen(cmd, shell=True, cwd=now_dir) # , stdin=PIPE, stdout=PIPE,stderr=PIPE
589
+ ###Damn, gr and popen read both have to run completely and then read at once. Without gr, it can just read and output one sentence at a time. I can only create an additional text stream to read at a fixed time.
590
  done = [False]
591
  threading.Thread(
592
  target=if_done,
 
607
  log = f.read()
608
  print(log)
609
  yield log
610
+ ####Open multiple processes for different parts
611
  """
612
  n_part=int(sys.argv[1])
613
  i_part=int(sys.argv[2])
 
636
  cmd, shell=True, cwd=now_dir
637
  ) # , shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE, cwd=now_dir
638
  ps.append(p)
639
+ ###Damn, gr and popen read both have to run completely and then read at once. Without gr, it can just read and output one sentence at a time. I can only create an additional text stream to read at a fixed time.
640
  done = [False]
641
  threading.Thread(
642
  target=if_done_multi,
 
779
  if_save_every_weights18,
780
  version19,
781
  ):
782
+ # Generate filelist
783
  exp_dir = "%s/logs/%s" % (now_dir, exp_dir1)
784
  os.makedirs(exp_dir, exist_ok=True)
785
  gt_wavs_dir = "%s/0_gt_wavs" % (exp_dir)
 
846
  with open("%s/filelist.txt" % exp_dir, "w") as f:
847
  f.write("\n".join(opt))
848
  print("write filelist done")
849
+ # Generate config#No need to generate config
850
  # 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"
851
  print("use gpus:", gpus16)
852
  if pretrained_G14 == "":
 
867
  save_epoch10,
868
  "-pg %s" % pretrained_G14 if pretrained_G14 != "" else "",
869
  "-pd %s" % pretrained_D15 if pretrained_D15 != "" else "",
870
+ 1 if if_save_latest13 == i18n("yes") else 0,
871
+ 1 if if_cache_gpu17 == i18n("yes") else 0,
872
+ 1 if if_save_every_weights18 == i18n("yes") else 0,
873
  version19,
874
  )
875
  )
 
886
  save_epoch10,
887
  "-pg %s" % pretrained_G14 if pretrained_G14 != "" else "\b",
888
  "-pd %s" % pretrained_D15 if pretrained_D15 != "" else "\b",
889
+ 1 if if_save_latest13 == i18n("yes") else 0,
890
+ 1 if if_cache_gpu17 == i18n("yes") else 0,
891
+ 1 if if_save_every_weights18 == i18n("yes") else 0,
892
  version19,
893
  )
894
  )
895
  print(cmd)
896
  p = Popen(cmd, shell=True, cwd=now_dir)
897
  p.wait()
898
+ return "After the training is completed, you can view the console training log or train.log in the experiment folder."
899
 
900
 
901
  # but4.click(train_index, [exp_dir1], info3)
 
908
  else "%s/3_feature768" % (exp_dir)
909
  )
910
  if not os.path.exists(feature_dir):
911
+ return "Please perform feature extraction first!"
912
  listdir_res = list(os.listdir(feature_dir))
913
  if len(listdir_res) == 0:
914
+ return "Please perform feature extraction first!"
915
  infos = []
916
  npys = []
917
  for name in sorted(listdir_res):
 
971
  % (exp_dir, n_ivf, index_ivf.nprobe, exp_dir1, version19),
972
  )
973
  infos.append(
974
+ "Successfully built index, added_IVF%s_Flat_nprobe_%s_%s_%s.index"
975
  % (n_ivf, index_ivf.nprobe, exp_dir1, version19)
976
  )
977
  # faiss.write_index(index, '%s/added_IVF%s_Flat_FastScan_%s.index'%(exp_dir,n_ivf,version19))
978
+ # infos.append("Index built successfully,added_IVF%s_Flat_FastScan_%s.index"%(n_ivf,version19))
979
  yield "\n".join(infos)
980
 
981
 
 
1017
  )
1018
 
1019
  os.makedirs(model_log_dir, exist_ok=True)
1020
+ #########step1:Process data
1021
  open(preprocess_log_path, "w").close()
1022
  cmd = (
1023
  config.python_cmd
 
1025
  % (trainset_dir4, sr_dict[sr2], np7, model_log_dir)
1026
  + str(config.noparallel)
1027
  )
1028
+ yield get_info_str(i18n("step1:Processing data"))
1029
  yield get_info_str(cmd)
1030
  p = Popen(cmd, shell=True)
1031
  p.wait()
1032
  with open(preprocess_log_path, "r") as f:
1033
  print(f.read())
1034
+ #########step2a:extract pitch
1035
  open(extract_f0_feature_log_path, "w")
1036
  if if_f0_3:
1037
+ yield get_info_str("step2a:Extracting pitch")
1038
  cmd = config.python_cmd + " extract_f0_print.py %s %s %s %s" % (
1039
  model_log_dir,
1040
  np7,
 
1047
  with open(extract_f0_feature_log_path, "r") as f:
1048
  print(f.read())
1049
  else:
1050
+ yield get_info_str(i18n("step2a:No need to extract pitch"))
1051
+ #######step2b:Extract features
1052
+ yield get_info_str(i18n("step2b:Extracting features"))
1053
  gpus = gpus16.split("-")
1054
  leng = len(gpus)
1055
  ps = []
 
1071
  p.wait()
1072
  with open(extract_f0_feature_log_path, "r") as f:
1073
  print(f.read())
1074
+ #######step3a:Training model
1075
+ yield get_info_str(i18n("step3a:Training model"))
1076
+ # Generate filelist
1077
  if if_f0_3:
1078
  f0_dir = "%s/2a_f0" % model_log_dir
1079
  f0nsf_dir = "%s/2b-f0nsf" % model_log_dir
 
1174
  yield get_info_str(cmd)
1175
  p = Popen(cmd, shell=True, cwd=now_dir)
1176
  p.wait()
1177
+ yield get_info_str(i18n("After the training is completed, you can view the console training log or train.log in the experiment folder."))
1178
+ #######step3b:training index
1179
  npys = []
1180
  listdir_res = list(os.listdir(feature_dir))
1181
  for name in sorted(listdir_res):
 
1234
  % (model_log_dir, n_ivf, index_ivf.nprobe, exp_dir1, version19),
1235
  )
1236
  yield get_info_str(
1237
+ "Index built successfully, added_IVF%s_Flat_nprobe_%s_%s_%s.index"
1238
  % (n_ivf, index_ivf.nprobe, exp_dir1, version19)
1239
  )
1240
+ yield get_info_str(i18n("The whole process is completed!"))
1241
 
1242
 
1243
  # ckpt_path2.change(change_info_,[ckpt_path2],[sr__,if_f0__])
 
1263
  vec_channels = 256 if cpt.get("version", "v1") == "v1" else 768
1264
 
1265
  test_phone = torch.rand(1, 200, vec_channels) # hidden unit
1266
+ test_phone_lengths = torch.tensor([200]).long() # hidden unit Length (seemingly useless)
1267
+ test_pitch = torch.randint(size=(1, 200), low=5, high=255) # Fundamental frequency (in Hz)
1268
+ test_pitchf = torch.rand(1, 200) # NSF base frequency
1269
+ test_ds = torch.LongTensor([0]) # Speaker ID
1270
+ test_rnd = torch.rand(1, 192, 200) # Noise (adding random factors)
1271
 
1272
+ device = "cpu" # Device when exporting (does not affect the use of the model)
1273
 
1274
 
1275
  net_g = SynthesizerTrnMsNSFsidM(
1276
  *cpt["config"], is_half=False, version=cpt.get("version", "v1")
1277
+ ) # fp32 export (C++ needs to manually rearrange memory to support fp16, so fp16 is not used for the time being)
1278
  net_g.load_state_dict(cpt["weight"], strict=False)
1279
  input_names = ["phone", "phone_lengths", "pitch", "pitchf", "ds", "rnd"]
1280
  output_names = [
1281
  "audio",
1282
  ]
1283
+ # net_g.construct_spkmixmap(n_speaker) export of multiple role mixed tracks
1284
  torch.onnx.export(
1285
  net_g,
1286
  (
 
1421
  total_epoch = int(com[5]) # 10000
1422
  batch_size = int(com[6])
1423
  gpu_card_slot_numbers = com[7]
1424
+ if_save_latest = i18n("yes") if (int(com[8]) == 1) else i18n("no")
1425
+ if_cache_gpu = i18n("yes") if (int(com[9]) == 1) else i18n("no")
1426
+ if_save_every_weight = i18n("yes") if (int(com[10]) == 1) else i18n("no")
1427
  version = com[11]
1428
 
1429
  pretrained_base = "pretrained/" if version == "v1" else "pretrained_v2/"
 
1621
  gr.HTML("<h1> The Mangio-RVC-Fork 💻 </h1>")
1622
  gr.Markdown(
1623
  value=i18n(
1624
+ "This software is open source under the MIT agreement. The author does not have any control over the software. Those who use the software and spread the sounds derived from the software are fully responsible. <br>If you do not agree with this clause, you cannot use or reference any code and files in the software package. For details, see the root directory <b>Agreement to be followed-LICENSE.txt</b>."
1625
  )
1626
  )
1627
  with gr.Tabs():
1628
+ with gr.TabItem(i18n("Model reasoning")):
1629
  # Inference Preset Row
1630
  # with gr.Row():
1631
  # mangio_preset = gr.Dropdown(label="Inference Preset", choices=sorted(get_presets()))
 
1636
 
1637
  # Other RVC stuff
1638
  with gr.Row():
1639
+ sid0 = gr.Dropdown(label=i18n("Mystery Tone"), choices=sorted(names))
1640
+ refresh_button = gr.Button(i18n("Refresh the patch list and index path"), variant="primary")
1641
+ clean_button = gr.Button(i18n("Uninstalling sounds saves video memory"), variant="primary")
1642
  spk_item = gr.Slider(
1643
  minimum=0,
1644
  maximum=2333,
1645
  step=1,
1646
+ label=i18n("Please select the speaker id"),
1647
  value=0,
1648
  visible=False,
1649
  interactive=True,
 
1651
  clean_button.click(fn=clean, inputs=[], outputs=[sid0])
1652
  with gr.Group():
1653
  gr.Markdown(
1654
+ value=i18n("For male to female, +12key is recommended, for female to male, -12key is recommended. If the sound range explodes and causes timbre distortion, you can adjust it to the appropriate range yourself.")
1655
  )
1656
  with gr.Row():
1657
  with gr.Column():
1658
  vc_transform0 = gr.Number(
1659
+ label=i18n("Transpose(integer, number of semitones, octave up 12 octave down -12)"), value=0
1660
  )
1661
  input_audio0 = gr.Textbox(
1662
+ label=i18n("Enter the path of the audio file to be processed (the default is an example of the correct format)"),
1663
+ value="E:\\codes\\py39\\test-20230416b\\todo-songs\\winter flowers clip1.wav",
1664
  )
1665
  f0method0 = gr.Radio(
1666
  label=i18n(
1667
+ "Select the pitch extraction algorithm. You can use pm to speed up the input singing voice. Harvest has good bass but is extremely slow. Crepe has good effect but consumes GPU."
1668
  ),
1669
  choices=["pm", "harvest", "dio", "crepe", "crepe-tiny", "mangio-crepe", "mangio-crepe-tiny"], # Fork Feature. Add Crepe-Tiny
1670
  value="pm",
 
1681
  filter_radius0 = gr.Slider(
1682
  minimum=0,
1683
  maximum=7,
1684
+ label=i18n(">=3, use median filtering on the result of harvest pitch recognition, the value is the filter radius, which can reduce mute"),
1685
  value=3,
1686
  step=1,
1687
  interactive=True,
1688
  )
1689
  with gr.Column():
1690
  file_index1 = gr.Textbox(
1691
+ label=i18n("Feature retrieval library file path, if empty, use the drop-down selection result"),
1692
  value="",
1693
  interactive=True,
1694
  )
1695
  file_index2 = gr.Dropdown(
1696
+ label=i18n("Automatically detect index path, drop-down selection"),
1697
  choices=sorted(index_paths),
1698
  interactive=True,
1699
  )
 
1701
  fn=change_choices, inputs=[], outputs=[sid0, file_index2]
1702
  )
1703
  # file_big_npy1 = gr.Textbox(
1704
+ # label=i18n("Feature file path"),
1705
  # value="E:\\codes\py39\\vits_vc_gpu_train\\logs\\mi-test-1key\\total_fea.npy",
1706
  # interactive=True,
1707
  # )
1708
  index_rate1 = gr.Slider(
1709
  minimum=0,
1710
  maximum=1,
1711
+ label=i18n("Search feature proportion"),
1712
  value=0.88,
1713
  interactive=True,
1714
  )
 
1716
  resample_sr0 = gr.Slider(
1717
  minimum=0,
1718
  maximum=48000,
1719
+ label=i18n("Post-processing resampling to the final sampling rate, 0 means no resampling"),
1720
  value=0,
1721
  step=1,
1722
  interactive=True,
 
1724
  rms_mix_rate0 = gr.Slider(
1725
  minimum=0,
1726
  maximum=1,
1727
+ label=i18n("The input source volume envelope replaces the output volume envelope blending ratio. The closer it is to 1, the more the output envelope is used."),
1728
  value=1,
1729
  interactive=True,
1730
  )
 
1732
  minimum=0,
1733
  maximum=0.5,
1734
  label=i18n(
1735
+ "Protects clear consonants and breathing sounds, and prevents electronic music tearing and other artifacts. It is not enabled when it is set to 0.5. It is more effective when it is lowered, but the indexing effect may be reduced."
1736
  ),
1737
  value=0.33,
1738
  step=0.01,
1739
  interactive=True,
1740
  )
1741
+ f0_file = gr.File(label=i18n("F0 curve file, optional, one line per pitch, replaces the default F0 and sharp and flat tones"))
1742
+ but0 = gr.Button(i18n("Convert"), variant="primary")
1743
  with gr.Row():
1744
+ vc_output1 = gr.Textbox(label=i18n("Output information"))
1745
+ vc_output2 = gr.Audio(label=i18n("Output audio (three dots in the lower right corner, click to download)"))
1746
  but0.click(
1747
  vc_single,
1748
  [
 
1765
  )
1766
  with gr.Group():
1767
  gr.Markdown(
1768
+ value=i18n("Batch conversion, input the audio folder to be converted, or upload multiple audio files, and output the converted audio in the specified folder (default opt).")
1769
  )
1770
  with gr.Row():
1771
  with gr.Column():
1772
  vc_transform1 = gr.Number(
1773
+ label=i18n("Transpose(integer, number of semitones, octave up 12 octave down -12)"), value=0
1774
  )
1775
+ opt_input = gr.Textbox(label=i18n("Specify output folder"), value="opt")
1776
  f0method1 = gr.Radio(
1777
  label=i18n(
1778
+ "Select the pitch extraction algorithm. You can use pm to speed up the input singing voice. Harvest has good bass but is extremely slow. Crepe has good effect but consumes GPU."
1779
  ),
1780
  choices=["pm", "harvest", "crepe"],
1781
  value="pm",
 
1784
  filter_radius1 = gr.Slider(
1785
  minimum=0,
1786
  maximum=7,
1787
+ label=i18n(">=3, use median filtering on the result of harvest pitch recognition, the value is the filter radius, which can reduce mute"),
1788
  value=3,
1789
  step=1,
1790
  interactive=True,
1791
  )
1792
  with gr.Column():
1793
  file_index3 = gr.Textbox(
1794
+ label=i18n("Feature retrieval library file path, if empty, use the drop-down selection result"),
1795
  value="",
1796
  interactive=True,
1797
  )
1798
  file_index4 = gr.Dropdown(
1799
+ label=i18n("Automatically detect index path, drop-down selection"),
1800
  choices=sorted(index_paths),
1801
  interactive=True,
1802
  )
 
1806
  outputs=file_index4,
1807
  )
1808
  # file_big_npy2 = gr.Textbox(
1809
+ # label=i18n("Feature file path"),
1810
  # value="E:\\codes\\py39\\vits_vc_gpu_train\\logs\\mi-test-1key\\total_fea.npy",
1811
  # interactive=True,
1812
  # )
1813
  index_rate2 = gr.Slider(
1814
  minimum=0,
1815
  maximum=1,
1816
+ label=i18n("Search feature proportion"),
1817
  value=1,
1818
  interactive=True,
1819
  )
 
1821
  resample_sr1 = gr.Slider(
1822
  minimum=0,
1823
  maximum=48000,
1824
+ label=i18n("Post-processing resampling to the final sampling rate, 0 means no resampling"),
1825
  value=0,
1826
  step=1,
1827
  interactive=True,
 
1829
  rms_mix_rate1 = gr.Slider(
1830
  minimum=0,
1831
  maximum=1,
1832
+ label=i18n("The input source volume envelope replaces the output volume envelope blending ratio. The closer it is to 1, the more the output envelope is used."),
1833
  value=1,
1834
  interactive=True,
1835
  )
 
1837
  minimum=0,
1838
  maximum=0.5,
1839
  label=i18n(
1840
+ "Protects clear consonants and breathing sounds, and prevents electronic music tearing and other artifacts. It is not enabled when it is set to 0.5. It is more effective when it is lowered, but the indexing effect may be reduced."
1841
  ),
1842
  value=0.33,
1843
  step=0.01,
 
1845
  )
1846
  with gr.Column():
1847
  dir_input = gr.Textbox(
1848
+ label=i18n("Enter the path of the audio folder to be processed (just copy it from the address bar of the file manager)"),
1849
  value="E:\codes\py39\\test-20230416b\\todo-songs",
1850
  )
1851
  inputs = gr.File(
1852
+ file_count="multiple", label=i18n("You can also batch import audio files, choose one of the two, and read the folder first")
1853
  )
1854
  with gr.Row():
1855
  format1 = gr.Radio(
1856
+ label=i18n("Export file format"),
1857
  choices=["wav", "flac", "mp3", "m4a"],
1858
  value="flac",
1859
  interactive=True,
1860
  )
1861
+ but1 = gr.Button(i18n("Convert"), variant="primary")
1862
+ vc_output3 = gr.Textbox(label=i18n("Output information"))
1863
  but1.click(
1864
  vc_multi,
1865
  [
 
1891
  with gr.Group():
1892
  gr.Markdown(
1893
  value=i18n(
1894
+ "Batch processing of vocal accompaniment separation, using the UVR5 model.<br>"
1895
+ "An example of a qualified folder path format: E:\\codes\\py39\\vits_vc_gpu\\White Deer Frost Flower Test Sample (just copy it from the address bar of the file manager). <br>"
1896
+ "Models are divided into three categories: <br>"
1897
+ "1. Preserve vocals: Choose this for audio without harmony, it preserves the main vocals better than HP5. There are two models built-in, HP2 and HP3. HP3 may slightly miss the accompaniment but preserves the main vocals a little better than HP2; <br>"
1898
+ "2. Keep only the main voice: Select this for audio with harmony, which may weaken the main voice. Built-in HP5 model; <br>"
1899
+ "3. De-reverberation and de-delay model (by FoxJoy):"
1900
+ " (1) MDX-Net (onnx_dereverb): is the best choice for dual-channel reverberation, and cannot remove single-channel reverberation;"
1901
+ "&emsp;(234)DeEcho: Removes delay effects. Aggressive removes delay effects more thoroughly than Normal. DeReverb additionally removes reverberation and can remove mono reverberation, but it cannot completely remove high-frequency plate reverberation. <br>"
1902
+ "De-reverb/de-delay, attached:<br>"
1903
+ "1. The time consumption of DeEcho-DeReverb model is nearly twice that of the other two DeEcho models;<br>"
1904
+ "2. The MDX-Net-Dereverb model is quite slow;<br>"
1905
+ "3. The cleanest configuration I personally recommend is to use MDX-Net first and then DeEcho-Aggressive."
1906
  )
1907
  )
1908
  with gr.Row():
1909
  with gr.Column():
1910
  dir_wav_input = gr.Textbox(
1911
+ label=i18n("Enter the path of the audio folder to be processed"),
1912
  value="E:\\codes\\py39\\test-20230416b\\todo-songs\\todo-songs",
1913
  )
1914
  wav_inputs = gr.File(
1915
+ file_count="multiple", label=i18n("You can also batch import audio files, choose one of the two, and read the folder first")
1916
  )
1917
  with gr.Column():
1918
+ model_choose = gr.Dropdown(label=i18n("Model"), choices=uvr5_names)
1919
  agg = gr.Slider(
1920
  minimum=0,
1921
  maximum=20,
1922
  step=1,
1923
+ label="Vocal extraction aggressiveness",
1924
  value=10,
1925
  interactive=True,
1926
+ visible=False, # Not open for adjustment yet
1927
  )
1928
  opt_vocal_root = gr.Textbox(
1929
+ label=i18n("Specify the output folder for the lead vocals"), value="opt"
1930
  )
1931
  opt_ins_root = gr.Textbox(
1932
+ label=i18n("Specify the folder for outputting non-lead vocals"), value="opt"
1933
  )
1934
  format0 = gr.Radio(
1935
+ label=i18n("Export file format"),
1936
  choices=["wav", "flac", "mp3", "m4a"],
1937
  value="flac",
1938
  interactive=True,
1939
  )
1940
+ but2 = gr.Button(i18n("Convert"), variant="primary")
1941
+ vc_output4 = gr.Textbox(label=i18n("Output information"))
1942
  but2.click(
1943
  uvr,
1944
  [
 
1952
  ],
1953
  [vc_output4],
1954
  )
1955
+ with gr.TabItem(i18n("train")):
1956
  gr.Markdown(
1957
  value=i18n(
1958
+ "Step 1: Fill in the experimental configuration. The experimental data is placed under logs, one folder for each experiment. You need to manually enter the experiment name path, which contains the experimental configuration, logs, and trained model files."
1959
  )
1960
  )
1961
  with gr.Row():
1962
+ exp_dir1 = gr.Textbox(label=i18n("Enter experiment name"), value="mi-test")
1963
  sr2 = gr.Radio(
1964
+ label=i18n("target sampling rate"),
1965
  choices=["40k", "48k"],
1966
  value="40k",
1967
  interactive=True,
1968
  )
1969
  if_f0_3 = gr.Radio(
1970
+ label=i18n("Does the model have pitch guidance (must be provided for singing, but not for voice)"),
1971
  choices=[True, False],
1972
  value=True,
1973
  interactive=True,
1974
  )
1975
  version19 = gr.Radio(
1976
+ label=i18n("Version"),
1977
  choices=["v1", "v2"],
1978
  value="v1",
1979
  interactive=True,
 
1983
  minimum=0,
1984
  maximum=config.n_cpu,
1985
  step=1,
1986
+ label=i18n("The number of CPU processes used to extract pitch and process data"),
1987
  value=int(np.ceil(config.n_cpu / 1.5)),
1988
  interactive=True,
1989
  )
1990
+ with gr.Group(): # Currently single-player, will support up to 4 players later#Data processing
1991
  gr.Markdown(
1992
  value=i18n(
1993
+ "step2a: Automatically traverse all files that can be decoded into audio in the training folder and perform slice normalization, generating 2 wav folders in the experimental directory; currently only supports single-player training."
1994
  )
1995
  )
1996
  with gr.Row():
1997
  trainset_dir4 = gr.Textbox(
1998
+ label=i18n("Enter the training folder path"), value="E:\\Voice Audio+Annotation\\Kenshi Yonezu\\src"
1999
  )
2000
  spk_id5 = gr.Slider(
2001
  minimum=0,
2002
  maximum=4,
2003
  step=1,
2004
+ label=i18n("Please specify the speaker id"),
2005
  value=0,
2006
  interactive=True,
2007
  )
2008
+ but1 = gr.Button(i18n("Process data"), variant="primary")
2009
+ info1 = gr.Textbox(label=i18n("Output information"), value="")
2010
  but1.click(
2011
  preprocess_dataset, [trainset_dir4, exp_dir1, sr2, np7], [info1]
2012
  )
2013
  with gr.Group():
2014
+ gr.Markdown(value=i18n("step2b: Use CPU to extract pitch (if the model has pitch), use GPU to extract features (select card number)"))
2015
  with gr.Row():
2016
  with gr.Column():
2017
  gpus6 = gr.Textbox(
2018
+ label=i18n("Enter the card numbers to be used separated by -, for example 0-1-2 uses card 0, card 1 and card 2"),
2019
  value=gpus,
2020
  interactive=True,
2021
  )
 
2023
  with gr.Column():
2024
  f0method8 = gr.Radio(
2025
  label=i18n(
2026
+ "Select the pitch extraction algorithm: input singing voice can be accelerated by pm, high-quality voice but poor CPU can be accelerated by dio, harvest has better quality but is slow"
2027
  ),
2028
  choices=["pm", "harvest", "dio", "crepe", "mangio-crepe"], # Fork feature: Crepe on f0 extraction for training.
2029
  value="harvest",
 
2037
  value=64,
2038
  interactive=True
2039
  )
2040
+ but2 = gr.Button(i18n("Feature extraction"), variant="primary")
2041
+ info2 = gr.Textbox(label=i18n("Output information"), value="", max_lines=8)
2042
  but2.click(
2043
  extract_f0_feature,
2044
  [gpus6, np7, f0method8, if_f0_3, exp_dir1, version19, extraction_crepe_hop_length],
2045
  [info2],
2046
  )
2047
  with gr.Group():
2048
+ gr.Markdown(value=i18n("step3: Fill in the training settings and start training the model and indexing"))
2049
  with gr.Row():
2050
  save_epoch10 = gr.Slider(
2051
  minimum=0,
2052
  maximum=50,
2053
  step=1,
2054
+ label=i18n("Save frequency save_every_epoch"),
2055
  value=5,
2056
  interactive=True,
2057
  )
 
2059
  minimum=0,
2060
  maximum=10000,
2061
  step=1,
2062
+ label=i18n("Total number of training rounds total_epoch"),
2063
  value=20,
2064
  interactive=True,
2065
  )
 
2067
  minimum=1,
2068
  maximum=40,
2069
  step=1,
2070
+ label=i18n("batch_size for each graphics card"),
2071
  value=default_batch_size,
2072
  interactive=True,
2073
  )
2074
  if_save_latest13 = gr.Radio(
2075
+ label=i18n("Whether to save only the latest ckpt file to save hard disk space"),
2076
+ choices=[i18n("yes"), i18n("yes")],
2077
+ value=i18n("yes"),
2078
  interactive=True,
2079
  )
2080
  if_cache_gpu17 = gr.Radio(
2081
  label=i18n(
2082
+ "Whether to cache all training sets to the video memory. Small data under 10 minutes can be cached to speed up training. Large data cache will explode the video memory and will not increase the speed much."
2083
  ),
2084
+ choices=[i18n("yes"), i18n("no")],
2085
+ value=i18n("no"),
2086
  interactive=True,
2087
  )
2088
  if_save_every_weights18 = gr.Radio(
2089
+ label=i18n("Whether to save the final small model to the weights folder at each save time point"),
2090
+ choices=[i18n("yes"), i18n("no")],
2091
+ value=i18n("no"),
2092
  interactive=True,
2093
  )
2094
  with gr.Row():
2095
  pretrained_G14 = gr.Textbox(
2096
+ label=i18n("Load the pre-trained bottom model G path"),
2097
  value="pretrained/f0G40k.pth",
2098
  interactive=True,
2099
  )
2100
  pretrained_D15 = gr.Textbox(
2101
+ label=i18n("Load the pre-trained bottom model D path"),
2102
  value="pretrained/f0D40k.pth",
2103
  interactive=True,
2104
  )
 
2118
  [f0method8, pretrained_G14, pretrained_D15],
2119
  )
2120
  gpus16 = gr.Textbox(
2121
+ label=i18n("Enter the card numbers to be used separated by -, for example 0-1-2 uses card 0, card 1 and card 2"),
2122
  value=gpus,
2123
  interactive=True,
2124
  )
2125
+ but3 = gr.Button(i18n("Training model"), variant="primary")
2126
+ but4 = gr.Button(i18n("Training feature index"), variant="primary")
2127
+ but5 = gr.Button(i18n("One click training"), variant="primary")
2128
+ info3 = gr.Textbox(label=i18n("Output information"), value="", max_lines=10)
2129
  but3.click(
2130
  click_train,
2131
  [
 
2172
  info3,
2173
  )
2174
 
2175
+ with gr.TabItem(i18n("ckpt processing")):
2176
  with gr.Group():
2177
+ gr.Markdown(value=i18n("Model fusion, can be used to test timbre fusion"))
2178
  with gr.Row():
2179
+ ckpt_a = gr.Textbox(label=i18n("A model path"), value="", interactive=True)
2180
+ ckpt_b = gr.Textbox(label=i18n("B model path"), value="", interactive=True)
2181
  alpha_a = gr.Slider(
2182
  minimum=0,
2183
  maximum=1,
2184
+ label=i18n("A model weight"),
2185
  value=0.5,
2186
  interactive=True,
2187
  )
2188
  with gr.Row():
2189
  sr_ = gr.Radio(
2190
+ label=i18n("target sampling rate"),
2191
  choices=["40k", "48k"],
2192
  value="40k",
2193
  interactive=True,
2194
  )
2195
  if_f0_ = gr.Radio(
2196
+ label=i18n("Does the model have pitch guidance?"),
2197
+ choices=[i18n("yes"), i18n("no")],
2198
+ value=i18n("yes"),
2199
  interactive=True,
2200
  )
2201
  info__ = gr.Textbox(
2202
+ label=i18n("Model information to be placed"), value="", max_lines=8, interactive=True
2203
  )
2204
  name_to_save0 = gr.Textbox(
2205
+ label=i18n("The saved model name has no suffix"),
2206
  value="",
2207
  max_lines=1,
2208
  interactive=True,
2209
  )
2210
  version_2 = gr.Radio(
2211
+ label=i18n("Model version model"),
2212
  choices=["v1", "v2"],
2213
  value="v1",
2214
  interactive=True,
2215
  )
2216
  with gr.Row():
2217
+ but6 = gr.Button(i18n("Fusion"), variant="primary")
2218
+ info4 = gr.Textbox(label=i18n("Output information"), value="", max_lines=8)
2219
  but6.click(
2220
  merge,
2221
  [
 
2231
  info4,
2232
  ) # def merge(path1,path2,alpha1,sr,f0,info):
2233
  with gr.Group():
2234
+ gr.Markdown(value=i18n("Modify model information (only supports small model files extracted from the weights folder)"))
2235
  with gr.Row():
2236
  ckpt_path0 = gr.Textbox(
2237
+ label=i18n("model path"), value="", interactive=True
2238
  )
2239
  info_ = gr.Textbox(
2240
+ label=i18n("Model information to be changed"), value="", max_lines=8, interactive=True
2241
  )
2242
  name_to_save1 = gr.Textbox(
2243
+ label=i18n("The saved file name, the default is empty and the same as the source file name"),
2244
  value="",
2245
  max_lines=8,
2246
  interactive=True,
2247
  )
2248
  with gr.Row():
2249
+ but7 = gr.Button(i18n("Revise"), variant="primary")
2250
+ info5 = gr.Textbox(label=i18n("Output information"), value="", max_lines=8)
2251
  but7.click(change_info, [ckpt_path0, info_, name_to_save1], info5)
2252
  with gr.Group():
2253
+ gr.Markdown(value=i18n("View model information (only supports small model files extracted from the weights folder)"))
2254
  with gr.Row():
2255
  ckpt_path1 = gr.Textbox(
2256
+ label=i18n("model path"), value="", interactive=True
2257
  )
2258
+ but8 = gr.Button(i18n("Check"), variant="primary")
2259
+ info6 = gr.Textbox(label=i18n("Output information"), value="", max_lines=8)
2260
  but8.click(show_info, [ckpt_path1], info6)
2261
  with gr.Group():
2262
  gr.Markdown(
2263
  value=i18n(
2264
+ "Model extraction (enter the large file model path in the logs folder), suitable for the case where you don’t want to train the model halfway through and there is no automatic extraction to save the small file model, or you want to test the intermediate model"
2265
  )
2266
  )
2267
  with gr.Row():
2268
  ckpt_path2 = gr.Textbox(
2269
+ label=i18n("model path"),
2270
  value="E:\\codes\\py39\\logs\\mi-test_f0_48k\\G_23333.pth",
2271
  interactive=True,
2272
  )
2273
  save_name = gr.Textbox(
2274
+ label=i18n("save name"), value="", interactive=True
2275
  )
2276
  sr__ = gr.Radio(
2277
+ label=i18n("target sampling rate"),
2278
  choices=["32k", "40k", "48k"],
2279
  value="40k",
2280
  interactive=True,
2281
  )
2282
  if_f0__ = gr.Radio(
2283
+ label=i18n("Whether the model has pitch guidance, 1 for yes, 0 for no"),
2284
  choices=["1", "0"],
2285
  value="1",
2286
  interactive=True,
2287
  )
2288
  version_1 = gr.Radio(
2289
+ label=i18n("Model version model"),
2290
  choices=["v1", "v2"],
2291
  value="v2",
2292
  interactive=True,
2293
  )
2294
  info___ = gr.Textbox(
2295
+ label=i18n("Model information to be placed"), value="", max_lines=8, interactive=True
2296
  )
2297
+ but9 = gr.Button(i18n("extract"), variant="primary")
2298
+ info7 = gr.Textbox(label=i18n("Output information"), value="", max_lines=8)
2299
  ckpt_path2.change(
2300
  change_info_, [ckpt_path2], [sr__, if_f0__, version_1]
2301
  )
 
2305
  info7,
2306
  )
2307
 
2308
+ with gr.TabItem(i18n("Onnx export")):
2309
  with gr.Row():
2310
+ ckpt_dir = gr.Textbox(label=i18n("RVC model path"), value="", interactive=True)
2311
  with gr.Row():
2312
  onnx_dir = gr.Textbox(
2313
+ label=i18n("Onnx output path"), value="", interactive=True
2314
  )
2315
  with gr.Row():
2316
  infoOnnx = gr.Label(label="info")
2317
  with gr.Row():
2318
+ butOnnx = gr.Button(i18n("Exporting Onnx Models"), variant="primary")
2319
  butOnnx.click(export_onnx, [ckpt_dir, onnx_dir], infoOnnx)
2320
 
2321
+ tab_faq = i18n("FAQ")
2322
  with gr.TabItem(tab_faq):
2323
  try:
2324
+ if tab_faq == "FAQ":
2325
  with open("docs/faq.md", "r", encoding="utf8") as f:
2326
  info = f.read()
2327
  else:
 
2453
  # )
2454
  #endregion
2455
 
2456
+ # with gr.TabItem(i18n("Recruiting pitch curve front-end editor")):
2457
+ # gr.Markdown(value=i18n("Add the development group to contact me xxxxx"))
2458
+ # with gr.TabItem(i18n("Click to view the communication and problem feedback group number")):
2459
  # gr.Markdown(value=i18n("xxxxx"))
2460
 
2461
  if config.iscolab or config.paperspace: # Share gradio link for colab and paperspace (FORK FEATURE)