PhoenixStormJr commited on
Commit
dd73bc9
·
verified ·
1 Parent(s): 1c49127

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +316 -313
app.py CHANGED
@@ -1,323 +1,326 @@
1
- print("app.py is running! Congrats!")
2
- import io
3
- import os
4
- import torch
5
-
6
- # os.system("wget -P cvec/ https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/hubert_base.pt")
7
- import gradio as gr
8
- import librosa
9
- import numpy as np
10
- import soundfile
11
- import logging
12
- from fairseq import checkpoint_utils
13
- from my_utils import load_audio
14
- from vc_infer_pipeline import VC
15
- import traceback
16
- from config import Config
17
- from infer_pack.models import (
18
- SynthesizerTrnMs256NSFsid,
19
- SynthesizerTrnMs256NSFsid_nono,
20
- SynthesizerTrnMs768NSFsid,
21
- SynthesizerTrnMs768NSFsid_nono,
22
- )
23
- from i18n import I18nAuto
24
-
25
- logging.getLogger("numba").setLevel(logging.WARNING)
26
- logging.getLogger("markdown_it").setLevel(logging.WARNING)
27
- logging.getLogger("urllib3").setLevel(logging.WARNING)
28
- logging.getLogger("matplotlib").setLevel(logging.WARNING)
29
-
30
- i18n = I18nAuto()
31
- i18n.print()
32
-
33
- config = Config()
34
-
35
- weight_root = "weights"
36
- weight_uvr5_root = "uvr5_weights"
37
- index_root = "logs"
38
- names = []
39
- hubert_model = None
40
- for name in os.listdir(weight_root):
41
- if name.endswith(".pth"):
42
- names.append(name)
43
- index_paths = []
44
- for root, dirs, files in os.walk(index_root, topdown=False):
45
- for name in files:
46
- if name.endswith(".index") and "trained" not in name:
47
- index_paths.append("%s/%s" % (root, name))
48
-
49
-
50
- def get_vc(sid):
51
- global n_spk, tgt_sr, net_g, vc, cpt, version
52
- if sid == "" or sid == []:
53
- global hubert_model
54
- if hubert_model != None: # 考虑到轮询, 需要加个判断看是否 sid 是由有模型切换到无模型的
55
- print("clean_empty_cache")
56
- del net_g, n_spk, vc, hubert_model, tgt_sr # ,cpt
57
- hubert_model = net_g = n_spk = vc = hubert_model = tgt_sr = None
58
- if torch.cuda.is_available():
59
- torch.cuda.empty_cache()
60
- ###楼下不这么折腾清理不干净
61
- if_f0 = cpt.get("f0", 1)
62
- version = cpt.get("version", "v1")
63
- if version == "v1":
64
- if if_f0 == 1:
65
- net_g = SynthesizerTrnMs256NSFsid(
66
- *cpt["config"], is_half=config.is_half
67
- )
68
- else:
69
- net_g = SynthesizerTrnMs256NSFsid_nono(*cpt["config"])
70
- elif version == "v2":
71
- if if_f0 == 1:
72
- net_g = SynthesizerTrnMs768NSFsid(
73
- *cpt["config"], is_half=config.is_half
74
- )
75
- else:
76
- net_g = SynthesizerTrnMs768NSFsid_nono(*cpt["config"])
77
- del net_g, cpt
78
- if torch.cuda.is_available():
79
- torch.cuda.empty_cache()
80
- cpt = None
81
- return {"visible": False, "__type__": "update"}
82
- person = "%s/%s" % (weight_root, sid)
83
- print("loading %s" % person)
84
- cpt = torch.load(person, map_location="cpu")
85
- tgt_sr = cpt["config"][-1]
86
- cpt["config"][-3] = cpt["weight"]["emb_g.weight"].shape[0] # n_spk
87
- if_f0 = cpt.get("f0", 1)
88
- version = cpt.get("version", "v1")
89
- if version == "v1":
90
- if if_f0 == 1:
91
- net_g = SynthesizerTrnMs256NSFsid(*cpt["config"], is_half=config.is_half)
92
- else:
93
- net_g = SynthesizerTrnMs256NSFsid_nono(*cpt["config"])
94
- elif version == "v2":
95
- if if_f0 == 1:
96
- net_g = SynthesizerTrnMs768NSFsid(*cpt["config"], is_half=config.is_half)
97
- else:
98
- net_g = SynthesizerTrnMs768NSFsid_nono(*cpt["config"])
99
- del net_g.enc_q
100
- print(net_g.load_state_dict(cpt["weight"], strict=False))
101
- net_g.eval().to(config.device)
102
- if config.is_half:
103
- net_g = net_g.half()
104
- else:
105
- net_g = net_g.float()
106
- vc = VC(tgt_sr, config)
107
- n_spk = cpt["config"][-3]
108
- return {"visible": True, "maximum": n_spk, "__type__": "update"}
109
-
110
-
111
- def load_hubert():
112
- global hubert_model
113
- models, _, _ = checkpoint_utils.load_model_ensemble_and_task(
114
- ["hubert_base.pt"],
115
- suffix="",
116
  )
117
- hubert_model = models[0]
118
- hubert_model = hubert_model.to(config.device)
119
- if config.is_half:
120
- hubert_model = hubert_model.half()
121
- else:
122
- hubert_model = hubert_model.float()
123
- hubert_model.eval()
124
-
125
-
126
- def vc_single(
127
- sid,
128
- input_audio_path,
129
- f0_up_key,
130
- f0_file,
131
- f0_method,
132
- file_index,
133
- file_index2,
134
- # file_big_npy,
135
- index_rate,
136
- filter_radius,
137
- resample_sr,
138
- rms_mix_rate,
139
- protect,
140
- ): # spk_item, input_audio0, vc_transform0,f0_file,f0method0
141
- global tgt_sr, net_g, vc, hubert_model, version
142
- if input_audio_path is None:
143
- return "You need to upload an audio", None
144
- f0_up_key = int(f0_up_key)
145
- try:
146
- audio = input_audio_path[1] / 32768.0
147
- if len(audio.shape) == 2:
148
- audio = np.mean(audio, -1)
149
- audio = librosa.resample(audio, orig_sr=input_audio_path[0], target_sr=16000)
150
- audio_max = np.abs(audio).max() / 0.95
151
- if audio_max > 1:
152
- audio /= audio_max
153
- times = [0, 0, 0]
154
- if hubert_model == None:
155
- load_hubert()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
156
  if_f0 = cpt.get("f0", 1)
157
- file_index = (
158
- (
159
- file_index.strip(" ")
160
- .strip('"')
161
- .strip("\n")
162
- .strip('"')
163
- .strip(" ")
164
- .replace("trained", "added")
165
- )
166
- if file_index != ""
167
- else file_index2
168
- ) # 防止小白写错,自动帮他替换掉
169
- # file_big_npy = (
170
- # file_big_npy.strip(" ").strip('"').strip("\n").strip('"').strip(" ")
171
- # )
172
- audio_opt = vc.pipeline(
173
- hubert_model,
174
- net_g,
175
- sid,
176
- audio,
177
- input_audio_path,
178
- times,
179
- f0_up_key,
180
- f0_method,
181
- file_index,
182
- # file_big_npy,
183
- index_rate,
184
- if_f0,
185
- filter_radius,
186
- tgt_sr,
187
- resample_sr,
188
- rms_mix_rate,
189
- version,
190
- protect,
191
- f0_file=f0_file,
192
- )
193
- if resample_sr >= 16000 and tgt_sr != resample_sr:
194
- tgt_sr = resample_sr
195
- index_info = (
196
- "Using index:%s." % file_index
197
- if os.path.exists(file_index)
198
- else "Index not used."
199
  )
200
- return "Success.\n %s\nTime:\n npy:%ss, f0:%ss, infer:%ss" % (
201
- index_info,
202
- times[0],
203
- times[1],
204
- times[2],
205
- ), (tgt_sr, audio_opt)
206
- except:
207
- info = traceback.format_exc()
208
- print(info)
209
- return info, (None, None)
210
-
211
-
212
- app = gr.Blocks()
213
- with app:
214
- with gr.Tabs():
215
- with gr.TabItem("在线demo"):
216
- gr.Markdown(
217
- value="""
218
- RVC 在线demo
219
- """
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
220
  )
221
- sid = gr.Dropdown(label=i18n("推理音色"), choices=sorted(names))
222
- with gr.Column():
223
- spk_item = gr.Slider(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
224
  minimum=0,
225
- maximum=2333,
 
 
226
  step=1,
227
- label=i18n("请选择说话人id"),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
228
  value=0,
229
- visible=False,
230
  interactive=True,
231
  )
232
- sid.change(
233
- fn=get_vc,
234
- inputs=[sid],
235
- outputs=[spk_item],
236
- )
237
- gr.Markdown(
238
- value=i18n("男转女推荐+12key, 女转男推荐-12key, 如果音域爆炸导致音色失真也可以自己调整到合适音域. ")
239
- )
240
- vc_input3 = gr.Audio(label="上传音频(长度小于90秒)")
241
- vc_transform0 = gr.Number(label=i18n("变调(整数, 半音数量, 升八度12降八度-12)"), value=0)
242
- f0method0 = gr.Radio(
243
- label=i18n("选择音高提取算法,输入歌声可用pm提速,harvest低音好但巨慢无比,crepe效果好但吃GPU"),
244
- choices=["pm", "harvest", "crepe"],
245
- value="pm",
246
- interactive=True,
247
- )
248
- filter_radius0 = gr.Slider(
249
- minimum=0,
250
- maximum=7,
251
- label=i18n(">=3则使用对harvest音高识别的结果使用中值滤波,数值为滤波半径,使用可以削弱哑音"),
252
- value=3,
253
- step=1,
254
- interactive=True,
255
- )
256
- with gr.Column():
257
- file_index1 = gr.Textbox(
258
- label=i18n("特征检索库文件路径,为空则使用下拉的选择结果"),
259
- value="",
260
- interactive=False,
261
- visible=False,
262
  )
263
- file_index2 = gr.Dropdown(
264
- label=i18n("自动检测index路径,下拉式选择(dropdown)"),
265
- choices=sorted(index_paths),
266
- interactive=True,
267
- )
268
- index_rate1 = gr.Slider(
269
- minimum=0,
270
- maximum=1,
271
- label=i18n("检索特征占比"),
272
- value=0.88,
273
- interactive=True,
274
- )
275
- resample_sr0 = gr.Slider(
276
- minimum=0,
277
- maximum=48000,
278
- label=i18n("后处理重采样至最终采样率,0为不进行重采样"),
279
- value=0,
280
- step=1,
281
- interactive=True,
282
- )
283
- rms_mix_rate0 = gr.Slider(
284
- minimum=0,
285
- maximum=1,
286
- label=i18n("输入源音量包络替换输出音量包络融合比例,越靠近1越使用输出包络"),
287
- value=1,
288
- interactive=True,
289
- )
290
- protect0 = gr.Slider(
291
- minimum=0,
292
- maximum=0.5,
293
- label=i18n("保护清辅音和呼吸声,防止电音撕裂等artifact,拉满0.5不开启,调低加大保护力度但可能降低索引效果"),
294
- value=0.33,
295
- step=0.01,
296
- interactive=True,
297
- )
298
- f0_file = gr.File(label=i18n("F0曲线文件, 可选, 一行一个音高, 代替默认F0及升降调"))
299
- but0 = gr.Button(i18n("转换"), variant="primary")
300
- vc_output1 = gr.Textbox(label=i18n("输出信息"))
301
- vc_output2 = gr.Audio(label=i18n("输出音频(右下角三个点,点了可以下载)"))
302
- but0.click(
303
- vc_single,
304
- [
305
- spk_item,
306
- vc_input3,
307
- vc_transform0,
308
- f0_file,
309
- f0method0,
310
- file_index1,
311
- file_index2,
312
- # file_big_npy1,
313
- index_rate1,
314
- filter_radius0,
315
- resample_sr0,
316
- rms_mix_rate0,
317
- protect0,
318
- ],
319
- [vc_output1, vc_output2],
320
- )
321
-
322
-
323
- app.launch()
 
1
+ try:
2
+ print("app.py is running! Congrats!")
3
+ import io
4
+ import os
5
+ import torch
6
+
7
+ # os.system("wget -P cvec/ https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/hubert_base.pt")
8
+ import gradio as gr
9
+ import librosa
10
+ import numpy as np
11
+ import soundfile
12
+ import logging
13
+ from fairseq import checkpoint_utils
14
+ from my_utils import load_audio
15
+ from vc_infer_pipeline import VC
16
+ import traceback
17
+ from config import Config
18
+ from infer_pack.models import (
19
+ SynthesizerTrnMs256NSFsid,
20
+ SynthesizerTrnMs256NSFsid_nono,
21
+ SynthesizerTrnMs768NSFsid,
22
+ SynthesizerTrnMs768NSFsid_nono,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  )
24
+ from i18n import I18nAuto
25
+
26
+ logging.getLogger("numba").setLevel(logging.WARNING)
27
+ logging.getLogger("markdown_it").setLevel(logging.WARNING)
28
+ logging.getLogger("urllib3").setLevel(logging.WARNING)
29
+ logging.getLogger("matplotlib").setLevel(logging.WARNING)
30
+
31
+ i18n = I18nAuto()
32
+ i18n.print()
33
+
34
+ config = Config()
35
+
36
+ weight_root = "weights"
37
+ weight_uvr5_root = "uvr5_weights"
38
+ index_root = "logs"
39
+ names = []
40
+ hubert_model = None
41
+ for name in os.listdir(weight_root):
42
+ if name.endswith(".pth"):
43
+ names.append(name)
44
+ index_paths = []
45
+ for root, dirs, files in os.walk(index_root, topdown=False):
46
+ for name in files:
47
+ if name.endswith(".index") and "trained" not in name:
48
+ index_paths.append("%s/%s" % (root, name))
49
+
50
+
51
+ def get_vc(sid):
52
+ global n_spk, tgt_sr, net_g, vc, cpt, version
53
+ if sid == "" or sid == []:
54
+ global hubert_model
55
+ if hubert_model != None: # 考虑到轮询, 需要加个判断看是否 sid 是由有模型切换到无模型的
56
+ print("clean_empty_cache")
57
+ del net_g, n_spk, vc, hubert_model, tgt_sr # ,cpt
58
+ hubert_model = net_g = n_spk = vc = hubert_model = tgt_sr = None
59
+ if torch.cuda.is_available():
60
+ torch.cuda.empty_cache()
61
+ ###楼下不这么折腾清理不干净
62
+ if_f0 = cpt.get("f0", 1)
63
+ version = cpt.get("version", "v1")
64
+ if version == "v1":
65
+ if if_f0 == 1:
66
+ net_g = SynthesizerTrnMs256NSFsid(
67
+ *cpt["config"], is_half=config.is_half
68
+ )
69
+ else:
70
+ net_g = SynthesizerTrnMs256NSFsid_nono(*cpt["config"])
71
+ elif version == "v2":
72
+ if if_f0 == 1:
73
+ net_g = SynthesizerTrnMs768NSFsid(
74
+ *cpt["config"], is_half=config.is_half
75
+ )
76
+ else:
77
+ net_g = SynthesizerTrnMs768NSFsid_nono(*cpt["config"])
78
+ del net_g, cpt
79
+ if torch.cuda.is_available():
80
+ torch.cuda.empty_cache()
81
+ cpt = None
82
+ return {"visible": False, "__type__": "update"}
83
+ person = "%s/%s" % (weight_root, sid)
84
+ print("loading %s" % person)
85
+ cpt = torch.load(person, map_location="cpu")
86
+ tgt_sr = cpt["config"][-1]
87
+ cpt["config"][-3] = cpt["weight"]["emb_g.weight"].shape[0] # n_spk
88
  if_f0 = cpt.get("f0", 1)
89
+ version = cpt.get("version", "v1")
90
+ if version == "v1":
91
+ if if_f0 == 1:
92
+ net_g = SynthesizerTrnMs256NSFsid(*cpt["config"], is_half=config.is_half)
93
+ else:
94
+ net_g = SynthesizerTrnMs256NSFsid_nono(*cpt["config"])
95
+ elif version == "v2":
96
+ if if_f0 == 1:
97
+ net_g = SynthesizerTrnMs768NSFsid(*cpt["config"], is_half=config.is_half)
98
+ else:
99
+ net_g = SynthesizerTrnMs768NSFsid_nono(*cpt["config"])
100
+ del net_g.enc_q
101
+ print(net_g.load_state_dict(cpt["weight"], strict=False))
102
+ net_g.eval().to(config.device)
103
+ if config.is_half:
104
+ net_g = net_g.half()
105
+ else:
106
+ net_g = net_g.float()
107
+ vc = VC(tgt_sr, config)
108
+ n_spk = cpt["config"][-3]
109
+ return {"visible": True, "maximum": n_spk, "__type__": "update"}
110
+
111
+
112
+ def load_hubert():
113
+ global hubert_model
114
+ models, _, _ = checkpoint_utils.load_model_ensemble_and_task(
115
+ ["hubert_base.pt"],
116
+ suffix="",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
117
  )
118
+ hubert_model = models[0]
119
+ hubert_model = hubert_model.to(config.device)
120
+ if config.is_half:
121
+ hubert_model = hubert_model.half()
122
+ else:
123
+ hubert_model = hubert_model.float()
124
+ hubert_model.eval()
125
+
126
+
127
+ def vc_single(
128
+ sid,
129
+ input_audio_path,
130
+ f0_up_key,
131
+ f0_file,
132
+ f0_method,
133
+ file_index,
134
+ file_index2,
135
+ # file_big_npy,
136
+ index_rate,
137
+ filter_radius,
138
+ resample_sr,
139
+ rms_mix_rate,
140
+ protect,
141
+ ): # spk_item, input_audio0, vc_transform0,f0_file,f0method0
142
+ global tgt_sr, net_g, vc, hubert_model, version
143
+ if input_audio_path is None:
144
+ return "You need to upload an audio", None
145
+ f0_up_key = int(f0_up_key)
146
+ try:
147
+ audio = input_audio_path[1] / 32768.0
148
+ if len(audio.shape) == 2:
149
+ audio = np.mean(audio, -1)
150
+ audio = librosa.resample(audio, orig_sr=input_audio_path[0], target_sr=16000)
151
+ audio_max = np.abs(audio).max() / 0.95
152
+ if audio_max > 1:
153
+ audio /= audio_max
154
+ times = [0, 0, 0]
155
+ if hubert_model == None:
156
+ load_hubert()
157
+ if_f0 = cpt.get("f0", 1)
158
+ file_index = (
159
+ (
160
+ file_index.strip(" ")
161
+ .strip('"')
162
+ .strip("\n")
163
+ .strip('"')
164
+ .strip(" ")
165
+ .replace("trained", "added")
166
+ )
167
+ if file_index != ""
168
+ else file_index2
169
+ ) # 防止小白写错,自动帮他替换掉
170
+ # file_big_npy = (
171
+ # file_big_npy.strip(" ").strip('"').strip("\n").strip('"').strip(" ")
172
+ # )
173
+ audio_opt = vc.pipeline(
174
+ hubert_model,
175
+ net_g,
176
+ sid,
177
+ audio,
178
+ input_audio_path,
179
+ times,
180
+ f0_up_key,
181
+ f0_method,
182
+ file_index,
183
+ # file_big_npy,
184
+ index_rate,
185
+ if_f0,
186
+ filter_radius,
187
+ tgt_sr,
188
+ resample_sr,
189
+ rms_mix_rate,
190
+ version,
191
+ protect,
192
+ f0_file=f0_file,
193
+ )
194
+ if resample_sr >= 16000 and tgt_sr != resample_sr:
195
+ tgt_sr = resample_sr
196
+ index_info = (
197
+ "Using index:%s." % file_index
198
+ if os.path.exists(file_index)
199
+ else "Index not used."
200
  )
201
+ return "Success.\n %s\nTime:\n npy:%ss, f0:%ss, infer:%ss" % (
202
+ index_info,
203
+ times[0],
204
+ times[1],
205
+ times[2],
206
+ ), (tgt_sr, audio_opt)
207
+ except:
208
+ info = traceback.format_exc()
209
+ print(info)
210
+ return info, (None, None)
211
+
212
+
213
+ app = gr.Blocks()
214
+ with app:
215
+ with gr.Tabs():
216
+ with gr.TabItem("在线demo"):
217
+ gr.Markdown(
218
+ value="""
219
+ RVC 在线demo
220
+ """
221
+ )
222
+ sid = gr.Dropdown(label=i18n("推理音色"), choices=sorted(names))
223
+ with gr.Column():
224
+ spk_item = gr.Slider(
225
+ minimum=0,
226
+ maximum=2333,
227
+ step=1,
228
+ label=i18n("请选择说话人id"),
229
+ value=0,
230
+ visible=False,
231
+ interactive=True,
232
+ )
233
+ sid.change(
234
+ fn=get_vc,
235
+ inputs=[sid],
236
+ outputs=[spk_item],
237
+ )
238
+ gr.Markdown(
239
+ value=i18n("男转女推荐+12key, 女转男推荐-12key, 如果音域爆炸导致音色失真也可以自己调整到合适音域. ")
240
+ )
241
+ vc_input3 = gr.Audio(label="上传音频(长度小于90秒)")
242
+ vc_transform0 = gr.Number(label=i18n("变调(整数, 半音数量, 升八度12降八度-12)"), value=0)
243
+ f0method0 = gr.Radio(
244
+ label=i18n("选择音高提取算法,输入歌声可用pm提速,harvest低音好但巨慢无比,crepe效果好但吃GPU"),
245
+ choices=["pm", "harvest", "crepe"],
246
+ value="pm",
247
+ interactive=True,
248
+ )
249
+ filter_radius0 = gr.Slider(
250
  minimum=0,
251
+ maximum=7,
252
+ label=i18n(">=3则使用对harvest音高识别的结果使用中值滤波,数值为滤波半径,使用可以削弱哑音"),
253
+ value=3,
254
  step=1,
255
+ interactive=True,
256
+ )
257
+ with gr.Column():
258
+ file_index1 = gr.Textbox(
259
+ label=i18n("特征检索库文件路径,为空则使用下拉的选择结果"),
260
+ value="",
261
+ interactive=False,
262
+ visible=False,
263
+ )
264
+ file_index2 = gr.Dropdown(
265
+ label=i18n("自动检测index路径,下拉式选择(dropdown)"),
266
+ choices=sorted(index_paths),
267
+ interactive=True,
268
+ )
269
+ index_rate1 = gr.Slider(
270
+ minimum=0,
271
+ maximum=1,
272
+ label=i18n("检索特征占比"),
273
+ value=0.88,
274
+ interactive=True,
275
+ )
276
+ resample_sr0 = gr.Slider(
277
+ minimum=0,
278
+ maximum=48000,
279
+ label=i18n("后处理重采样至最终采样率,0为不进行重采样"),
280
  value=0,
281
+ step=1,
282
  interactive=True,
283
  )
284
+ rms_mix_rate0 = gr.Slider(
285
+ minimum=0,
286
+ maximum=1,
287
+ label=i18n("输入源音量包络替换输出音量包络融合比例,越靠近1越使用输出包络"),
288
+ value=1,
289
+ interactive=True,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
290
  )
291
+ protect0 = gr.Slider(
292
+ minimum=0,
293
+ maximum=0.5,
294
+ label=i18n("保护清辅音和呼吸声,防止电音撕裂等artifact,拉满0.5不开启,调低加大保护力度但可能降低索引效果"),
295
+ value=0.33,
296
+ step=0.01,
297
+ interactive=True,
298
+ )
299
+ f0_file = gr.File(label=i18n("F0曲线文件, 可选, 一行一个音高, 代替默认F0及升降调"))
300
+ but0 = gr.Button(i18n("转换"), variant="primary")
301
+ vc_output1 = gr.Textbox(label=i18n("输出信息"))
302
+ vc_output2 = gr.Audio(label=i18n("输出音频(右下角三个点,点了可以下载)"))
303
+ but0.click(
304
+ vc_single,
305
+ [
306
+ spk_item,
307
+ vc_input3,
308
+ vc_transform0,
309
+ f0_file,
310
+ f0method0,
311
+ file_index1,
312
+ file_index2,
313
+ # file_big_npy1,
314
+ index_rate1,
315
+ filter_radius0,
316
+ resample_sr0,
317
+ rms_mix_rate0,
318
+ protect0,
319
+ ],
320
+ [vc_output1, vc_output2],
321
+ )
322
+
323
+
324
+ app.launch()
325
+ except Exception as e:
326
+ print("Startup error:", e)