andhikagg commited on
Commit
6fa9c53
·
verified ·
1 Parent(s): 9c69cba

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +441 -683
app.py CHANGED
@@ -1,683 +1,441 @@
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 fairseq.data.dictionary import Dictionary # Import the Dictionary class
21
-
22
- from lib.infer_pack.models import (
23
- SynthesizerTrnMs256NSFsid,
24
- SynthesizerTrnMs256NSFsid_nono,
25
- SynthesizerTrnMs768NSFsid,
26
- SynthesizerTrnMs768NSFsid_nono,
27
- )
28
- from vc_infer_pipeline import VC
29
- from config import Config
30
- config = Config()
31
- logging.getLogger("numba").setLevel(logging.WARNING)
32
- spaces = os.getenv("SYSTEM") == "spaces"
33
- force_support = None
34
- if config.unsupported is False:
35
- if config.device == "mps" or config.device == "cpu":
36
- force_support = False
37
- else:
38
- force_support = True
39
-
40
- audio_mode = []
41
- f0method_mode = []
42
- f0method_info = ""
43
-
44
- if force_support is False or spaces is True:
45
- if spaces is True:
46
- audio_mode = ["Upload audio", "TTS Audio"]
47
- else:
48
- audio_mode = ["Input path", "Upload audio", "TTS Audio"]
49
- f0method_mode = ["pm", "harvest"]
50
- f0method_info = "PM is fast, Harvest is good but extremely slow, Rvmpe is alternative to harvest (might be better). (Default: PM)"
51
- else:
52
- audio_mode = ["Input path", "Upload audio", "Youtube", "TTS Audio"]
53
- f0method_mode = ["pm", "harvest", "crepe"]
54
- f0method_info = "PM is fast, Harvest is good but extremely slow, Rvmpe is alternative to harvest (might be better), and Crepe effect is good but requires GPU (Default: PM)"
55
-
56
- if os.path.isfile("rmvpe.pt"):
57
- f0method_mode.insert(2, "rmvpe")
58
-
59
- def create_vc_fn(model_name, tgt_sr, net_g, vc, if_f0, version, file_index):
60
- def vc_fn(
61
- vc_audio_mode,
62
- vc_input,
63
- vc_upload,
64
- tts_text,
65
- tts_voice,
66
- f0_up_key,
67
- f0_method,
68
- index_rate,
69
- filter_radius,
70
- resample_sr,
71
- rms_mix_rate,
72
- protect,
73
- ):
74
- try:
75
- logs = []
76
- print(f"Converting using {model_name}...")
77
- logs.append(f"Converting using {model_name}...")
78
- yield "\n".join(logs), None
79
- if vc_audio_mode == "Input path" or "Youtube" and vc_input != "":
80
- audio, sr = librosa.load(vc_input, sr=16000, mono=True)
81
- elif vc_audio_mode == "Upload audio":
82
- if vc_upload is None:
83
- return "You need to upload an audio", None
84
- sampling_rate, audio = vc_upload
85
- duration = audio.shape[0] / sampling_rate
86
- if duration > 20 and spaces:
87
- 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
88
- audio = (audio / np.iinfo(audio.dtype).max).astype(np.float32)
89
- if len(audio.shape) > 1:
90
- audio = librosa.to_mono(audio.transpose(1, 0))
91
- if sampling_rate != 16000:
92
- audio = librosa.resample(audio, orig_sr=sampling_rate, target_sr=16000)
93
- elif vc_audio_mode == "TTS Audio":
94
- if len(tts_text) > 100 and spaces:
95
- return "Text is too long", None
96
- if tts_text is None or tts_voice is None:
97
- return "You need to enter text and select a voice", None
98
- asyncio.run(edge_tts.Communicate(tts_text, "-".join(tts_voice.split('-')[:-1])).save("tts.mp3"))
99
- audio, sr = librosa.load("tts.mp3", sr=16000, mono=True)
100
- vc_input = "tts.mp3"
101
- times = [0, 0, 0]
102
- f0_up_key = int(f0_up_key)
103
- audio_opt = vc.pipeline(
104
- hubert_model,
105
- net_g,
106
- 0,
107
- audio,
108
- vc_input,
109
- times,
110
- f0_up_key,
111
- f0_method,
112
- file_index,
113
- # file_big_npy,
114
- index_rate,
115
- if_f0,
116
- filter_radius,
117
- tgt_sr,
118
- resample_sr,
119
- rms_mix_rate,
120
- version,
121
- protect,
122
- f0_file=None,
123
- )
124
- info = f"[{datetime.now().strftime('%Y-%m-%d %H:%M')}]: npy: {times[0]}, f0: {times[1]}s, infer: {times[2]}s"
125
- print(f"{model_name} | {info}")
126
- logs.append(f"Successfully Convert {model_name}\n{info}")
127
- yield "\n".join(logs), (tgt_sr, audio_opt)
128
- except:
129
- info = traceback.format_exc()
130
- print(info)
131
- yield info, None
132
- return vc_fn
133
-
134
- def load_model():
135
- categories = []
136
- if os.path.isfile("weights/folder_info.json"):
137
- with open("weights/folder_info.json", "r", encoding="utf-8") as f:
138
- folder_info = json.load(f)
139
- for category_name, category_info in folder_info.items():
140
- if not category_info['enable']:
141
- continue
142
- category_title = category_info['title']
143
- category_folder = category_info['folder_path']
144
- description = category_info['description']
145
- models = []
146
- with open(f"weights/{category_folder}/model_info.json", "r", encoding="utf-8") as f:
147
- models_info = json.load(f)
148
- for character_name, info in models_info.items():
149
- if not info['enable']:
150
- continue
151
- model_title = info['title']
152
- model_name = info['model_path']
153
- model_author = info.get("author", None)
154
- model_cover = f"weights/{category_folder}/{character_name}/{info['cover']}"
155
- model_index = f"weights/{category_folder}/{character_name}/{info['feature_retrieval_library']}"
156
- cpt = torch.load(f"weights/{category_folder}/{character_name}/{model_name}", map_location="cpu")
157
- tgt_sr = cpt["config"][-1]
158
- cpt["config"][-3] = cpt["weight"]["emb_g.weight"].shape[0] # n_spk
159
- if_f0 = cpt.get("f0", 1)
160
- version = cpt.get("version", "v1")
161
- if version == "v1":
162
- if if_f0 == 1:
163
- net_g = SynthesizerTrnMs256NSFsid(*cpt["config"], is_half=config.is_half)
164
- else:
165
- net_g = SynthesizerTrnMs256NSFsid_nono(*cpt["config"])
166
- model_version = "V1"
167
- elif version == "v2":
168
- if if_f0 == 1:
169
- net_g = SynthesizerTrnMs768NSFsid(*cpt["config"], is_half=config.is_half)
170
- else:
171
- net_g = SynthesizerTrnMs768NSFsid_nono(*cpt["config"])
172
- model_version = "V2"
173
- del net_g.enc_q
174
- print(net_g.load_state_dict(cpt["weight"], strict=False))
175
- net_g.eval().to(config.device)
176
- if config.is_half:
177
- net_g = net_g.half()
178
- else:
179
- net_g = net_g.float()
180
- vc = VC(tgt_sr, config)
181
- print(f"Model loaded: {character_name} / {info['feature_retrieval_library']} | ({model_version})")
182
- models.append((character_name, model_title, model_author, model_cover, model_version, create_vc_fn(model_name, tgt_sr, net_g, vc, if_f0, version, model_index)))
183
- categories.append([category_title, category_folder, description, models])
184
- else:
185
- categories = []
186
- return categories
187
-
188
- def download_audio(url, audio_provider):
189
- logs = []
190
- if url == "":
191
- raise gr.Error("URL Required!")
192
- return "URL Required"
193
- if not os.path.exists("dl_audio"):
194
- os.mkdir("dl_audio")
195
- if audio_provider == "Youtube":
196
- logs.append("Downloading the audio...")
197
- yield None, "\n".join(logs)
198
- ydl_opts = {
199
- 'noplaylist': True,
200
- 'format': 'bestaudio/best',
201
- 'postprocessors': [{
202
- 'key': 'FFmpegExtractAudio',
203
- 'preferredcodec': 'wav',
204
- }],
205
- "outtmpl": 'dl_audio/audio',
206
- }
207
- audio_path = "dl_audio/audio.wav"
208
- with yt_dlp.YoutubeDL(ydl_opts) as ydl:
209
- ydl.download([url])
210
- logs.append("Download Complete.")
211
- yield audio_path, "\n".join(logs)
212
-
213
- def cut_vocal_and_inst(split_model):
214
- logs = []
215
- logs.append("Starting the audio splitting process...")
216
- yield "\n".join(logs), None, None, None, None
217
- command = f"demucs --two-stems=vocals -n {split_model} dl_audio/audio.wav -o output"
218
- result = subprocess.Popen(command.split(), stdout=subprocess.PIPE, text=True)
219
- for line in result.stdout:
220
- logs.append(line)
221
- yield "\n".join(logs), None, None, None, None
222
- print(result.stdout)
223
- vocal = f"output/{split_model}/audio/vocals.wav"
224
- inst = f"output/{split_model}/audio/no_vocals.wav"
225
- logs.append("Audio splitting complete.")
226
- yield "\n".join(logs), vocal, inst, vocal
227
-
228
- def combine_vocal_and_inst(audio_data, vocal_volume, inst_volume, split_model):
229
- if not os.path.exists("output/result"):
230
- os.mkdir("output/result")
231
- vocal_path = "output/result/output.wav"
232
- output_path = "output/result/combine.mp3"
233
- inst_path = f"output/{split_model}/audio/no_vocals.wav"
234
- with wave.open(vocal_path, "w") as wave_file:
235
- wave_file.setnchannels(1)
236
- wave_file.setsampwidth(2)
237
- wave_file.setframerate(audio_data[0])
238
- wave_file.writeframes(audio_data[1].tobytes())
239
- command = f'ffmpeg -y -i {inst_path} -i {vocal_path} -filter_complex [0:a]volume={inst_volume}[i];[1:a]volume={vocal_volume}[v];[i][v]amix=inputs=2:duration=longest[a] -map [a] -b:a 320k -c:a libmp3lame {output_path}'
240
- result = subprocess.run(command.split(), stdout=subprocess.PIPE)
241
- print(result.stdout.decode())
242
- return output_path
243
-
244
- def load_hubert():
245
- global hubert_model
246
- torch.serialization.add_safe_globals([Dictionary])
247
- models, _, _ = checkpoint_utils.load_model_ensemble_and_task(
248
- ["hubert_base.pt"],
249
- suffix="",
250
- )
251
- hubert_model = models[0]
252
- hubert_model = hubert_model.to(config.device)
253
- if config.is_half:
254
- hubert_model = hubert_model.half()
255
- else:
256
- hubert_model = hubert_model.float()
257
- hubert_model.eval()
258
-
259
- def change_audio_mode(vc_audio_mode):
260
- if vc_audio_mode == "Input path":
261
- return (
262
- # Input & Upload
263
- gr.Textbox.update(visible=True),
264
- gr.Checkbox.update(visible=False),
265
- gr.Audio.update(visible=False),
266
- # Youtube
267
- gr.Dropdown.update(visible=False),
268
- gr.Textbox.update(visible=False),
269
- gr.Textbox.update(visible=False),
270
- gr.Button.update(visible=False),
271
- # Splitter
272
- gr.Dropdown.update(visible=False),
273
- gr.Textbox.update(visible=False),
274
- gr.Button.update(visible=False),
275
- gr.Audio.update(visible=False),
276
- gr.Audio.update(visible=False),
277
- gr.Audio.update(visible=False),
278
- gr.Slider.update(visible=False),
279
- gr.Slider.update(visible=False),
280
- gr.Audio.update(visible=False),
281
- gr.Button.update(visible=False),
282
- # TTS
283
- gr.Textbox.update(visible=False),
284
- gr.Dropdown.update(visible=False)
285
- )
286
- elif vc_audio_mode == "Upload audio":
287
- return (
288
- # Input & Upload
289
- gr.Textbox.update(visible=False),
290
- gr.Checkbox.update(visible=True),
291
- gr.Audio.update(visible=True),
292
- # Youtube
293
- gr.Dropdown.update(visible=False),
294
- gr.Textbox.update(visible=False),
295
- gr.Textbox.update(visible=False),
296
- gr.Button.update(visible=False),
297
- # Splitter
298
- gr.Dropdown.update(visible=False),
299
- gr.Textbox.update(visible=False),
300
- gr.Button.update(visible=False),
301
- gr.Audio.update(visible=False),
302
- gr.Audio.update(visible=False),
303
- gr.Audio.update(visible=False),
304
- gr.Slider.update(visible=False),
305
- gr.Slider.update(visible=False),
306
- gr.Audio.update(visible=False),
307
- gr.Button.update(visible=False),
308
- # TTS
309
- gr.Textbox.update(visible=False),
310
- gr.Dropdown.update(visible=False)
311
- )
312
- elif vc_audio_mode == "Youtube":
313
- return (
314
- # Input & Upload
315
- gr.Textbox.update(visible=False),
316
- gr.Checkbox.update(visible=False),
317
- gr.Audio.update(visible=False),
318
- # Youtube
319
- gr.Dropdown.update(visible=True),
320
- gr.Textbox.update(visible=True),
321
- gr.Textbox.update(visible=True),
322
- gr.Button.update(visible=True),
323
- # Splitter
324
- gr.Dropdown.update(visible=True),
325
- gr.Textbox.update(visible=True),
326
- gr.Button.update(visible=True),
327
- gr.Audio.update(visible=True),
328
- gr.Audio.update(visible=True),
329
- gr.Audio.update(visible=True),
330
- gr.Slider.update(visible=True),
331
- gr.Slider.update(visible=True),
332
- gr.Audio.update(visible=True),
333
- gr.Button.update(visible=True),
334
- # TTS
335
- gr.Textbox.update(visible=False),
336
- gr.Dropdown.update(visible=False)
337
- )
338
- elif vc_audio_mode == "TTS Audio":
339
- return (
340
- # Input & Upload
341
- gr.Textbox.update(visible=False),
342
- gr.Checkbox.update(visible=False),
343
- gr.Audio.update(visible=False),
344
- # Youtube
345
- gr.Dropdown.update(visible=False),
346
- gr.Textbox.update(visible=False),
347
- gr.Textbox.update(visible=False),
348
- gr.Button.update(visible=False),
349
- # Splitter
350
- gr.Dropdown.update(visible=False),
351
- gr.Textbox.update(visible=False),
352
- gr.Button.update(visible=False),
353
- gr.Audio.update(visible=False),
354
- gr.Audio.update(visible=False),
355
- gr.Audio.update(visible=False),
356
- gr.Slider.update(visible=False),
357
- gr.Slider.update(visible=False),
358
- gr.Audio.update(visible=False),
359
- gr.Button.update(visible=False),
360
- # TTS
361
- gr.Textbox.update(visible=True),
362
- gr.Dropdown.update(visible=True)
363
- )
364
-
365
- def use_microphone(microphone):
366
- if microphone == True:
367
- return gr.Audio.update(source="microphone")
368
- else:
369
- return gr.Audio.update(source="upload")
370
-
371
- if __name__ == '__main__':
372
- load_hubert()
373
- categories = load_model()
374
- tts_voice_list = asyncio.new_event_loop().run_until_complete(edge_tts.list_voices())
375
- voices = [f"{v['ShortName']}-{v['Gender']}" for v in tts_voice_list]
376
- with gr.Blocks() as app:
377
- gr.Markdown(
378
- "<div align='center'>\n\n"+
379
- "# RVC Models\n\n"+
380
- "### Recommended to use Google Colab to use other character and feature.\n\n"+
381
- "[![Colab](https://img.shields.io/badge/Colab-RVC%20Blue%20Archives-blue?style=for-the-badge&logo=googlecolab)](https://colab.research.google.com/drive/19Eo2xO7EKcMqvJDc_yXrWmixuNA4NtEU)\n\n"+
382
- "</div>\n\n"+
383
- "[![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)\n\n"+
384
- "</div>"
385
- )
386
- if categories == []:
387
- gr.Markdown(
388
- "<div align='center'>\n\n"+
389
- "## No model found, please add the model into weights folder\n\n"+
390
- "</div>"
391
- )
392
- for (folder_title, folder, description, models) in categories:
393
- with gr.TabItem(folder_title):
394
- if description:
395
- gr.Markdown(f"### <center> {description}")
396
- with gr.Tabs():
397
- if not models:
398
- gr.Markdown("# <center> No Model Loaded.")
399
- gr.Markdown("## <center> Please add the model or fix your model path.")
400
- continue
401
- for (name, title, author, cover, model_version, vc_fn) in models:
402
- with gr.TabItem(name):
403
- with gr.Row():
404
- gr.Markdown(
405
- '<div align="center">'
406
- f'<div>{title}</div>\n'+
407
- f'<div>RVC {model_version} Model</div>\n'+
408
- (f'<div>Model author: {author}</div>' if author else "")+
409
- (f'<img style="width:auto;height:300px;" src="file/{cover}">' if cover else "")+
410
- '</div>'
411
- )
412
- with gr.Row():
413
- if spaces is False:
414
- with gr.TabItem("Input"):
415
- with gr.Row():
416
- with gr.Column():
417
- vc_audio_mode = gr.Dropdown(label="Input voice", choices=audio_mode, allow_custom_value=False, value="Upload audio")
418
- # Input
419
- vc_input = gr.Textbox(label="Input audio path", visible=False)
420
- # Upload
421
- vc_microphone_mode = gr.Checkbox(label="Use Microphone", value=False, visible=True, interactive=True)
422
- vc_upload = gr.Audio(label="Upload audio file", visible=True, interactive=True)
423
- # Youtube
424
- vc_download_audio = gr.Dropdown(label="Provider", choices=["Youtube"], allow_custom_value=False, visible=False, value="Youtube", info="Select provider (Default: Youtube)")
425
- 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=...")
426
- vc_log_yt = gr.Textbox(label="Output Information", visible=False, interactive=False)
427
- vc_download_button = gr.Button("Download Audio", variant="primary", visible=False)
428
- vc_audio_preview = gr.Audio(label="Audio Preview", visible=False)
429
- # TTS
430
- tts_text = gr.Textbox(label="TTS text", info="Text to speech input", visible=False)
431
- tts_voice = gr.Dropdown(label="Edge-tts speaker", choices=voices, visible=False, allow_custom_value=False, value="en-US-AnaNeural-Female")
432
- with gr.Column():
433
- vc_split_model = gr.Dropdown(label="Splitter Model", choices=["hdemucs_mmi", "htdemucs", "htdemucs_ft", "mdx", "mdx_q", "mdx_extra_q"], allow_custom_value=False, visible=False, value="htdemucs", info="Select the splitter model (Default: htdemucs)")
434
- vc_split_log = gr.Textbox(label="Output Information", visible=False, interactive=False)
435
- vc_split = gr.Button("Split Audio", variant="primary", visible=False)
436
- vc_vocal_preview = gr.Audio(label="Vocal Preview", visible=False)
437
- vc_inst_preview = gr.Audio(label="Instrumental Preview", visible=False)
438
- with gr.TabItem("Convert"):
439
- with gr.Row():
440
- with gr.Column():
441
- 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')
442
- f0method0 = gr.Radio(
443
- label="Pitch extraction algorithm",
444
- info=f0method_info,
445
- choices=f0method_mode,
446
- value="pm",
447
- interactive=True
448
- )
449
- index_rate1 = gr.Slider(
450
- minimum=0,
451
- maximum=1,
452
- label="Retrieval feature ratio",
453
- info="(Default: 0.7)",
454
- value=0.7,
455
- interactive=True,
456
- )
457
- filter_radius0 = gr.Slider(
458
- minimum=0,
459
- maximum=7,
460
- label="Apply Median Filtering",
461
- info="The value represents the filter radius and can reduce breathiness.",
462
- value=3,
463
- step=1,
464
- interactive=True,
465
- )
466
- resample_sr0 = gr.Slider(
467
- minimum=0,
468
- maximum=48000,
469
- label="Resample the output audio",
470
- info="Resample the output audio in post-processing to the final sample rate. Set to 0 for no resampling",
471
- value=0,
472
- step=1,
473
- interactive=True,
474
- )
475
- rms_mix_rate0 = gr.Slider(
476
- minimum=0,
477
- maximum=1,
478
- label="Volume Envelope",
479
- 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",
480
- value=1,
481
- interactive=True,
482
- )
483
- protect0 = gr.Slider(
484
- minimum=0,
485
- maximum=0.5,
486
- label="Voice Protection",
487
- 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",
488
- value=0.5,
489
- step=0.01,
490
- interactive=True,
491
- )
492
- with gr.Column():
493
- vc_log = gr.Textbox(label="Output Information", interactive=False)
494
- vc_output = gr.Audio(label="Output Audio", interactive=False)
495
- vc_convert = gr.Button("Convert", variant="primary")
496
- vc_vocal_volume = gr.Slider(
497
- minimum=0,
498
- maximum=10,
499
- label="Vocal volume",
500
- value=1,
501
- interactive=True,
502
- step=1,
503
- info="Adjust vocal volume (Default: 1}",
504
- visible=False
505
- )
506
- vc_inst_volume = gr.Slider(
507
- minimum=0,
508
- maximum=10,
509
- label="Instrument volume",
510
- value=1,
511
- interactive=True,
512
- step=1,
513
- info="Adjust instrument volume (Default: 1}",
514
- visible=False
515
- )
516
- vc_combined_output = gr.Audio(label="Output Combined Audio", visible=False)
517
- vc_combine = gr.Button("Combine",variant="primary", visible=False)
518
- else:
519
- with gr.Column():
520
- vc_audio_mode = gr.Dropdown(label="Input voice", choices=audio_mode, allow_custom_value=False, value="Upload audio")
521
- # Input
522
- vc_input = gr.Textbox(label="Input audio path", visible=False)
523
- # Upload
524
- vc_microphone_mode = gr.Checkbox(label="Use Microphone", value=False, visible=True, interactive=True)
525
- vc_upload = gr.Audio(label="Upload audio file", visible=True, interactive=True)
526
- # Youtube
527
- vc_download_audio = gr.Dropdown(label="Provider", choices=["Youtube"], allow_custom_value=False, visible=False, value="Youtube", info="Select provider (Default: Youtube)")
528
- 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=...")
529
- vc_log_yt = gr.Textbox(label="Output Information", visible=False, interactive=False)
530
- vc_download_button = gr.Button("Download Audio", variant="primary", visible=False)
531
- vc_audio_preview = gr.Audio(label="Audio Preview", visible=False)
532
- # Splitter
533
- vc_split_model = gr.Dropdown(label="Splitter Model", choices=["hdemucs_mmi", "htdemucs", "htdemucs_ft", "mdx", "mdx_q", "mdx_extra_q"], allow_custom_value=False, visible=False, value="htdemucs", info="Select the splitter model (Default: htdemucs)")
534
- vc_split_log = gr.Textbox(label="Output Information", visible=False, interactive=False)
535
- vc_split = gr.Button("Split Audio", variant="primary", visible=False)
536
- vc_vocal_preview = gr.Audio(label="Vocal Preview", visible=False)
537
- vc_inst_preview = gr.Audio(label="Instrumental Preview", visible=False)
538
- # TTS
539
- tts_text = gr.Textbox(label="TTS text", info="Text to speech input", visible=False)
540
- tts_voice = gr.Dropdown(label="Edge-tts speaker", choices=voices, visible=False, allow_custom_value=False, value="en-US-AnaNeural-Female")
541
- with gr.Column():
542
- 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')
543
- f0method0 = gr.Radio(
544
- label="Pitch extraction algorithm",
545
- info=f0method_info,
546
- choices=f0method_mode,
547
- value="pm",
548
- interactive=True
549
- )
550
- index_rate1 = gr.Slider(
551
- minimum=0,
552
- maximum=1,
553
- label="Retrieval feature ratio",
554
- info="(Default: 0.7)",
555
- value=0.7,
556
- interactive=True,
557
- )
558
- filter_radius0 = gr.Slider(
559
- minimum=0,
560
- maximum=7,
561
- label="Apply Median Filtering",
562
- info="The value represents the filter radius and can reduce breathiness.",
563
- value=3,
564
- step=1,
565
- interactive=True,
566
- )
567
- resample_sr0 = gr.Slider(
568
- minimum=0,
569
- maximum=48000,
570
- label="Resample the output audio",
571
- info="Resample the output audio in post-processing to the final sample rate. Set to 0 for no resampling",
572
- value=0,
573
- step=1,
574
- interactive=True,
575
- )
576
- rms_mix_rate0 = gr.Slider(
577
- minimum=0,
578
- maximum=1,
579
- label="Volume Envelope",
580
- 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",
581
- value=1,
582
- interactive=True,
583
- )
584
- protect0 = gr.Slider(
585
- minimum=0,
586
- maximum=0.5,
587
- label="Voice Protection",
588
- 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",
589
- value=0.5,
590
- step=0.01,
591
- interactive=True,
592
- )
593
- with gr.Column():
594
- vc_log = gr.Textbox(label="Output Information", interactive=False)
595
- vc_output = gr.Audio(label="Output Audio", interactive=False)
596
- vc_convert = gr.Button("Convert", variant="primary")
597
- vc_vocal_volume = gr.Slider(
598
- minimum=0,
599
- maximum=10,
600
- label="Vocal volume",
601
- value=1,
602
- interactive=True,
603
- step=1,
604
- info="Adjust vocal volume (Default: 1}",
605
- visible=False
606
- )
607
- vc_inst_volume = gr.Slider(
608
- minimum=0,
609
- maximum=10,
610
- label="Instrument volume",
611
- value=1,
612
- interactive=True,
613
- step=1,
614
- info="Adjust instrument volume (Default: 1}",
615
- visible=False
616
- )
617
- vc_combined_output = gr.Audio(label="Output Combined Audio", visible=False)
618
- vc_combine = gr.Button("Combine",variant="primary", visible=False)
619
- vc_convert.click(
620
- fn=vc_fn,
621
- inputs=[
622
- vc_audio_mode,
623
- vc_input,
624
- vc_upload,
625
- tts_text,
626
- tts_voice,
627
- vc_transform0,
628
- f0method0,
629
- index_rate1,
630
- filter_radius0,
631
- resample_sr0,
632
- rms_mix_rate0,
633
- protect0,
634
- ],
635
- outputs=[vc_log ,vc_output]
636
- )
637
- vc_download_button.click(
638
- fn=download_audio,
639
- inputs=[vc_link, vc_download_audio],
640
- outputs=[vc_audio_preview, vc_log_yt]
641
- )
642
- vc_split.click(
643
- fn=cut_vocal_and_inst,
644
- inputs=[vc_split_model],
645
- outputs=[vc_split_log, vc_vocal_preview, vc_inst_preview, vc_input]
646
- )
647
- vc_combine.click(
648
- fn=combine_vocal_and_inst,
649
- inputs=[vc_output, vc_vocal_volume, vc_inst_volume, vc_split_model],
650
- outputs=[vc_combined_output]
651
- )
652
- vc_microphone_mode.change(
653
- fn=use_microphone,
654
- inputs=vc_microphone_mode,
655
- outputs=vc_upload
656
- )
657
- vc_audio_mode.change(
658
- fn=change_audio_mode,
659
- inputs=[vc_audio_mode],
660
- outputs=[
661
- vc_input,
662
- vc_microphone_mode,
663
- vc_upload,
664
- vc_download_audio,
665
- vc_link,
666
- vc_log_yt,
667
- vc_download_button,
668
- vc_split_model,
669
- vc_split_log,
670
- vc_split,
671
- vc_audio_preview,
672
- vc_vocal_preview,
673
- vc_inst_preview,
674
- vc_vocal_volume,
675
- vc_inst_volume,
676
- vc_combined_output,
677
- vc_combine,
678
- tts_text,
679
- tts_voice
680
- ]
681
- )
682
-
683
- app.queue(max_size=20, api_open=config.api).launch(share=config.colab if spaces else True)
 
1
+ print("Starting up. Please be patient...")
2
+
3
+ import os
4
+ import glob
5
+ import json
6
+ import traceback
7
+ import logging
8
+ import gradio as gr
9
+ import numpy as np
10
+ import librosa
11
+ import torch
12
+ import asyncio
13
+ import edge_tts
14
+ import yt_dlp
15
+ import ffmpeg
16
+ import subprocess
17
+ import sys
18
+ import io
19
+ import wave
20
+ from datetime import datetime
21
+ from fairseq import checkpoint_utils
22
+ from lib.infer_pack.models import (
23
+ SynthesizerTrnMs256NSFsid,
24
+ SynthesizerTrnMs256NSFsid_nono,
25
+ SynthesizerTrnMs768NSFsid,
26
+ SynthesizerTrnMs768NSFsid_nono,
27
+ )
28
+ from vc_infer_pipeline import VC
29
+ from config import Config
30
+ from edgetts_db import tts_order_voice
31
+
32
+ #fuck intel
33
+ os.environ["KMP_DUPLICATE_LIB_OK"]="TRUE"
34
+
35
+ config = Config()
36
+ logging.getLogger("numba").setLevel(logging.WARNING)
37
+ limitation = os.getenv("SYSTEM") == "spaces"
38
+ #limitation=True
39
+ language_dict = tts_order_voice
40
+
41
+ authors = ["dacoolkid44", "Hijack", "Maki Ligon", "megaaziib", "Kit Lemonfoot", "yeey5", "Sui", "MahdeenSky"]
42
+
43
+ f0method_mode = []
44
+ if limitation is True:
45
+ f0method_info = "PM is better for testing, RMVPE is better for finalized generations. (Default: PM)"
46
+ f0method_mode = ["pm", "rmvpe"]
47
+ else:
48
+ f0method_info = "PM is fast but low quality, crepe and harvest are slow but good quality, RMVPE is the best of both worlds. (Default: PM)"
49
+ f0method_mode = ["pm", "crepe", "harvest", "rmvpe"]
50
+
51
+ #Eagerload VCs
52
+ print("Preloading VCs...")
53
+ vcArr=[]
54
+ vcArr.append(VC(32000, config))
55
+ vcArr.append(VC(40000, config))
56
+ vcArr.append(VC(48000, config))
57
+
58
+ def infer(name, path, index, vc_input, vc_upload, tts_text, tts_voice, f0_up_key, f0_method, index_rate, filter_radius, resample_sr, rms_mix_rate, protect):
59
+ try:
60
+ #Setup audio
61
+ audio=None
62
+ #Determine audio mode
63
+ #TTS takes priority over uploads.
64
+ #Uploads takes priority over paths.
65
+ vc_audio_mode = ""
66
+ #Edge-TTS
67
+ if(tts_text):
68
+ vc_audio_mode = "ETTS"
69
+ if len(tts_text) > 250 and limitation:
70
+ return "Text is too long.", None
71
+ if tts_text is None or tts_voice is None or tts_text=="":
72
+ return "You need to enter text and select a voice.", None
73
+ voice = language_dict[tts_voice]
74
+ try:
75
+ asyncio.run(edge_tts.Communicate(tts_text, voice).save("tts.mp3"))
76
+ except:
77
+ print("Failed to get E-TTS handle. A restart may be needed soon.")
78
+ return "ERROR: Failed to communicate with Edge-TTS. The Edge-TTS service may be down or cannot communicate. Please try another method or try again later.", None
79
+ try:
80
+ audio, sr = librosa.load("tts.mp3", sr=16000, mono=True)
81
+ except:
82
+ return "ERROR: Invalid characters for the chosen TTS speaker. (Change your TTS speaker to one that supports your language!)", None
83
+ duration = audio.shape[0] / sr
84
+ if duration > 30 and limitation:
85
+ return "Your text generated an audio that was too long.", None
86
+ vc_input = "tts.mp3"
87
+ #File upload
88
+ elif(vc_upload):
89
+ vc_audio_mode = "Upload"
90
+ sampling_rate, audio = vc_upload
91
+ duration = audio.shape[0] / sampling_rate
92
+ if duration > 60 and limitation:
93
+ return "Too long! Please upload an audio file that is less than 1 minute.", None
94
+ audio = (audio / np.iinfo(audio.dtype).max).astype(np.float32)
95
+ if len(audio.shape) > 1:
96
+ audio = librosa.to_mono(audio.transpose(1, 0))
97
+ if sampling_rate != 16000:
98
+ audio = librosa.resample(audio, orig_sr=sampling_rate, target_sr=16000)
99
+ tts_text = "Uploaded Audio"
100
+ #YouTube or path
101
+ elif(vc_input):
102
+ audio, sr = librosa.load(vc_input, sr=16000, mono=True)
103
+ vc_audio_mode = "YouTube"
104
+ tts_text = "YouTube Audio"
105
+ else:
106
+ return "Please upload or choose some type of audio.", None
107
+
108
+ if audio is None:
109
+ if vc_audio_mode == "ETTS":
110
+ print("Failed to get E-TTS handle. A restart may be needed soon.")
111
+ return "ERROR: Failed to obtain a correct response from Edge-TTS. The Edge-TTS service may be down or unable to communicate. Please try another method or try again later.", None
112
+ return "ERROR: Unknown audio error. Please try again.", None
113
+
114
+ times = [0, 0, 0]
115
+ f0_up_key = int(f0_up_key)
116
+
117
+ #Setup model
118
+ cpt = torch.load(f"{path}", map_location="cpu")
119
+ tgt_sr = cpt["config"][-1]
120
+ cpt["config"][-3] = cpt["weight"]["emb_g.weight"].shape[0] # n_spk
121
+ if_f0 = cpt.get("f0", 1)
122
+ version = cpt.get("version", "v1")
123
+ if version == "v1":
124
+ if if_f0 == 1:
125
+ net_g = SynthesizerTrnMs256NSFsid(*cpt["config"], is_half=config.is_half)
126
+ else:
127
+ net_g = SynthesizerTrnMs256NSFsid_nono(*cpt["config"])
128
+ model_version = "V1"
129
+ elif version == "v2":
130
+ if if_f0 == 1:
131
+ net_g = SynthesizerTrnMs768NSFsid(*cpt["config"], is_half=config.is_half)
132
+ else:
133
+ net_g = SynthesizerTrnMs768NSFsid_nono(*cpt["config"])
134
+ model_version = "V2"
135
+ del net_g.enc_q
136
+ print(net_g.load_state_dict(cpt["weight"], strict=False))
137
+ net_g.eval().to(config.device)
138
+ if config.is_half:
139
+ net_g = net_g.half()
140
+ else:
141
+ net_g = net_g.float()
142
+ vcIdx = int((tgt_sr/8000)-4)
143
+
144
+ #Gen audio
145
+ audio_opt = vcArr[vcIdx].pipeline(
146
+ hubert_model,
147
+ net_g,
148
+ 0,
149
+ audio,
150
+ vc_input,
151
+ times,
152
+ f0_up_key,
153
+ f0_method,
154
+ index,
155
+ # file_big_npy,
156
+ index_rate,
157
+ if_f0,
158
+ filter_radius,
159
+ tgt_sr,
160
+ resample_sr,
161
+ rms_mix_rate,
162
+ version,
163
+ protect,
164
+ f0_file=None,
165
+ )
166
+ info = f"[{datetime.now().strftime('%Y-%m-%d %H:%M')}]: npy: {times[0]}, f0: {times[1]}s, infer: {times[2]}s"
167
+ print(f"Successful inference with model {name} | {tts_text} | {info}")
168
+ del net_g, cpt
169
+ return info, (tgt_sr, audio_opt)
170
+ except:
171
+ info = traceback.format_exc()
172
+ print(info)
173
+ return info, (None, None)
174
+
175
+ def load_model():
176
+ categories = []
177
+ with open("weights/folder_info.json", "r", encoding="utf-8") as f:
178
+ folder_info = json.load(f)
179
+ for category_name, category_info in folder_info.items():
180
+ if not category_info['enable']:
181
+ continue
182
+ category_title = category_info['title']
183
+ category_folder = category_info['folder_path']
184
+ models = []
185
+ print(f"Creating category {category_title}...")
186
+ with open(f"weights/{category_folder}/model_info.json", "r", encoding="utf-8") as f:
187
+ models_info = json.load(f)
188
+ for character_name, info in models_info.items():
189
+ if not info['enable']:
190
+ continue
191
+ model_title = info['title']
192
+ model_name = info['model_path']
193
+ model_author = info.get("author", None)
194
+ model_cover = f"weights/{category_folder}/{character_name}/{info['cover']}"
195
+ model_index = f"weights/{category_folder}/{character_name}/{info['feature_retrieval_library']}"
196
+ if info['feature_retrieval_library'] == "None":
197
+ model_index = None
198
+ if model_index:
199
+ assert os.path.exists(model_index), f"Model {model_title} failed to load index."
200
+ if not (model_author in authors or "/" in model_author or "&" in model_author):
201
+ authors.append(model_author)
202
+ model_path = f"weights/{category_folder}/{character_name}/{model_name}"
203
+ cpt = torch.load(f"weights/{category_folder}/{character_name}/{model_name}", map_location="cpu")
204
+ model_version = cpt.get("version", "v1")
205
+ print(f"Indexed model {model_title} by {model_author} ({model_version})")
206
+ models.append((character_name, model_title, model_author, model_cover, model_version, model_path, model_index))
207
+ del cpt
208
+ categories.append([category_title, category_folder, models])
209
+ return categories
210
+
211
+ def cut_vocal_and_inst(url, audio_provider, split_model):
212
+ if url != "":
213
+ if not os.path.exists("dl_audio"):
214
+ os.mkdir("dl_audio")
215
+ if audio_provider == "Youtube":
216
+ ydl_opts = {
217
+ 'format': 'bestaudio/best',
218
+ 'postprocessors': [{
219
+ 'key': 'FFmpegExtractAudio',
220
+ 'preferredcodec': 'wav',
221
+ }],
222
+ "outtmpl": 'dl_audio/youtube_audio',
223
+ }
224
+ with yt_dlp.YoutubeDL(ydl_opts) as ydl:
225
+ ydl.download([url])
226
+ audio_path = "dl_audio/youtube_audio.wav"
227
+ else:
228
+ # Spotify doesnt work.
229
+ # Need to find other solution soon.
230
+ '''
231
+ command = f"spotdl download {url} --output dl_audio/.wav"
232
+ result = subprocess.run(command.split(), stdout=subprocess.PIPE)
233
+ print(result.stdout.decode())
234
+ audio_path = "dl_audio/spotify_audio.wav"
235
+ '''
236
+ if split_model == "htdemucs":
237
+ command = f"demucs --two-stems=vocals {audio_path} -o output"
238
+ result = subprocess.run(command.split(), stdout=subprocess.PIPE)
239
+ print(result.stdout.decode())
240
+ return "output/htdemucs/youtube_audio/vocals.wav", "output/htdemucs/youtube_audio/no_vocals.wav", audio_path, "output/htdemucs/youtube_audio/vocals.wav"
241
+ else:
242
+ command = f"demucs --two-stems=vocals -n mdx_extra_q {audio_path} -o output"
243
+ result = subprocess.run(command.split(), stdout=subprocess.PIPE)
244
+ print(result.stdout.decode())
245
+ 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"
246
+ else:
247
+ raise gr.Error("URL Required!")
248
+ return None, None, None, None
249
+
250
+ def load_hubert():
251
+ global hubert_model
252
+ models, _, _ = checkpoint_utils.load_model_ensemble_and_task(
253
+ ["hubert_base.pt"],
254
+ suffix="",
255
+ )
256
+ hubert_model = models[0]
257
+ hubert_model = hubert_model.to(config.device)
258
+ if config.is_half:
259
+ hubert_model = hubert_model.half()
260
+ else:
261
+ hubert_model = hubert_model.float()
262
+ hubert_model.eval()
263
+
264
+ if __name__ == '__main__':
265
+ load_hubert()
266
+ categories = load_model()
267
+ voices = list(language_dict.keys())
268
+
269
+ # Gradio preloading
270
+ # Input and Upload
271
+ vc_upload = gr.Audio(label="Upload or record an audio file", interactive=True)
272
+ # Youtube
273
+ vc_input = gr.Textbox(label="Input audio path", visible=False)
274
+ vc_download_audio = gr.Dropdown(label="Provider", choices=["Youtube"], allow_custom_value=False, value="Youtube", info="Select provider (Default: Youtube)")
275
+ vc_link = gr.Textbox(label="Youtube URL", info="Example: https://www.youtube.com/watch?v=Nc0sB1Bmf-A", placeholder="https://www.youtube.com/watch?v=...")
276
+ vc_split_model = gr.Dropdown(label="Splitter Model", choices=["htdemucs", "mdx_extra_q"], allow_custom_value=False, value="htdemucs", info="Select the splitter model (Default: htdemucs)")
277
+ vc_split = gr.Button("Split Audio", variant="primary")
278
+ vc_vocal_preview = gr.Audio(label="Vocal Preview")
279
+ vc_inst_preview = gr.Audio(label="Instrumental Preview")
280
+ vc_audio_preview = gr.Audio(label="Audio Preview")
281
+ # TTS
282
+ tts_text = gr.Textbox(label="TTS text", info="Text to speech input (There is a limit of 250 characters)", interactive=True)
283
+ tts_voice = gr.Dropdown(label="Edge-TTS speaker", choices=voices, allow_custom_value=False, value="English-Ana (Female)", interactive=True)
284
+ # Other settings
285
+ 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')
286
+ f0method0 = gr.Radio(
287
+ label="Pitch extraction algorithm",
288
+ info=f0method_info,
289
+ choices=f0method_mode,
290
+ value="pm",
291
+ interactive=True
292
+ )
293
+ index_rate1 = gr.Slider(
294
+ minimum=0,
295
+ maximum=1,
296
+ label="Retrieval feature ratio",
297
+ info="Accent control. Too high will usually sound too robotic. (Default: 0.4)",
298
+ value=0.4,
299
+ interactive=True,
300
+ )
301
+ filter_radius0 = gr.Slider(
302
+ minimum=0,
303
+ maximum=7,
304
+ label="Apply Median Filtering",
305
+ info="The value represents the filter radius and can reduce breathiness.",
306
+ value=1,
307
+ step=1,
308
+ interactive=True,
309
+ )
310
+ resample_sr0 = gr.Slider(
311
+ minimum=0,
312
+ maximum=48000,
313
+ label="Resample the output audio",
314
+ info="Resample the output audio in post-processing to the final sample rate. Set to 0 for no resampling.",
315
+ value=0,
316
+ step=1,
317
+ interactive=True,
318
+ )
319
+ rms_mix_rate0 = gr.Slider(
320
+ minimum=0,
321
+ maximum=1,
322
+ label="Volume Envelope",
323
+ 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",
324
+ value=1,
325
+ interactive=True,
326
+ )
327
+ protect0 = gr.Slider(
328
+ minimum=0,
329
+ maximum=0.5,
330
+ label="Voice Protection",
331
+ 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",
332
+ value=0.23,
333
+ step=0.01,
334
+ interactive=True,
335
+ )
336
+
337
+ with gr.Blocks(theme=gr.themes.Base()) as app:
338
+ gr.Markdown(
339
+ "# <center> VTuber RVC Models\n"
340
+ "### <center> Space by Kit Lemonfoot / Noel Shirogane's High Flying Birds"
341
+ "<center> Original space by megaaziib & zomehwh\n"
342
+ "### <center> Please credit the original model authors if you use this Space."
343
+ "<center>Do no evil.\n\n"
344
+ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1Til3SY7-X0x3Wss3YXlgfq8go39DzWHk)\n\n"
345
+ )
346
+ gr.Markdown("<center> Looking for more models? <a href=\"https://docs.google.com/spreadsheets/d/1tvZSggOsZGAPjbMrWOAAaoJJFpJuQlwUEQCf5x1ssO8\">Check out the VTuber AI Model Tracking spreadsheet!</a>")
347
+ for (folder_title, folder, models) in categories:
348
+ with gr.TabItem(folder_title):
349
+ with gr.Tabs():
350
+ if not models:
351
+ gr.Markdown("# <center> No Model Loaded.")
352
+ gr.Markdown("## <center> Please add model or fix your model path.")
353
+ continue
354
+ for (name, title, author, cover, model_version, model_path, model_index) in models:
355
+ with gr.TabItem(name):
356
+ with gr.Row():
357
+ with gr.Column():
358
+ gr.Markdown(
359
+ '<div align="center">'
360
+ f'<div>{title}</div>\n'+
361
+ f'<div>RVC {model_version} Model</div>\n'+
362
+ (f'<div>Model author: {author}</div>' if author else "")+
363
+ (f'<img style="width:auto;height:300px;" src="file/{cover}"></img>' if cover else "")+
364
+ '</div>'
365
+ )
366
+ with gr.Column():
367
+ vc_log = gr.Textbox(label="Output Information", interactive=False)
368
+ vc_output = gr.Audio(label="Output Audio", interactive=False)
369
+ #This is a fucking stupid solution but Gradio refuses to pass in values unless I do this.
370
+ vc_name = gr.Textbox(value=title, visible=False, interactive=False)
371
+ vc_mp = gr.Textbox(value=model_path, visible=False, interactive=False)
372
+ vc_mi = gr.Textbox(value=model_index, visible=False, interactive=False)
373
+ vc_convert = gr.Button("Convert", variant="primary")
374
+
375
+ vc_convert.click(
376
+ fn=infer,
377
+ inputs=[
378
+ vc_name,
379
+ vc_mp,
380
+ vc_mi,
381
+ vc_input,
382
+ vc_upload,
383
+ tts_text,
384
+ tts_voice,
385
+ vc_transform0,
386
+ f0method0,
387
+ index_rate1,
388
+ filter_radius0,
389
+ resample_sr0,
390
+ rms_mix_rate0,
391
+ protect0
392
+ ],
393
+ outputs=[vc_log, vc_output]
394
+ )
395
+
396
+ with gr.Row():
397
+ with gr.Column():
398
+ with gr.Tab("Edge-TTS"):
399
+ tts_text.render()
400
+ tts_voice.render()
401
+ with gr.Tab("Upload/Record"):
402
+ vc_input.render()
403
+ vc_upload.render()
404
+ if(not limitation):
405
+ with gr.Tab("YouTube"):
406
+ vc_download_audio.render()
407
+ vc_link.render()
408
+ vc_split_model.render()
409
+ vc_split.render()
410
+ vc_vocal_preview.render()
411
+ vc_inst_preview.render()
412
+ vc_audio_preview.render()
413
+ with gr.Column():
414
+ vc_transform0.render()
415
+ f0method0.render()
416
+ index_rate1.render()
417
+ with gr.Accordion("Advanced Options", open=False):
418
+ filter_radius0.render()
419
+ resample_sr0.render()
420
+ rms_mix_rate0.render()
421
+ protect0.render()
422
+
423
+ vc_split.click(
424
+ fn=cut_vocal_and_inst,
425
+ inputs=[vc_link, vc_download_audio, vc_split_model],
426
+ outputs=[vc_vocal_preview, vc_inst_preview, vc_audio_preview, vc_input]
427
+ )
428
+
429
+ authStr=", ".join(authors)
430
+ gr.Markdown(
431
+ "## <center>Credit to:\n"
432
+ "#### <center>Original devs:\n"
433
+ "<center>the RVC Project, lj1995, zomehwh, sysf\n\n"
434
+ "#### <center>Model creators:\n"
435
+ f"<center>{authStr}\n"
436
+ )
437
+
438
+ if limitation is True:
439
+ app.queue(max_size=20, api_open=config.api).launch(allowed_paths=["/"])
440
+ else:
441
+ app.queue(max_size=20, api_open=config.api).launch(allowed_paths=["/"], share=False)