Ilzhabimantara commited on
Commit
df63d65
1 Parent(s): a477d7b

Create app-2.py

Browse files
Files changed (1) hide show
  1. app-2.py +521 -0
app-2.py ADDED
@@ -0,0 +1,521 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import glob
3
+ import json
4
+ import traceback
5
+ import logging
6
+ import gradio as gr
7
+ import numpy as np
8
+ import librosa
9
+ import torch
10
+ import asyncio
11
+ import edge_tts
12
+ import yt_dlp
13
+ import ffmpeg
14
+ import subprocess
15
+ import sys
16
+ import io
17
+ import wave
18
+ from datetime import datetime
19
+ from fairseq import checkpoint_utils
20
+ from lib.infer_pack.models import (
21
+ SynthesizerTrnMs256NSFsid,
22
+ SynthesizerTrnMs256NSFsid_nono,
23
+ SynthesizerTrnMs768NSFsid,
24
+ SynthesizerTrnMs768NSFsid_nono,
25
+ )
26
+ from vc_infer_pipeline import VC
27
+ from config import Config
28
+ config = Config()
29
+ logging.getLogger("numba").setLevel(logging.WARNING)
30
+ limitation = os.getenv("SYSTEM") == "spaces"
31
+
32
+ audio_mode = []
33
+ f0method_mode = []
34
+ f0method_info = ""
35
+ if limitation is True:
36
+ audio_mode = ["Upload audio", "TTS Audio"]
37
+ f0method_mode = ["pm", "harvest"]
38
+ f0method_info = "PM is fast, Harvest is good but extremely slow. (Default: PM)"
39
+ else:
40
+ audio_mode = ["Input path", "Upload audio", "Youtube", "TTS Audio"]
41
+ f0method_mode = ["pm", "harvest", "crepe"]
42
+ f0method_info = "PM is fast, Harvest is good but extremely slow, and Crepe effect is good but requires GPU (Default: PM)"
43
+
44
+ def create_vc_fn(model_title, tgt_sr, net_g, vc, if_f0, version, file_index):
45
+ def vc_fn(
46
+ vc_audio_mode,
47
+ vc_input,
48
+ vc_upload,
49
+ tts_text,
50
+ tts_voice,
51
+ f0_up_key,
52
+ f0_method,
53
+ index_rate,
54
+ filter_radius,
55
+ resample_sr,
56
+ rms_mix_rate,
57
+ protect,
58
+ ):
59
+ try:
60
+ if vc_audio_mode == "Input path" or "Youtube" and vc_input != "":
61
+ audio, sr = librosa.load(vc_input, sr=16000, mono=True)
62
+ elif vc_audio_mode == "Upload audio":
63
+ if vc_upload is None:
64
+ return "You need to upload an audio", None
65
+ sampling_rate, audio = vc_upload
66
+ duration = audio.shape[0] / sampling_rate
67
+ if duration > 20 and limitation:
68
+ return "Please upload an audio file that is less than 20 seconds. If you need to generate a longer audio file, please use Colab.", None
69
+ audio = (audio / np.iinfo(audio.dtype).max).astype(np.float32)
70
+ if len(audio.shape) > 1:
71
+ audio = librosa.to_mono(audio.transpose(1, 0))
72
+ if sampling_rate != 16000:
73
+ audio = librosa.resample(audio, orig_sr=sampling_rate, target_sr=16000)
74
+ elif vc_audio_mode == "TTS Audio":
75
+ if len(tts_text) > 100 and limitation:
76
+ return "Text is too long", None
77
+ if tts_text is None or tts_voice is None:
78
+ return "You need to enter text and select a voice", None
79
+ asyncio.run(edge_tts.Communicate(tts_text, "-".join(tts_voice.split('-')[:-1])).save("tts.mp3"))
80
+ audio, sr = librosa.load("tts.mp3", sr=16000, mono=True)
81
+ vc_input = "tts.mp3"
82
+ times = [0, 0, 0]
83
+ f0_up_key = int(f0_up_key)
84
+ audio_opt = vc.pipeline(
85
+ hubert_model,
86
+ net_g,
87
+ 0,
88
+ audio,
89
+ vc_input,
90
+ times,
91
+ f0_up_key,
92
+ f0_method,
93
+ file_index,
94
+ # file_big_npy,
95
+ index_rate,
96
+ if_f0,
97
+ filter_radius,
98
+ tgt_sr,
99
+ resample_sr,
100
+ rms_mix_rate,
101
+ version,
102
+ protect,
103
+ f0_file=None,
104
+ )
105
+ info = f"[{datetime.now().strftime('%Y-%m-%d %H:%M')}]: npy: {times[0]}, f0: {times[1]}s, infer: {times[2]}s"
106
+ print(f"{model_title} | {info}")
107
+ return info, (tgt_sr, audio_opt)
108
+ except:
109
+ info = traceback.format_exc()
110
+ print(info)
111
+ return info, None
112
+ return vc_fn
113
+
114
+ def load_model():
115
+ categories = []
116
+ with open("weights/folder_info.json", "r", encoding="utf-8") as f:
117
+ folder_info = json.load(f)
118
+ for category_name, category_info in folder_info.items():
119
+ if not category_info['enable']:
120
+ continue
121
+ category_title = category_info['title']
122
+ category_folder = category_info['folder_path']
123
+ description = category_info['description']
124
+ models = []
125
+ with open(f"weights/{category_folder}/model_info.json", "r", encoding="utf-8") as f:
126
+ models_info = json.load(f)
127
+ for character_name, info in models_info.items():
128
+ if not info['enable']:
129
+ continue
130
+ model_title = info['title']
131
+ model_name = info['model_path']
132
+ model_author = info.get("author", None)
133
+ model_cover = f"weights/{category_folder}/{character_name}/{info['cover']}"
134
+ model_index = f"weights/{category_folder}/{character_name}/{info['feature_retrieval_library']}"
135
+ cpt = torch.load(f"weights/{category_folder}/{character_name}/{model_name}", map_location="cpu")
136
+ tgt_sr = cpt["config"][-1]
137
+ cpt["config"][-3] = cpt["weight"]["emb_g.weight"].shape[0] # n_spk
138
+ if_f0 = cpt.get("f0", 1)
139
+ version = cpt.get("version", "v1")
140
+ if version == "v1":
141
+ if if_f0 == 1:
142
+ net_g = SynthesizerTrnMs256NSFsid(*cpt["config"], is_half=config.is_half)
143
+ else:
144
+ net_g = SynthesizerTrnMs256NSFsid_nono(*cpt["config"])
145
+ model_version = "V1"
146
+ elif version == "v2":
147
+ if if_f0 == 1:
148
+ net_g = SynthesizerTrnMs768NSFsid(*cpt["config"], is_half=config.is_half)
149
+ else:
150
+ net_g = SynthesizerTrnMs768NSFsid_nono(*cpt["config"])
151
+ model_version = "V2"
152
+ del net_g.enc_q
153
+ print(net_g.load_state_dict(cpt["weight"], strict=False))
154
+ net_g.eval().to(config.device)
155
+ if config.is_half:
156
+ net_g = net_g.half()
157
+ else:
158
+ net_g = net_g.float()
159
+ vc = VC(tgt_sr, config)
160
+ print(f"Model loaded: {character_name} / {info['feature_retrieval_library']} | ({model_version})")
161
+ models.append((character_name, model_title, model_author, model_cover, model_version, create_vc_fn(model_title, tgt_sr, net_g, vc, if_f0, version, model_index)))
162
+ categories.append([category_title, category_folder, description, models])
163
+ return categories
164
+
165
+ def cut_vocal_and_inst(url, audio_provider, split_model):
166
+ if url != "":
167
+ if not os.path.exists("dl_audio"):
168
+ os.mkdir("dl_audio")
169
+ if audio_provider == "Youtube":
170
+ ydl_opts = {
171
+ 'noplaylist': True,
172
+ 'format': 'bestaudio/best',
173
+ 'postprocessors': [{
174
+ 'key': 'FFmpegExtractAudio',
175
+ 'preferredcodec': 'wav',
176
+ }],
177
+ "outtmpl": 'dl_audio/youtube_audio',
178
+ }
179
+ with yt_dlp.YoutubeDL(ydl_opts) as ydl:
180
+ ydl.download([url])
181
+ audio_path = "dl_audio/youtube_audio.wav"
182
+ if split_model == "htdemucs":
183
+ command = f"demucs --two-stems=vocals {audio_path} -o output"
184
+ result = subprocess.run(command.split(), stdout=subprocess.PIPE)
185
+ print(result.stdout.decode())
186
+ return "output/htdemucs/youtube_audio/vocals.wav", "output/htdemucs/youtube_audio/no_vocals.wav", audio_path, "output/htdemucs/youtube_audio/vocals.wav"
187
+ else:
188
+ command = f"demucs --two-stems=vocals -n mdx_extra_q {audio_path} -o output"
189
+ result = subprocess.run(command.split(), stdout=subprocess.PIPE)
190
+ print(result.stdout.decode())
191
+ return "output/mdx_extra_q/youtube_audio/vocals.wav", "output/mdx_extra_q/youtube_audio/no_vocals.wav", audio_path, "output/mdx_extra_q/youtube_audio/vocals.wav"
192
+ else:
193
+ raise gr.Error("URL Required!")
194
+ return None, None, None, None
195
+
196
+ def combine_vocal_and_inst(audio_data, audio_volume, split_model):
197
+ if not os.path.exists("output/result"):
198
+ os.mkdir("output/result")
199
+ vocal_path = "output/result/output.wav"
200
+ output_path = "output/result/combine.mp3"
201
+ if split_model == "htdemucs":
202
+ inst_path = "output/htdemucs/youtube_audio/no_vocals.wav"
203
+ else:
204
+ inst_path = "output/mdx_extra_q/youtube_audio/no_vocals.wav"
205
+ with wave.open(vocal_path, "w") as wave_file:
206
+ wave_file.setnchannels(1)
207
+ wave_file.setsampwidth(2)
208
+ wave_file.setframerate(audio_data[0])
209
+ wave_file.writeframes(audio_data[1].tobytes())
210
+ command = f'ffmpeg -y -i {inst_path} -i {vocal_path} -filter_complex [1:a]volume={audio_volume}dB[v];[0:a][v]amix=inputs=2:duration=longest -b:a 320k -c:a libmp3lame {output_path}'
211
+ result = subprocess.run(command.split(), stdout=subprocess.PIPE)
212
+ print(result.stdout.decode())
213
+ return output_path
214
+
215
+ def load_hubert():
216
+ global hubert_model
217
+ models, _, _ = checkpoint_utils.load_model_ensemble_and_task(
218
+ ["hubert_base.pt"],
219
+ suffix="",
220
+ )
221
+ hubert_model = models[0]
222
+ hubert_model = hubert_model.to(config.device)
223
+ if config.is_half:
224
+ hubert_model = hubert_model.half()
225
+ else:
226
+ hubert_model = hubert_model.float()
227
+ hubert_model.eval()
228
+
229
+ def change_audio_mode(vc_audio_mode):
230
+ if vc_audio_mode == "Input path":
231
+ return (
232
+ # Input & Upload
233
+ gr.Textbox.update(visible=True),
234
+ gr.Checkbox.update(visible=False),
235
+ gr.Audio.update(visible=False),
236
+ # Youtube
237
+ gr.Dropdown.update(visible=False),
238
+ gr.Textbox.update(visible=False),
239
+ gr.Dropdown.update(visible=False),
240
+ gr.Button.update(visible=False),
241
+ gr.Audio.update(visible=False),
242
+ gr.Audio.update(visible=False),
243
+ gr.Audio.update(visible=False),
244
+ gr.Slider.update(visible=False),
245
+ gr.Audio.update(visible=False),
246
+ gr.Button.update(visible=False),
247
+ # TTS
248
+ gr.Textbox.update(visible=False),
249
+ gr.Dropdown.update(visible=False)
250
+ )
251
+ elif vc_audio_mode == "Upload audio":
252
+ return (
253
+ # Input & Upload
254
+ gr.Textbox.update(visible=False),
255
+ gr.Checkbox.update(visible=True),
256
+ gr.Audio.update(visible=True),
257
+ # Youtube
258
+ gr.Dropdown.update(visible=False),
259
+ gr.Textbox.update(visible=False),
260
+ gr.Dropdown.update(visible=False),
261
+ gr.Button.update(visible=False),
262
+ gr.Audio.update(visible=False),
263
+ gr.Audio.update(visible=False),
264
+ gr.Audio.update(visible=False),
265
+ gr.Slider.update(visible=False),
266
+ gr.Audio.update(visible=False),
267
+ gr.Button.update(visible=False),
268
+ # TTS
269
+ gr.Textbox.update(visible=False),
270
+ gr.Dropdown.update(visible=False)
271
+ )
272
+ elif vc_audio_mode == "Youtube":
273
+ return (
274
+ # Input & Upload
275
+ gr.Textbox.update(visible=False),
276
+ gr.Checkbox.update(visible=False),
277
+ gr.Audio.update(visible=False),
278
+ # Youtube
279
+ gr.Dropdown.update(visible=True),
280
+ gr.Textbox.update(visible=True),
281
+ gr.Dropdown.update(visible=True),
282
+ gr.Button.update(visible=True),
283
+ gr.Audio.update(visible=True),
284
+ gr.Audio.update(visible=True),
285
+ gr.Audio.update(visible=True),
286
+ gr.Slider.update(visible=True),
287
+ gr.Audio.update(visible=True),
288
+ gr.Button.update(visible=True),
289
+ # TTS
290
+ gr.Textbox.update(visible=False),
291
+ gr.Dropdown.update(visible=False)
292
+ )
293
+ elif vc_audio_mode == "TTS Audio":
294
+ return (
295
+ # Input & Upload
296
+ gr.Textbox.update(visible=False),
297
+ gr.Checkbox.update(visible=False),
298
+ gr.Audio.update(visible=False),
299
+ # Youtube
300
+ gr.Dropdown.update(visible=False),
301
+ gr.Textbox.update(visible=False),
302
+ gr.Dropdown.update(visible=False),
303
+ gr.Button.update(visible=False),
304
+ gr.Audio.update(visible=False),
305
+ gr.Audio.update(visible=False),
306
+ gr.Audio.update(visible=False),
307
+ gr.Slider.update(visible=False),
308
+ gr.Audio.update(visible=False),
309
+ gr.Button.update(visible=False),
310
+ # TTS
311
+ gr.Textbox.update(visible=True),
312
+ gr.Dropdown.update(visible=True)
313
+ )
314
+ else:
315
+ return (
316
+ # Input & Upload
317
+ gr.Textbox.update(visible=False),
318
+ gr.Checkbox.update(visible=True),
319
+ gr.Audio.update(visible=True),
320
+ # Youtube
321
+ gr.Dropdown.update(visible=False),
322
+ gr.Textbox.update(visible=False),
323
+ gr.Dropdown.update(visible=False),
324
+ gr.Button.update(visible=False),
325
+ gr.Audio.update(visible=False),
326
+ gr.Audio.update(visible=False),
327
+ gr.Audio.update(visible=False),
328
+ gr.Slider.update(visible=False),
329
+ gr.Audio.update(visible=False),
330
+ gr.Button.update(visible=False),
331
+ # TTS
332
+ gr.Textbox.update(visible=False),
333
+ gr.Dropdown.update(visible=False)
334
+ )
335
+
336
+ def use_microphone(microphone):
337
+ if microphone == True:
338
+ return gr.Audio.update(source="microphone")
339
+ else:
340
+ return gr.Audio.update(source="upload")
341
+
342
+ if __name__ == '__main__':
343
+ load_hubert()
344
+ categories = load_model()
345
+ tts_voice_list = asyncio.get_event_loop().run_until_complete(edge_tts.list_voices())
346
+ voices = [f"{v['ShortName']}-{v['Gender']}" for v in tts_voice_list]
347
+ with gr.Blocks() as app:
348
+ gr.Markdown(
349
+ "<div align='center'>\n\n"+
350
+ "# RVC V2 MODELS GENSHIN IMPACT\n\n"+
351
+ "### Recommended to use Google Colab to use other character and feature.\n\n"+
352
+ "#### All of this voice samples are taken from the game Genshin Impact, and all voice credits belong to hoyoverse.\n\n"+
353
+ "[![Colab](https://img.shields.io/badge/Colab-RVC%20Genshin%20Impact-blue?style=for-the-badge&logo=googlecolab)](https://colab.research.google.com/drive/1EGHCk7wluqMX2krZhPI13Vhs21e07kOv)\n\n"+
354
+ "</div>\n\n"+
355
+ "[![Repository](https://img.shields.io/badge/Github-Multi%20Model%20RVC%20Inference-blue?style=for-the-badge&logo=github)](https://github.com/ArkanDash/Multi-Model-RVC-Inference)"
356
+ )
357
+ for (folder_title, folder, description, models) in categories:
358
+ with gr.TabItem(folder_title):
359
+ if description:
360
+ gr.Markdown(f"### <center> {description}")
361
+ with gr.Tabs():
362
+ if not models:
363
+ gr.Markdown("# <center> No Model Loaded.")
364
+ gr.Markdown("## <center> Please add model or fix your model path.")
365
+ continue
366
+ for (name, title, author, cover, model_version, vc_fn) in models:
367
+ with gr.TabItem(name):
368
+ with gr.Row():
369
+ gr.Markdown(
370
+ '<div align="center">'
371
+ f'<div>{title}</div>\n'+
372
+ f'<div>RVC {model_version} Model</div>\n'+
373
+ (f'<div>Model author: {author}</div>' if author else "")+
374
+ (f'<img style="width:auto;height:300px;" src="file/{cover}">' if cover else "")+
375
+ '</div>'
376
+ )
377
+ with gr.Row():
378
+ with gr.Column():
379
+ vc_audio_mode = gr.Dropdown(label="Input voice", choices=audio_mode, allow_custom_value=False, value="Upload audio")
380
+ # Input
381
+ vc_input = gr.Textbox(label="Input audio path", visible=False)
382
+ # Upload
383
+ vc_microphone_mode = gr.Checkbox(label="Use Microphone", value=False, visible=True, interactive=True)
384
+ vc_upload = gr.Audio(label="Upload audio file", source="upload", visible=True, interactive=True)
385
+ # Youtube
386
+ vc_download_audio = gr.Dropdown(label="Provider", choices=["Youtube"], allow_custom_value=False, visible=False, value="Youtube", info="Select provider (Default: Youtube)")
387
+ vc_link = gr.Textbox(label="Youtube URL", visible=False, info="Example: https://www.youtube.com/watch?v=Nc0sB1Bmf-A", placeholder="https://www.youtube.com/watch?v=...")
388
+ vc_split_model = gr.Dropdown(label="Splitter Model", choices=["htdemucs", "mdx_extra_q"], allow_custom_value=False, visible=False, value="htdemucs", info="Select the splitter model (Default: htdemucs)")
389
+ vc_split = gr.Button("Split Audio", variant="primary", visible=False)
390
+ vc_vocal_preview = gr.Audio(label="Vocal Preview", visible=False)
391
+ vc_inst_preview = gr.Audio(label="Instrumental Preview", visible=False)
392
+ vc_audio_preview = gr.Audio(label="Audio Preview", visible=False)
393
+ # TTS
394
+ tts_text = gr.Textbox(visible=False, label="TTS text", info="Text to speech input")
395
+ tts_voice = gr.Dropdown(label="Edge-tts speaker", choices=voices, visible=False, allow_custom_value=False, value="en-US-AnaNeural-Female")
396
+ with gr.Column():
397
+ vc_transform0 = gr.Number(label="Transpose", value=0, info='Type "12" to change from male to female voice. Type "-12" to change female to male voice')
398
+ f0method0 = gr.Radio(
399
+ label="Pitch extraction algorithm",
400
+ info=f0method_info,
401
+ choices=f0method_mode,
402
+ value="pm",
403
+ interactive=True
404
+ )
405
+ index_rate1 = gr.Slider(
406
+ minimum=0,
407
+ maximum=1,
408
+ label="Retrieval feature ratio",
409
+ info="(Default: 0.7)",
410
+ value=0.7,
411
+ interactive=True,
412
+ )
413
+ filter_radius0 = gr.Slider(
414
+ minimum=0,
415
+ maximum=7,
416
+ label="Apply Median Filtering",
417
+ info="The value represents the filter radius and can reduce breathiness.",
418
+ value=3,
419
+ step=1,
420
+ interactive=True,
421
+ )
422
+ resample_sr0 = gr.Slider(
423
+ minimum=0,
424
+ maximum=48000,
425
+ label="Resample the output audio",
426
+ info="Resample the output audio in post-processing to the final sample rate. Set to 0 for no resampling",
427
+ value=0,
428
+ step=1,
429
+ interactive=True,
430
+ )
431
+ rms_mix_rate0 = gr.Slider(
432
+ minimum=0,
433
+ maximum=1,
434
+ label="Volume Envelope",
435
+ info="Use the volume envelope of the input to replace or mix with the volume envelope of the output. The closer the ratio is to 1, the more the output envelope is used",
436
+ value=1,
437
+ interactive=True,
438
+ )
439
+ protect0 = gr.Slider(
440
+ minimum=0,
441
+ maximum=0.5,
442
+ label="Voice Protection",
443
+ info="Protect voiceless consonants and breath sounds to prevent artifacts such as tearing in electronic music. Set to 0.5 to disable. Decrease the value to increase protection, but it may reduce indexing accuracy",
444
+ value=0.5,
445
+ step=0.01,
446
+ interactive=True,
447
+ )
448
+ with gr.Column():
449
+ vc_log = gr.Textbox(label="Output Information", interactive=False)
450
+ vc_output = gr.Audio(label="Output Audio", interactive=False)
451
+ vc_convert = gr.Button("Convert", variant="primary")
452
+ vc_volume = gr.Slider(
453
+ minimum=0,
454
+ maximum=10,
455
+ label="Vocal volume",
456
+ value=4,
457
+ interactive=True,
458
+ step=1,
459
+ info="Adjust vocal volume (Default: 4}",
460
+ visible=False
461
+ )
462
+ vc_combined_output = gr.Audio(label="Output Combined Audio", visible=False)
463
+ vc_combine = gr.Button("Combine",variant="primary", visible=False)
464
+ vc_convert.click(
465
+ fn=vc_fn,
466
+ inputs=[
467
+ vc_audio_mode,
468
+ vc_input,
469
+ vc_upload,
470
+ tts_text,
471
+ tts_voice,
472
+ vc_transform0,
473
+ f0method0,
474
+ index_rate1,
475
+ filter_radius0,
476
+ resample_sr0,
477
+ rms_mix_rate0,
478
+ protect0,
479
+ ],
480
+ outputs=[vc_log ,vc_output]
481
+ )
482
+ vc_split.click(
483
+ fn=cut_vocal_and_inst,
484
+ inputs=[vc_link, vc_download_audio, vc_split_model],
485
+ outputs=[vc_vocal_preview, vc_inst_preview, vc_audio_preview, vc_input]
486
+ )
487
+ vc_combine.click(
488
+ fn=combine_vocal_and_inst,
489
+ inputs=[vc_output, vc_volume, vc_split_model],
490
+ outputs=[vc_combined_output]
491
+ )
492
+ vc_microphone_mode.change(
493
+ fn=use_microphone,
494
+ inputs=vc_microphone_mode,
495
+ outputs=vc_upload
496
+ )
497
+ vc_audio_mode.change(
498
+ fn=change_audio_mode,
499
+ inputs=[vc_audio_mode],
500
+ outputs=[
501
+ vc_input,
502
+ vc_microphone_mode,
503
+ vc_upload,
504
+ vc_download_audio,
505
+ vc_link,
506
+ vc_split_model,
507
+ vc_split,
508
+ vc_vocal_preview,
509
+ vc_inst_preview,
510
+ vc_audio_preview,
511
+ vc_volume,
512
+ vc_combined_output,
513
+ vc_combine,
514
+ tts_text,
515
+ tts_voice
516
+ ]
517
+ )
518
+ if limitation is True:
519
+ app.queue(concurrency_count=1, max_size=20, api_open=config.api).launch(share=config.colab)
520
+ else:
521
+ app.queue(concurrency_count=1, max_size=20, api_open=config.api).launch(share=True)