kiuuiro commited on
Commit
f133178
·
verified ·
1 Parent(s): e026483

Create rvc.py

Browse files
Files changed (1) hide show
  1. lib/rvc.py +451 -0
lib/rvc.py ADDED
@@ -0,0 +1,451 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import argparse
2
+ import gc
3
+ import hashlib
4
+ import json
5
+ import os
6
+ import shlex
7
+ import subprocess
8
+ from contextlib import suppress
9
+ from urllib.parse import urlparse, parse_qs
10
+
11
+ import gradio as gr
12
+ import librosa
13
+ import numpy as np
14
+ import soundfile as sf
15
+ import sox
16
+ import yt_dlp
17
+ from pedalboard import Pedalboard, Reverb, Compressor, HighpassFilter
18
+ from pedalboard.io import AudioFile
19
+ from pydub import AudioSegment
20
+ from audio_separator.separator import Separator
21
+ from lib.infer import infer_audio
22
+
23
+ # Base directories
24
+ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
25
+ mdxnet_models_dir = os.path.join(BASE_DIR, 'mdxnet_models')
26
+ rvc_models_dir = os.path.join(BASE_DIR, 'models')
27
+ output_dir = os.path.join(BASE_DIR, 'song_output')
28
+
29
+
30
+ def get_youtube_video_id(url, ignore_playlist=True):
31
+ """
32
+ Extract the YouTube video ID from various URL formats.
33
+
34
+ Examples:
35
+ http://youtu.be/SA2iWivDJiE
36
+ http://www.youtube.com/watch?v=_oPAwA_Udwc&feature=feedu
37
+ http://www.youtube.com/embed/SA2iWivDJiE
38
+ http://www.youtube.com/v/SA2iWivDJiE?version=3&hl=en_US
39
+ """
40
+ parsed_url = urlparse(url)
41
+ hostname = parsed_url.hostname or ''
42
+ path = parsed_url.path
43
+
44
+ if hostname.lower() == 'youtu.be':
45
+ return path.lstrip('/')
46
+
47
+ if hostname.lower() in {'www.youtube.com', 'youtube.com', 'music.youtube.com'}:
48
+ if not ignore_playlist:
49
+ with suppress(KeyError):
50
+ return parse_qs(parsed_url.query)['list'][0]
51
+ if parsed_url.path == '/watch':
52
+ return parse_qs(parsed_url.query).get('v', [None])[0]
53
+ if parsed_url.path.startswith('/watch/'):
54
+ return parsed_url.path.split('/')[1]
55
+ if parsed_url.path.startswith('/embed/'):
56
+ return parsed_url.path.split('/')[2]
57
+ if parsed_url.path.startswith('/v/'):
58
+ return parsed_url.path.split('/')[2]
59
+
60
+ return None
61
+
62
+
63
+ def yt_download(link):
64
+ """
65
+ Download the audio from a YouTube link as an mp3 file.
66
+ """
67
+ ydl_opts = {
68
+ 'format': 'bestaudio',
69
+ 'outtmpl': '%(title)s',
70
+ 'nocheckcertificate': True,
71
+ 'ignoreerrors': True,
72
+ 'no_warnings': True,
73
+ 'quiet': True,
74
+ 'extractaudio': True,
75
+ 'postprocessors': [{
76
+ 'key': 'FFmpegExtractAudio',
77
+ 'preferredcodec': 'mp3'
78
+ }],
79
+ }
80
+ with yt_dlp.YoutubeDL(ydl_opts) as ydl:
81
+ result = ydl.extract_info(link, download=True)
82
+ download_path = ydl.prepare_filename(result, outtmpl='%(title)s.mp3')
83
+ return download_path
84
+
85
+
86
+ def display_progress(message, percent, is_webui, progress=None):
87
+ """
88
+ Display progress either via the provided progress callback or by printing.
89
+ """
90
+ if is_webui and progress is not None:
91
+ progress(percent, desc=message)
92
+ else:
93
+ print(message)
94
+
95
+
96
+ def raise_exception(error_msg, is_webui):
97
+ """
98
+ Raise an exception. If running in a web UI, use gr.Error.
99
+ """
100
+ if is_webui:
101
+ raise gr.Error(error_msg)
102
+ else:
103
+ raise Exception(error_msg)
104
+
105
+
106
+
107
+ def separation_uvr(filename, output):
108
+ """
109
+ Run the separation steps using different pre-trained models.
110
+ Returns a tuple of four file paths:
111
+ - vocals_no_reverb: The vocals after initial de-echo/de-reverb (used as intermediate vocals)
112
+ - instrumental_path: The separated instrumental audio
113
+ - main_vocals_dereverb: The lead vocals after final de-reverb processing
114
+ - backup_vocals: The backup vocals extracted in the final stage
115
+ """
116
+ separator = Separator(output_dir=output)
117
+ base_name = os.path.splitext(os.path.basename(filename))[0]
118
+
119
+ instrumental_path = os.path.join(output, f'{base_name}_Instrumental.wav')
120
+ initial_vocals = os.path.join(output, f'{base_name}_Vocals.wav')
121
+ vocals_no_reverb = os.path.join(output, f'{base_name}_Vocals (No Reverb).wav')
122
+ vocals_reverb = os.path.join(output, f'{base_name}_Vocals (Reverb).wav')
123
+ main_vocals_dereverb = os.path.join(output, f'{base_name}_Vocals_Main_DeReverb.wav')
124
+ backup_vocals = os.path.join(output, f'{base_name}_Vocals_Backup.wav')
125
+
126
+ separator.load_model(model_filename='model_bs_roformer_ep_317_sdr_12.9755.ckpt')
127
+ voc_inst = separator.separate(filename)
128
+ os.rename(os.path.join(output, voc_inst[0]), instrumental_path)
129
+ os.rename(os.path.join(output, voc_inst[1]), initial_vocals)
130
+
131
+ separator.load_model(model_filename='UVR-DeEcho-DeReverb.pth')
132
+ voc_no_reverb = separator.separate(initial_vocals)
133
+ os.rename(os.path.join(output, voc_no_reverb[0]), vocals_no_reverb)
134
+ os.rename(os.path.join(output, voc_no_reverb[1]), vocals_reverb)
135
+
136
+ separator.load_model(model_filename='mel_band_roformer_karaoke_aufr33_viperx_sdr_10.1956.ckpt')
137
+ voc_split = separator.separate(vocals_no_reverb)
138
+ os.rename(os.path.join(output, voc_split[0]), backup_vocals)
139
+ os.rename(os.path.join(output, voc_split[1]), main_vocals_dereverb)
140
+
141
+ if os.path.exists(vocals_reverb):
142
+ os.remove(vocals_reverb)
143
+
144
+ return vocals_no_reverb, instrumental_path, main_vocals_dereverb, backup_vocals
145
+
146
+
147
+ def get_audio_paths(song_dir):
148
+ """
149
+ Search the given directory for expected audio files.
150
+ Returns:
151
+ orig_song_path, instrumentals_path, main_vocals_dereverb_path, backup_vocals_path
152
+ """
153
+ orig_song_path = None
154
+ instrumentals_path = None
155
+ main_vocals_dereverb_path = None
156
+ backup_vocals_path = None
157
+
158
+ for file in os.listdir(song_dir):
159
+ if file.endswith('_Instrumental.wav'):
160
+ instrumentals_path = os.path.join(song_dir, file)
161
+ orig_song_path = instrumentals_path.replace('_Instrumental', '')
162
+ elif file.endswith('_Vocals_Main_DeReverb.wav'):
163
+ main_vocals_dereverb_path = os.path.join(song_dir, file)
164
+ elif file.endswith('_Vocals_Backup.wav'):
165
+ backup_vocals_path = os.path.join(song_dir, file)
166
+
167
+ return orig_song_path, instrumentals_path, main_vocals_dereverb_path, backup_vocals_path
168
+
169
+
170
+ def convert_to_stereo(audio_path):
171
+ """
172
+ Convert the given audio file to stereo (2 channels) if it is mono.
173
+ """
174
+ wave, sr = librosa.load(audio_path, mono=False, sr=44100)
175
+ if wave.ndim == 1:
176
+ stereo_path = f'{os.path.splitext(audio_path)[0]}_stereo.wav'
177
+ command = shlex.split(f'ffmpeg -y -loglevel error -i "{audio_path}" -ac 2 -f wav "{stereo_path}"')
178
+ subprocess.run(command, check=True)
179
+ return stereo_path
180
+ return audio_path
181
+
182
+
183
+ def pitch_shift(audio_path, pitch_change):
184
+ """
185
+ Shift the pitch of the audio by the specified amount.
186
+ """
187
+ output_path = f'{os.path.splitext(audio_path)[0]}_p{pitch_change}.wav'
188
+ if not os.path.exists(output_path):
189
+ y, sr = sf.read(audio_path)
190
+ tfm = sox.Transformer()
191
+ tfm.pitch(pitch_change)
192
+ y_shifted = tfm.build_array(input_array=y, sample_rate_in=sr)
193
+ sf.write(output_path, y_shifted, sr)
194
+ return output_path
195
+
196
+
197
+ def get_hash(filepath):
198
+ """
199
+ Calculate a short BLAKE2b hash for the given file.
200
+ """
201
+ with open(filepath, 'rb') as f:
202
+ file_hash = hashlib.blake2b()
203
+ while chunk := f.read(8192):
204
+ file_hash.update(chunk)
205
+ return file_hash.hexdigest()[:11]
206
+
207
+
208
+ def preprocess_song(song_input, song_id, is_webui, input_type, progress):
209
+ """
210
+ Preprocess the input song:
211
+ - Download if YouTube URL.
212
+ - Convert to stereo.
213
+ - Separate vocals and instrumentals.
214
+ Returns a tuple with six values matching the expected unpacking in the pipeline.
215
+ """
216
+ if input_type == 'yt':
217
+ display_progress('[~] Downloading song...', 0, is_webui, progress)
218
+ song_link = song_input.split('&')[0]
219
+ orig_song_path = yt_download(song_link)
220
+ elif input_type == 'local':
221
+ orig_song_path = song_input
222
+ else:
223
+ orig_song_path = None
224
+
225
+ song_output_dir = os.path.join(output_dir, song_id)
226
+ if not os.path.exists(song_output_dir):
227
+ os.makedirs(song_output_dir)
228
+
229
+ orig_song_path = convert_to_stereo(orig_song_path)
230
+
231
+ display_progress('[~] Separating Vocals from Instrumental...', 0.1, is_webui, progress)
232
+ vocals_no_reverb, instrumental_path, main_vocals_dereverb, backup_vocals = separation_uvr(orig_song_path, song_output_dir)
233
+ return orig_song_path, vocals_no_reverb, instrumental_path, main_vocals_dereverb, backup_vocals, main_vocals_dereverb
234
+
235
+
236
+ def voice_change(voice_model, vocals_path, output_path, pitch_change, f0_method,
237
+ index_rate, filter_radius, rms_mix_rate, protect, crepe_hop_length, is_webui):
238
+ """
239
+ Convert the input vocals using the specified RVC model.
240
+ """
241
+ rvc_model_path, rvc_index_path = get_rvc_model(voice_model, is_webui)
242
+
243
+ inferred_audio = infer_audio(
244
+ MODEL_NAME=voice_model,
245
+ SOUND_PATH=vocals_path,
246
+ F0_CHANGE=pitch_change,
247
+ F0_METHOD=f0_method,
248
+ CREPE_HOP_LENGTH=crepe_hop_length,
249
+ INDEX_RATE=index_rate,
250
+ FILTER_RADIUS=filter_radius,
251
+ RMS_MIX_RATE=rms_mix_rate,
252
+ PROTECT=protect,
253
+ )
254
+ gc.collect()
255
+
256
+
257
+ def add_audio_effects(audio_path, reverb_rm_size, reverb_wet, reverb_dry, reverb_damping):
258
+ """
259
+ Apply a chain of audio effects (highpass, compression, reverb) to the input audio.
260
+ """
261
+ output_path = f'{os.path.splitext(audio_path)[0]}_mixed.wav'
262
+ board = Pedalboard([
263
+ HighpassFilter(),
264
+ Compressor(ratio=4, threshold_db=-15),
265
+ Reverb(room_size=reverb_rm_size, dry_level=reverb_dry, wet_level=reverb_wet, damping=reverb_damping)
266
+ ])
267
+
268
+ with AudioFile(audio_path) as f:
269
+ with AudioFile(output_path, 'w', f.samplerate, f.num_channels) as o:
270
+ while f.tell() < f.frames:
271
+ chunk = f.read(int(f.samplerate))
272
+ effected = board(chunk, f.samplerate, reset=False)
273
+ o.write(effected)
274
+ return output_path
275
+
276
+
277
+ def combine_audio(audio_paths, output_path, main_gain, backup_gain, inst_gain, output_format):
278
+ """
279
+ Combine main vocals, backup vocals, and instrumental audio into a final mix.
280
+ """
281
+ main_vocal_audio = AudioSegment.from_wav(audio_paths[0]) - 4 + main_gain
282
+ backup_vocal_audio = AudioSegment.from_wav(audio_paths[1]) - 6 + backup_gain
283
+ instrumental_audio = AudioSegment.from_wav(audio_paths[2]) - 7 + inst_gain
284
+ final_audio = main_vocal_audio.overlay(backup_vocal_audio).overlay(instrumental_audio)
285
+ final_audio.export(output_path, format=output_format)
286
+
287
+
288
+ def song_cover_pipeline(song_input, voice_model, pitch_change, keep_files,
289
+ is_webui=0, main_gain=0, backup_gain=0, inst_gain=0, index_rate=0.5, filter_radius=3,
290
+ rms_mix_rate=0.25, f0_method='rmvpe', crepe_hop_length=128, protect=0.33, pitch_change_all=0,
291
+ reverb_rm_size=0.15, reverb_wet=0.2, reverb_dry=0.8, reverb_damping=0.7, output_format='mp3',
292
+ progress=gr.Progress()):
293
+ """
294
+ Main pipeline that orchestrates the AI cover song generation.
295
+ """
296
+ try:
297
+ if not song_input or not voice_model:
298
+ raise_exception('Ensure that the song input field and voice model field is filled.', is_webui)
299
+
300
+ display_progress('[~] Starting AI Cover Generation Pipeline...', 0, is_webui, progress)
301
+
302
+ if urlparse(song_input).scheme == 'https':
303
+ input_type = 'yt'
304
+ song_id = get_youtube_video_id(song_input)
305
+ if song_id is None:
306
+ raise_exception('Invalid YouTube url.', is_webui)
307
+ else:
308
+ input_type = 'local'
309
+ song_input = song_input.strip('\"')
310
+ if os.path.exists(song_input):
311
+ song_id = get_hash(song_input)
312
+ else:
313
+ raise_exception(f'{song_input} does not exist.', is_webui)
314
+
315
+ song_dir = os.path.join(output_dir, song_id)
316
+
317
+ if not os.path.exists(song_dir):
318
+ os.makedirs(song_dir)
319
+ (orig_song_path, vocals_path, instrumentals_path,
320
+ main_vocals_path, backup_vocals_path, main_vocals_dereverb_path) = preprocess_song(
321
+ song_input, song_id, is_webui, input_type, progress
322
+ )
323
+ else:
324
+ vocals_path, main_vocals_path = None, None
325
+ paths = get_audio_paths(song_dir)
326
+ if any(path is None for path in paths) or keep_files:
327
+ (orig_song_path, vocals_path, instrumentals_path,
328
+ main_vocals_path, backup_vocals_path, main_vocals_dereverb_path) = preprocess_song(
329
+ song_input, song_id, is_webui, input_type, progress
330
+ )
331
+ else:
332
+ orig_song_path, instrumentals_path, main_vocals_dereverb_path, backup_vocals_path = paths
333
+ main_vocals_path = main_vocals_dereverb_path
334
+
335
+ pitch_change += pitch_change_all
336
+
337
+ base_song_name = os.path.splitext(os.path.basename(orig_song_path))[0]
338
+ algo_suffix = f"_{crepe_hop_length}" if f0_method == "mangio-crepe" else ""
339
+ ai_vocals_path = os.path.join(
340
+ song_dir,
341
+ f'{base_song_name}_lead_{voice_model}_p{pitch_change}_i{index_rate}_fr{filter_radius}_'
342
+ f'rms{rms_mix_rate}_pro{protect}_{f0_method}{algo_suffix}.wav'
343
+ )
344
+ ai_backing_path = os.path.join(
345
+ song_dir,
346
+ f'{base_song_name}_backing_{voice_model}_p{pitch_change}_i{index_rate}_fr{filter_radius}_'
347
+ f'rms{rms_mix_rate}_pro{protect}_{f0_method}{algo_suffix}.wav'
348
+ )
349
+ ai_cover_path = os.path.join(song_dir, f'{base_song_name} ({voice_model} Ver).{output_format}')
350
+ ai_cover_backing_path = os.path.join(song_dir, f'{base_song_name} ({voice_model} Ver With Backing).{output_format}')
351
+
352
+ if not os.path.exists(ai_vocals_path):
353
+ display_progress('[~] Converting lead voice using RVC...', 0.5, is_webui, progress)
354
+ voice_change(voice_model, main_vocals_dereverb_path, ai_vocals_path, pitch_change,
355
+ f0_method, index_rate, filter_radius, rms_mix_rate, protect, crepe_hop_length, is_webui)
356
+
357
+ display_progress('[~] Converting backing voice using RVC...', 0.65, is_webui, progress)
358
+ voice_change(voice_model, backup_vocals_path, ai_backing_path, pitch_change,
359
+ f0_method, index_rate, filter_radius, rms_mix_rate, protect, crepe_hop_length, is_webui)
360
+
361
+ display_progress('[~] Applying audio effects to Vocals...', 0.8, is_webui, progress)
362
+ ai_vocals_mixed_path = add_audio_effects(ai_vocals_path, reverb_rm_size, reverb_wet, reverb_dry, reverb_damping)
363
+ ai_backing_mixed_path = add_audio_effects(ai_backing_path, reverb_rm_size, reverb_wet, reverb_dry, reverb_damping)
364
+
365
+ if pitch_change_all != 0:
366
+ display_progress('[~] Applying overall pitch change', 0.85, is_webui, progress)
367
+ instrumentals_path = pitch_shift(instrumentals_path, pitch_change_all)
368
+ backup_vocals_path = pitch_shift(backup_vocals_path, pitch_change_all)
369
+
370
+ display_progress('[~] Combining AI Vocals and Instrumentals...', 0.9, is_webui, progress)
371
+ combine_audio([ai_vocals_mixed_path, backup_vocals_path, instrumentals_path],
372
+ ai_cover_path, main_gain, backup_gain, inst_gain, output_format)
373
+ combine_audio([ai_vocals_mixed_path, ai_backing_mixed_path, instrumentals_path],
374
+ ai_cover_backing_path, main_gain, backup_gain, inst_gain, output_format)
375
+
376
+ if not keep_files:
377
+ display_progress('[~] Removing intermediate audio files...', 0.95, is_webui, progress)
378
+ intermediate_files = [vocals_path, main_vocals_path, ai_vocals_mixed_path, ai_backing_mixed_path]
379
+ if pitch_change_all != 0:
380
+ intermediate_files += [instrumentals_path, backup_vocals_path]
381
+ for file in intermediate_files:
382
+ if file and os.path.exists(file):
383
+ os.remove(file)
384
+
385
+ return ai_cover_path, ai_cover_backing_path
386
+
387
+ except Exception as e:
388
+ raise_exception(str(e), is_webui)
389
+
390
+
391
+ if __name__ == '__main__':
392
+ parser = argparse.ArgumentParser(
393
+ description='AICoverGen: Mod.',
394
+ add_help=True
395
+ )
396
+ parser.add_argument('-i', '--song-input', type=str, required=True,
397
+ help='Link to a YouTube video or the filepath to a local mp3/wav file to create an AI cover of')
398
+ parser.add_argument('-dir', '--rvc-dirname', type=str, required=True,
399
+ help='Name of the folder in the rvc_models directory containing the RVC model file and optional index file to use')
400
+ parser.add_argument('-p', '--pitch-change', type=int, required=True,
401
+ help='Change the pitch of AI Vocals only. Generally, use 1 for male to female and -1 for vice-versa. (Octaves)')
402
+ parser.add_argument('-k', '--keep-files', action=argparse.BooleanOptionalAction,
403
+ help='Whether to keep all intermediate audio files generated in the song_output/id directory, e.g. Isolated Vocals/Instrumentals')
404
+ parser.add_argument('-ir', '--index-rate', type=float, default=0.5,
405
+ help='A decimal number e.g. 0.5, used to reduce/resolve the timbre leakage problem. If set to 1, more biased towards the timbre quality of the training dataset')
406
+ parser.add_argument('-fr', '--filter-radius', type=int, default=3,
407
+ help='A number between 0 and 7. If >=3: apply median filtering to the harvested pitch results. The value represents the filter radius and can reduce breathiness.')
408
+ parser.add_argument('-rms', '--rms-mix-rate', type=float, default=0.25,
409
+ help="A decimal number e.g. 0.25. Control how much to use the original vocal's loudness (0) or a fixed loudness (1).")
410
+ parser.add_argument('-palgo', '--pitch-detection-algo', type=str, default='rmvpe',
411
+ help='Best option is rmvpe (clarity in vocals), then mangio-crepe (smoother vocals).')
412
+ parser.add_argument('-hop', '--crepe-hop-length', type=int, default=128,
413
+ help='If pitch detection algo is mangio-crepe, controls how often it checks for pitch changes in milliseconds. Recommended: 128.')
414
+ parser.add_argument('-pro', '--protect', type=float, default=0.33,
415
+ help='A decimal number e.g. 0.33. Protect voiceless consonants and breath sounds to prevent artifacts such as tearing in electronic music.')
416
+ parser.add_argument('-mv', '--main-vol', type=int, default=0,
417
+ help='Volume change for AI main vocals in decibels. Use -3 to decrease by 3 dB and 3 to increase by 3 dB')
418
+ parser.add_argument('-bv', '--backup-vol', type=int, default=0,
419
+ help='Volume change for backup vocals in decibels')
420
+ parser.add_argument('-iv', '--inst-vol', type=int, default=0,
421
+ help='Volume change for instrumentals in decibels')
422
+ parser.add_argument('-pall', '--pitch-change-all', type=int, default=0,
423
+ help='Change the pitch/key of vocals and instrumentals. Changing this slightly reduces sound quality')
424
+ parser.add_argument('-rsize', '--reverb-size', type=float, default=0.15,
425
+ help='Reverb room size between 0 and 1')
426
+ parser.add_argument('-rwet', '--reverb-wetness', type=float, default=0.2,
427
+ help='Reverb wet level between 0 and 1')
428
+ parser.add_argument('-rdry', '--reverb-dryness', type=float, default=0.8,
429
+ help='Reverb dry level between 0 and 1')
430
+ parser.add_argument('-rdamp', '--reverb-damping', type=float, default=0.7,
431
+ help='Reverb damping between 0 and 1')
432
+ parser.add_argument('-oformat', '--output-format', type=str, default='mp3',
433
+ help='Output format of audio file. mp3 for smaller file size, wav for best quality')
434
+ args = parser.parse_args()
435
+
436
+ rvc_dir = os.path.join(rvc_models_dir, args.rvc_dirname)
437
+ if not os.path.exists(rvc_dir):
438
+ raise Exception(f'The folder {rvc_dir} does not exist.')
439
+
440
+ cover_path, cover_with_backing = song_cover_pipeline(
441
+ args.song_input, args.rvc_dirname, args.pitch_change, args.keep_files,
442
+ main_gain=args.main_vol, backup_gain=args.backup_vol, inst_gain=args.inst_vol,
443
+ index_rate=args.index_rate, filter_radius=args.filter_radius,
444
+ rms_mix_rate=args.rms_mix_rate, f0_method=args.pitch_detection_algo,
445
+ crepe_hop_length=args.crepe_hop_length, protect=args.protect,
446
+ pitch_change_all=args.pitch_change_all,
447
+ reverb_rm_size=args.reverb_size, reverb_wet=args.reverb_wetness,
448
+ reverb_dry=args.reverb_dryness, reverb_damping=args.reverb_damping,
449
+ output_format=args.output_format
450
+ )
451
+ print(f'[+] Cover generated at {cover_path}')