Nick1 commited on
Commit
63e6f39
·
verified ·
1 Parent(s): 9b48034

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -680
app.py DELETED
@@ -1,680 +0,0 @@
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
- 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 > 90 and spaces:
85
- return "Please upload an audio file that is less than 90 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) > 300 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
- logs.append("URL required!")
190
- yield None, "\n".join(logs)
191
- return None, "\n".join(logs)
192
- if not os.path.exists("dl_audio"):
193
- os.mkdir("dl_audio")
194
- if audio_provider == "Youtube":
195
- logs.append("Downloading the audio...")
196
- yield None, "\n".join(logs)
197
- ydl_opts = {
198
- 'noplaylist': True,
199
- 'format': 'bestaudio/best',
200
- 'postprocessors': [{
201
- 'key': 'FFmpegExtractAudio',
202
- 'preferredcodec': 'wav',
203
- }],
204
- "outtmpl": 'dl_audio/audio',
205
- }
206
- audio_path = "dl_audio/audio.wav"
207
- with yt_dlp.YoutubeDL(ydl_opts) as ydl:
208
- ydl.download([url])
209
- logs.append("Download Complete.")
210
- yield audio_path, "\n".join(logs)
211
-
212
- def cut_vocal_and_inst(split_model):
213
- logs = []
214
- logs.append("Starting the audio splitting process...")
215
- yield "\n".join(logs), None, None, None
216
- command = f"demucs --two-stems=vocals -n {split_model} dl_audio/audio.wav -o output"
217
- result = subprocess.Popen(command.split(), stdout=subprocess.PIPE, text=True)
218
- for line in result.stdout:
219
- logs.append(line)
220
- yield "\n".join(logs), None, None, None
221
- print(result.stdout)
222
- vocal = f"output/{split_model}/audio/vocals.wav"
223
- inst = f"output/{split_model}/audio/no_vocals.wav"
224
- logs.append("Audio splitting complete.")
225
- yield "\n".join(logs), vocal, inst, vocal
226
-
227
- def combine_vocal_and_inst(audio_data, vocal_volume, inst_volume, split_model):
228
- if not os.path.exists("output/result"):
229
- os.mkdir("output/result")
230
- vocal_path = "output/result/output.wav"
231
- output_path = "output/result/combine.mp3"
232
- inst_path = f"output/{split_model}/audio/no_vocals.wav"
233
- with wave.open(vocal_path, "w") as wave_file:
234
- wave_file.setnchannels(1)
235
- wave_file.setsampwidth(2)
236
- wave_file.setframerate(audio_data[0])
237
- wave_file.writeframes(audio_data[1].tobytes())
238
- 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}'
239
- result = subprocess.run(command.split(), stdout=subprocess.PIPE)
240
- print(result.stdout.decode())
241
- return output_path
242
-
243
- def load_hubert():
244
- global hubert_model
245
- models, _, _ = checkpoint_utils.load_model_ensemble_and_task(
246
- ["hubert_base.pt"],
247
- suffix="",
248
- )
249
- hubert_model = models[0]
250
- hubert_model = hubert_model.to(config.device)
251
- if config.is_half:
252
- hubert_model = hubert_model.half()
253
- else:
254
- hubert_model = hubert_model.float()
255
- hubert_model.eval()
256
-
257
- def change_audio_mode(vc_audio_mode):
258
- if vc_audio_mode == "Input path":
259
- return (
260
- # Input & Upload
261
- gr.Textbox.update(visible=True),
262
- gr.Checkbox.update(visible=False),
263
- gr.Audio.update(visible=False),
264
- # Youtube
265
- gr.Dropdown.update(visible=False),
266
- gr.Textbox.update(visible=False),
267
- gr.Textbox.update(visible=False),
268
- gr.Button.update(visible=False),
269
- # Splitter
270
- gr.Dropdown.update(visible=False),
271
- gr.Textbox.update(visible=False),
272
- gr.Button.update(visible=False),
273
- gr.Audio.update(visible=False),
274
- gr.Audio.update(visible=False),
275
- gr.Audio.update(visible=False),
276
- gr.Slider.update(visible=False),
277
- gr.Slider.update(visible=False),
278
- gr.Audio.update(visible=False),
279
- gr.Button.update(visible=False),
280
- # TTS
281
- gr.Textbox.update(visible=False),
282
- gr.Dropdown.update(visible=False)
283
- )
284
- elif vc_audio_mode == "Upload audio":
285
- return (
286
- # Input & Upload
287
- gr.Textbox.update(visible=False),
288
- gr.Checkbox.update(visible=True),
289
- gr.Audio.update(visible=True),
290
- # Youtube
291
- gr.Dropdown.update(visible=False),
292
- gr.Textbox.update(visible=False),
293
- gr.Textbox.update(visible=False),
294
- gr.Button.update(visible=False),
295
- # Splitter
296
- gr.Dropdown.update(visible=False),
297
- gr.Textbox.update(visible=False),
298
- gr.Button.update(visible=False),
299
- gr.Audio.update(visible=False),
300
- gr.Audio.update(visible=False),
301
- gr.Audio.update(visible=False),
302
- gr.Slider.update(visible=False),
303
- gr.Slider.update(visible=False),
304
- gr.Audio.update(visible=False),
305
- gr.Button.update(visible=False),
306
- # TTS
307
- gr.Textbox.update(visible=False),
308
- gr.Dropdown.update(visible=False)
309
- )
310
- elif vc_audio_mode == "Youtube":
311
- return (
312
- # Input & Upload
313
- gr.Textbox.update(visible=False),
314
- gr.Checkbox.update(visible=False),
315
- gr.Audio.update(visible=False),
316
- # Youtube
317
- gr.Dropdown.update(visible=True),
318
- gr.Textbox.update(visible=True),
319
- gr.Textbox.update(visible=True),
320
- gr.Button.update(visible=True),
321
- # Splitter
322
- gr.Dropdown.update(visible=True),
323
- gr.Textbox.update(visible=True),
324
- gr.Button.update(visible=True),
325
- gr.Audio.update(visible=True),
326
- gr.Audio.update(visible=True),
327
- gr.Audio.update(visible=True),
328
- gr.Slider.update(visible=True),
329
- gr.Slider.update(visible=True),
330
- gr.Audio.update(visible=True),
331
- gr.Button.update(visible=True),
332
- # TTS
333
- gr.Textbox.update(visible=False),
334
- gr.Dropdown.update(visible=False)
335
- )
336
- elif vc_audio_mode == "TTS Audio":
337
- return (
338
- # Input & Upload
339
- gr.Textbox.update(visible=False),
340
- gr.Checkbox.update(visible=False),
341
- gr.Audio.update(visible=False),
342
- # Youtube
343
- gr.Dropdown.update(visible=False),
344
- gr.Textbox.update(visible=False),
345
- gr.Textbox.update(visible=False),
346
- gr.Button.update(visible=False),
347
- # Splitter
348
- gr.Dropdown.update(visible=False),
349
- gr.Textbox.update(visible=False),
350
- gr.Button.update(visible=False),
351
- gr.Audio.update(visible=False),
352
- gr.Audio.update(visible=False),
353
- gr.Audio.update(visible=False),
354
- gr.Slider.update(visible=False),
355
- gr.Slider.update(visible=False),
356
- gr.Audio.update(visible=False),
357
- gr.Button.update(visible=False),
358
- # TTS
359
- gr.Textbox.update(visible=True),
360
- gr.Dropdown.update(visible=True)
361
- )
362
-
363
- def use_microphone(microphone):
364
- if microphone == True:
365
- return gr.Audio.update(source="microphone")
366
- else:
367
- return gr.Audio.update(source="upload")
368
-
369
- if __name__ == '__main__':
370
- load_hubert()
371
- categories = load_model()
372
- tts_voice_list = asyncio.new_event_loop().run_until_complete(edge_tts.list_voices())
373
- voices = [f"{v['ShortName']}-{v['Gender']}" for v in tts_voice_list]
374
- with gr.Blocks() as app:
375
- gr.Markdown(
376
- "<div align='center'>\n\n"+
377
- "# RVC Modal\n\n"+
378
- "### Ya upload audio nya 90s saja.\n\n"+
379
- "[Enjoy]\n\n"+
380
- "[tapi kena tunggu beberapa lama kalau upload 90s]\n\n"+
381
- "</div>\n\n"+
382
- ""
383
- )
384
- if categories == []:
385
- gr.Markdown(
386
- "<div align='center'>\n\n"+
387
- "## No model found, please add the model into weights folder\n\n"+
388
- "</div>"
389
- )
390
- for (folder_title, folder, description, models) in categories:
391
- with gr.TabItem(folder_title):
392
- if description:
393
- gr.Markdown(f"### <center> {description}")
394
- with gr.Tabs():
395
- if not models:
396
- gr.Markdown("# <center> No Model Loaded.")
397
- gr.Markdown("## <center> Please add the model or fix your model path.")
398
- continue
399
- for (name, title, author, cover, model_version, vc_fn) in models:
400
- with gr.TabItem(name):
401
- with gr.Row():
402
- gr.Markdown(
403
- '<div align="center">'
404
- f'<div>{title}</div>\n'+
405
- f'<div>RVC {model_version} Model</div>\n'+
406
- (f'<div>Model author: {author}</div>' if author else "")+
407
- (f'<img style="width:auto;height:300px;" src="file/{cover}">' if cover else "")+
408
- '</div>'
409
- )
410
- with gr.Row():
411
- if spaces is False:
412
- with gr.TabItem("Input"):
413
- with gr.Row():
414
- with gr.Column():
415
- vc_audio_mode = gr.Dropdown(label="Input voice", choices=audio_mode, allow_custom_value=False, value="Upload audio")
416
- # Input
417
- vc_input = gr.Textbox(label="Input audio path", visible=False)
418
- # Upload
419
- vc_microphone_mode = gr.Checkbox(label="Use Microphone", value=False, visible=True, interactive=True)
420
- vc_upload = gr.Audio(label="Upload audio file", source="upload", visible=True, interactive=True)
421
- # Youtube
422
- vc_download_audio = gr.Dropdown(label="Provider", choices=["Youtube"], allow_custom_value=False, visible=False, value="Youtube", info="Select provider (Default: Youtube)")
423
- 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=...")
424
- vc_log_yt = gr.Textbox(label="Output Information", visible=False, interactive=False)
425
- vc_download_button = gr.Button("Download Audio", variant="primary", visible=False)
426
- vc_audio_preview = gr.Audio(label="Audio Preview", visible=False)
427
- # TTS
428
- tts_text = gr.Textbox(label="TTS text", info="Text to speech input", visible=False)
429
- tts_voice = gr.Dropdown(label="Edge-tts speaker", choices=voices, visible=False, allow_custom_value=False, value="en-US-AnaNeural-Female")
430
- with gr.Column():
431
- 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)")
432
- vc_split_log = gr.Textbox(label="Output Information", visible=False, interactive=False)
433
- vc_split = gr.Button("Split Audio", variant="primary", visible=False)
434
- vc_vocal_preview = gr.Audio(label="Vocal Preview", visible=False)
435
- vc_inst_preview = gr.Audio(label="Instrumental Preview", visible=False)
436
- with gr.TabItem("Convert"):
437
- with gr.Row():
438
- with gr.Column():
439
- 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')
440
- f0method0 = gr.Radio(
441
- label="Pitch extraction algorithm",
442
- info=f0method_info,
443
- choices=f0method_mode,
444
- value="pm",
445
- interactive=True
446
- )
447
- index_rate1 = gr.Slider(
448
- minimum=0,
449
- maximum=1,
450
- label="Retrieval feature ratio",
451
- info="(Default: 0.7)",
452
- value=0.7,
453
- interactive=True,
454
- )
455
- filter_radius0 = gr.Slider(
456
- minimum=0,
457
- maximum=7,
458
- label="Apply Median Filtering",
459
- info="The value represents the filter radius and can reduce breathiness.",
460
- value=3,
461
- step=1,
462
- interactive=True,
463
- )
464
- resample_sr0 = gr.Slider(
465
- minimum=0,
466
- maximum=48000,
467
- label="Resample the output audio",
468
- info="Resample the output audio in post-processing to the final sample rate. Set to 0 for no resampling",
469
- value=0,
470
- step=1,
471
- interactive=True,
472
- )
473
- rms_mix_rate0 = gr.Slider(
474
- minimum=0,
475
- maximum=1,
476
- label="Volume Envelope",
477
- 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",
478
- value=1,
479
- interactive=True,
480
- )
481
- protect0 = gr.Slider(
482
- minimum=0,
483
- maximum=0.5,
484
- label="Voice Protection",
485
- 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",
486
- value=0.5,
487
- step=0.01,
488
- interactive=True,
489
- )
490
- with gr.Column():
491
- vc_log = gr.Textbox(label="Output Information", interactive=False)
492
- vc_output = gr.Audio(label="Output Audio", interactive=False)
493
- vc_convert = gr.Button("Convert", variant="primary")
494
- vc_vocal_volume = gr.Slider(
495
- minimum=0,
496
- maximum=10,
497
- label="Vocal volume",
498
- value=1,
499
- interactive=True,
500
- step=1,
501
- info="Adjust vocal volume (Default: 1}",
502
- visible=False
503
- )
504
- vc_inst_volume = gr.Slider(
505
- minimum=0,
506
- maximum=10,
507
- label="Instrument volume",
508
- value=1,
509
- interactive=True,
510
- step=1,
511
- info="Adjust instrument volume (Default: 1}",
512
- visible=False
513
- )
514
- vc_combined_output = gr.Audio(label="Output Combined Audio", visible=False)
515
- vc_combine = gr.Button("Combine",variant="primary", visible=False)
516
- else:
517
- with gr.Column():
518
- vc_audio_mode = gr.Dropdown(label="Input voice", choices=audio_mode, allow_custom_value=False, value="Upload audio")
519
- # Input
520
- vc_input = gr.Textbox(label="Input audio path", visible=False)
521
- # Upload
522
- vc_microphone_mode = gr.Checkbox(label="Use Microphone", value=False, visible=True, interactive=True)
523
- vc_upload = gr.Audio(label="Upload audio file", source="upload", visible=True, interactive=True)
524
- # Youtube
525
- vc_download_audio = gr.Dropdown(label="Provider", choices=["Youtube"], allow_custom_value=False, visible=False, value="Youtube", info="Select provider (Default: Youtube)")
526
- 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=...")
527
- vc_log_yt = gr.Textbox(label="Output Information", visible=False, interactive=False)
528
- vc_download_button = gr.Button("Download Audio", variant="primary", visible=False)
529
- vc_audio_preview = gr.Audio(label="Audio Preview", visible=False)
530
- # Splitter
531
- 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)")
532
- vc_split_log = gr.Textbox(label="Output Information", visible=False, interactive=False)
533
- vc_split = gr.Button("Split Audio", variant="primary", visible=False)
534
- vc_vocal_preview = gr.Audio(label="Vocal Preview", visible=False)
535
- vc_inst_preview = gr.Audio(label="Instrumental Preview", visible=False)
536
- # TTS
537
- tts_text = gr.Textbox(label="TTS text", info="Text to speech input", visible=False)
538
- tts_voice = gr.Dropdown(label="Edge-tts speaker", choices=voices, visible=False, allow_custom_value=False, value="en-US-AnaNeural-Female")
539
- with gr.Column():
540
- 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')
541
- f0method0 = gr.Radio(
542
- label="Pitch extraction algorithm",
543
- info=f0method_info,
544
- choices=f0method_mode,
545
- value="pm",
546
- interactive=True
547
- )
548
- index_rate1 = gr.Slider(
549
- minimum=0,
550
- maximum=1,
551
- label="Retrieval feature ratio",
552
- info="(Default: 0.7)",
553
- value=0.7,
554
- interactive=True,
555
- )
556
- filter_radius0 = gr.Slider(
557
- minimum=0,
558
- maximum=7,
559
- label="Apply Median Filtering",
560
- info="The value represents the filter radius and can reduce breathiness.",
561
- value=3,
562
- step=1,
563
- interactive=True,
564
- )
565
- resample_sr0 = gr.Slider(
566
- minimum=0,
567
- maximum=48000,
568
- label="Resample the output audio",
569
- info="Resample the output audio in post-processing to the final sample rate. Set to 0 for no resampling",
570
- value=0,
571
- step=1,
572
- interactive=True,
573
- )
574
- rms_mix_rate0 = gr.Slider(
575
- minimum=0,
576
- maximum=1,
577
- label="Volume Envelope",
578
- 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",
579
- value=1,
580
- interactive=True,
581
- )
582
- protect0 = gr.Slider(
583
- minimum=0,
584
- maximum=0.5,
585
- label="Voice Protection",
586
- 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",
587
- value=0.5,
588
- step=0.01,
589
- interactive=True,
590
- )
591
- with gr.Column():
592
- vc_log = gr.Textbox(label="Output Information", interactive=False)
593
- vc_output = gr.Audio(label="Output Audio", interactive=False)
594
- vc_convert = gr.Button("Convert", variant="primary")
595
- vc_vocal_volume = gr.Slider(
596
- minimum=0,
597
- maximum=10,
598
- label="Vocal volume",
599
- value=1,
600
- interactive=True,
601
- step=1,
602
- info="Adjust vocal volume (Default: 1}",
603
- visible=False
604
- )
605
- vc_inst_volume = gr.Slider(
606
- minimum=0,
607
- maximum=10,
608
- label="Instrument volume",
609
- value=1,
610
- interactive=True,
611
- step=1,
612
- info="Adjust instrument volume (Default: 1}",
613
- visible=False
614
- )
615
- vc_combined_output = gr.Audio(label="Output Combined Audio", visible=False)
616
- vc_combine = gr.Button("Combine",variant="primary", visible=False)
617
- vc_convert.click(
618
- fn=vc_fn,
619
- inputs=[
620
- vc_audio_mode,
621
- vc_input,
622
- vc_upload,
623
- tts_text,
624
- tts_voice,
625
- vc_transform0,
626
- f0method0,
627
- index_rate1,
628
- filter_radius0,
629
- resample_sr0,
630
- rms_mix_rate0,
631
- protect0,
632
- ],
633
- outputs=[vc_log ,vc_output]
634
- )
635
- vc_download_button.click(
636
- fn=download_audio,
637
- inputs=[vc_link, vc_download_audio],
638
- outputs=[vc_audio_preview, vc_log_yt]
639
- )
640
- vc_split.click(
641
- fn=cut_vocal_and_inst,
642
- inputs=[vc_split_model],
643
- outputs=[vc_split_log, vc_vocal_preview, vc_inst_preview, vc_input]
644
- )
645
- vc_combine.click(
646
- fn=combine_vocal_and_inst,
647
- inputs=[vc_output, vc_vocal_volume, vc_inst_volume, vc_split_model],
648
- outputs=[vc_combined_output]
649
- )
650
- vc_microphone_mode.change(
651
- fn=use_microphone,
652
- inputs=vc_microphone_mode,
653
- outputs=vc_upload
654
- )
655
- vc_audio_mode.change(
656
- fn=change_audio_mode,
657
- inputs=[vc_audio_mode],
658
- outputs=[
659
- vc_input,
660
- vc_microphone_mode,
661
- vc_upload,
662
- vc_download_audio,
663
- vc_link,
664
- vc_log_yt,
665
- vc_download_button,
666
- vc_split_model,
667
- vc_split_log,
668
- vc_split,
669
- vc_audio_preview,
670
- vc_vocal_preview,
671
- vc_inst_preview,
672
- vc_vocal_volume,
673
- vc_inst_volume,
674
- vc_combined_output,
675
- vc_combine,
676
- tts_text,
677
- tts_voice
678
- ]
679
- )
680
- app.queue(concurrency_count=5, max_size=50, api_open=config.api).launch(share=config.colab)