Ilzhabimantara commited on
Commit
5cf7666
1 Parent(s): 6c2e83b

Update app.py

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