JULES ELH commited on
Commit
2e4e349
·
1 Parent(s): 6fb761a

Upload easy_gui_(for_rvc_v2,_with_crepe)_(with_improved_downloader).py

Browse files
easy_gui_(for_rvc_v2,_with_crepe)_(with_improved_downloader).py ADDED
@@ -0,0 +1,1392 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ """Easy GUI (for RVC v2, with crepe) (with improved downloader)
3
+
4
+ Automatically generated by Colaboratory.
5
+
6
+ Original file is located at
7
+ https://colab.research.google.com/drive/1Gj6UTf2gicndUW_tVheVhTXIIYpFTYc7
8
+
9
+ ### RVC GENERAL COVER GUIDE:
10
+ https://docs.google.com/document/d/13_l1bd1Osgz7qlAZn-zhklCbHpVRk6bYOuAuB78qmsE/edit?usp=sharing
11
+
12
+ ### RVC VOICE TRAINING GUIDE:
13
+ https://docs.google.com/document/d/13ebnzmeEBc6uzYCMt-QVFQk-whVrK4zw8k7_Lw3Bv_A/edit?usp=sharing
14
+
15
+ ##**EDIT 6/17:** Easy GUI interface finally updated by Rejekts, the original colab author!
16
+ ####Major thanks and shoutout to him! Advanced settings have been added to a separate menu. If this new interface gives you troubles, simply enable the old interface again, or ping me @kalomaze in the AI HUB Discord.
17
+
18
+ Keep in mind 'mangio-crepe' is superior to the other 'crepe' in both training and inference. The hop size won't be properly configurable otherwise.
19
+
20
+ ##Step 1. Install (it will take 30-45 seconds)
21
+
22
+ [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/liujing04/Retrieval-based-Voice-Conversion-WebUI/blob/main/Retrieval_based_Voice_Conversion_WebUI.ipynb)
23
+ If you want to open the ORIGINAL Colab go here!
24
+ """
25
+
26
+ #@title GPU Check
27
+ !nvidia-smi
28
+
29
+ #@title Install Dependencies (and load your cached install if it exists to boost times)
30
+ # Required Libraries
31
+ import os
32
+ import csv
33
+ import shutil
34
+ import tarfile
35
+ import subprocess
36
+ from pathlib import Path
37
+ from datetime import datetime
38
+
39
+ #@markdown This will forcefully update dependencies even after the initial install seemed to have functioned.
40
+ ForceUpdateDependencies = False #@param{type:"boolean"}
41
+ #@markdown This will force temporary storage to be used, so it will download dependencies every time instead of on Drive. Not needed, unless you really want that 160mb storage. (Turned on by default for non-training colab to boost the initial launch speed)
42
+ ForceTemporaryStorage = True #@param{type:"boolean"}
43
+
44
+ # Mounting Google Drive
45
+ if not ForceTemporaryStorage:
46
+ from google.colab import drive
47
+
48
+ if not os.path.exists('/content/drive'):
49
+ drive.mount('/content/drive')
50
+ else:
51
+ print('Drive is already mounted. Proceeding...')
52
+
53
+ # Function to install dependencies with progress
54
+ def install_packages():
55
+ packages = ['build-essential', 'python3-dev', 'ffmpeg', 'aria2']
56
+ pip_packages = ['pip', 'setuptools', 'wheel', 'httpx==0.23.0', 'faiss-gpu', 'fairseq', 'gradio==3.34.0',
57
+ 'ffmpeg', 'ffmpeg-python', 'praat-parselmouth', 'pyworld', 'numpy==1.23.5',
58
+ 'numba==0.56.4', 'librosa==0.9.2', 'mega.py', 'gdown', 'onnxruntime', 'pyngrok==4.1.12']
59
+
60
+ print("Updating and installing system packages...")
61
+ for package in packages:
62
+ print(f"Installing {package}...")
63
+ subprocess.check_call(['apt-get', 'install', '-qq', '-y', package])
64
+
65
+ print("Updating and installing pip packages...")
66
+ subprocess.check_call(['pip', 'install', '--upgrade'] + pip_packages)
67
+
68
+ print('Packages up to date.')
69
+
70
+ # Function to scan a directory and writes filenames and timestamps
71
+ def scan_and_write(base_path, output_file):
72
+ with open(output_file, 'w', newline='') as f:
73
+ writer = csv.writer(f)
74
+ for dirpath, dirs, files in os.walk(base_path):
75
+ for filename in files:
76
+ fname = os.path.join(dirpath, filename)
77
+ try:
78
+ mtime = os.path.getmtime(fname)
79
+ writer.writerow([fname, mtime])
80
+ except Exception as e:
81
+ print(f'Skipping irrelevant nonexistent file {fname}: {str(e)}')
82
+ print(f'Finished recording filesystem timestamps to {output_file}.')
83
+
84
+ # Function to compare files
85
+ def compare_files(old_file, new_file):
86
+ old_files = {}
87
+ new_files = {}
88
+
89
+ with open(old_file, 'r') as f:
90
+ reader = csv.reader(f)
91
+ old_files = {rows[0]:rows[1] for rows in reader}
92
+
93
+ with open(new_file, 'r') as f:
94
+ reader = csv.reader(f)
95
+ new_files = {rows[0]:rows[1] for rows in reader}
96
+
97
+ removed_files = old_files.keys() - new_files.keys()
98
+ added_files = new_files.keys() - old_files.keys()
99
+ unchanged_files = old_files.keys() & new_files.keys()
100
+
101
+ changed_files = {f for f in unchanged_files if old_files[f] != new_files[f]}
102
+
103
+ for file in removed_files:
104
+ print(f'File has been removed: {file}')
105
+
106
+ for file in changed_files:
107
+ print(f'File has been updated: {file}')
108
+
109
+ return list(added_files) + list(changed_files)
110
+
111
+ # Check if CachedRVC.tar.gz exists
112
+ if ForceTemporaryStorage:
113
+ file_path = '/content/CachedRVC.tar.gz'
114
+ else:
115
+ file_path = '/content/drive/MyDrive/RVC_Cached/CachedRVC.tar.gz'
116
+
117
+ content_file_path = '/content/CachedRVC.tar.gz'
118
+ extract_path = '/'
119
+
120
+ !pip install -q gTTS
121
+ !pip install -q elevenlabs
122
+
123
+ def extract_wav2lip_tar_files():
124
+ !wget https://github.com/777gt/EVC/raw/main/wav2lip-HD.tar.gz
125
+ !wget https://github.com/777gt/EVC/raw/main/wav2lip-cache.tar.gz
126
+
127
+ with tarfile.open('/content/wav2lip-cache.tar.gz', 'r:gz') as tar:
128
+ for member in tar.getmembers():
129
+ target_path = os.path.join('/', member.name)
130
+ try:
131
+ tar.extract(member, '/')
132
+ except:
133
+ pass
134
+
135
+ with tarfile.open('/content/wav2lip-HD.tar.gz') as tar:
136
+ tar.extractall('/content')
137
+
138
+ extract_wav2lip_tar_files()
139
+
140
+ if not os.path.exists(file_path):
141
+ folder_path = os.path.dirname(file_path)
142
+ os.makedirs(folder_path, exist_ok=True)
143
+ print('No cached dependency install found. Attempting to download GitHub backup..')
144
+
145
+ try:
146
+ download_url = "https://github.com/kalomaze/QuickMangioFixes/releases/download/release3/CachedRVC.tar.gz"
147
+ !wget -O $file_path $download_url
148
+ print('Download completed successfully!')
149
+ except Exception as e:
150
+ print('Download failed:', str(e))
151
+
152
+ # Delete the failed download file
153
+ if os.path.exists(file_path):
154
+ os.remove(file_path)
155
+ print('Failed download file deleted. Continuing manual backup..')
156
+
157
+ if Path(file_path).exists():
158
+ if ForceTemporaryStorage:
159
+ print('Finished downloading CachedRVC.tar.gz.')
160
+ else:
161
+ print('CachedRVC.tar.gz found on Google Drive. Proceeding to copy and extract...')
162
+
163
+ # Check if ForceTemporaryStorage is True and skip copying if it is
164
+ if ForceTemporaryStorage:
165
+ pass
166
+ else:
167
+ shutil.copy(file_path, content_file_path)
168
+
169
+ print('Beginning backup copy operation...')
170
+
171
+ with tarfile.open(content_file_path, 'r:gz') as tar:
172
+ for member in tar.getmembers():
173
+ target_path = os.path.join(extract_path, member.name)
174
+ try:
175
+ tar.extract(member, extract_path)
176
+ except Exception as e:
177
+ print('Failed to extract a file (this isn\'t normal)... forcing an update to compensate')
178
+ ForceUpdateDependencies = True
179
+ print(f'Extraction of {content_file_path} to {extract_path} completed.')
180
+
181
+ if ForceUpdateDependencies:
182
+ install_packages()
183
+ ForceUpdateDependencies = False
184
+ else:
185
+ print('CachedRVC.tar.gz not found. Proceeding to create an index of all current files...')
186
+ scan_and_write('/usr/', '/content/usr_files.csv')
187
+
188
+ install_packages()
189
+
190
+ scan_and_write('/usr/', '/content/usr_files_new.csv')
191
+ changed_files = compare_files('/content/usr_files.csv', '/content/usr_files_new.csv')
192
+
193
+ with tarfile.open('/content/CachedRVC.tar.gz', 'w:gz') as new_tar:
194
+ for file in changed_files:
195
+ new_tar.add(file)
196
+ print(f'Added to tar: {file}')
197
+
198
+ os.makedirs('/content/drive/MyDrive/RVC_Cached', exist_ok=True)
199
+ shutil.copy('/content/CachedRVC.tar.gz', '/content/drive/MyDrive/RVC_Cached/CachedRVC.tar.gz')
200
+ print('Updated CachedRVC.tar.gz copied to Google Drive.')
201
+ print('Dependencies fully up to date; future runs should be faster.')
202
+
203
+ #@title Clone Github Repository
204
+ import os
205
+
206
+ # Change the current directory to /content/
207
+ os.chdir('/content/')
208
+
209
+ # Changes defaults of the infer-web.py
210
+ def edit_file(file_path):
211
+ temp_file_path = "/tmp/temp_file.py"
212
+ changes_made = False
213
+ with open(file_path, "r") as file, open(temp_file_path, "w") as temp_file:
214
+ previous_line = ""
215
+ for line in file:
216
+ new_line = line.replace("value=160", "value=128")
217
+ if new_line != line:
218
+ print("Replaced 'value=160' with 'value=128'")
219
+ changes_made = True
220
+ line = new_line
221
+
222
+ new_line = line.replace("crepe hop length: 160", "crepe hop length: 128")
223
+ if new_line != line:
224
+ print("Replaced 'crepe hop length: 160' with 'crepe hop length: 128'")
225
+ changes_made = True
226
+ line = new_line
227
+
228
+ new_line = line.replace("value=0.88", "value=0.75")
229
+ if new_line != line:
230
+ print("Replaced 'value=0.88' with 'value=0.75'")
231
+ changes_made = True
232
+ line = new_line
233
+
234
+ if "label=i18n(\"输入源音量包络替换输出音量包络融合比例,越靠近1越使用输出包络\")" in previous_line and "value=1," in line:
235
+ new_line = line.replace("value=1,", "value=0.25,")
236
+ if new_line != line:
237
+ print("Replaced 'value=1,' with 'value=0.25,' based on the condition")
238
+ changes_made = True
239
+ line = new_line
240
+
241
+ if 'choices=["pm", "harvest", "dio", "crepe", "crepe-tiny", "mangio-crepe", "mangio-crepe-tiny"], # Fork Feature. Add Crepe-Tiny' in previous_line:
242
+ if 'value="pm",' in line:
243
+ new_line = line.replace('value="pm",', 'value="mangio-crepe",')
244
+ if new_line != line:
245
+ print("Replaced 'value=\"pm\",' with 'value=\"mangio-crepe\",' based on the condition")
246
+ changes_made = True
247
+ line = new_line
248
+
249
+ temp_file.write(line)
250
+ previous_line = line
251
+
252
+ # After finished, we replace the original file with the temp one
253
+ import shutil
254
+ shutil.move(temp_file_path, file_path)
255
+
256
+ if changes_made:
257
+ print("Changes made and file saved successfully.")
258
+ else:
259
+ print("No changes were needed.")
260
+
261
+ repo_path = '/content/Retrieval-based-Voice-Conversion-WebUI'
262
+ if not os.path.exists(repo_path):
263
+ # Clone the latest code from the Mangio621/Mangio-RVC-Fork repository
264
+ !git clone https://github.com/Mangio621/Mangio-RVC-Fork.git
265
+ os.chdir('/content/Mangio-RVC-Fork')
266
+ !wget https://github.com/777gt/EasyGUI-RVC-Fork/raw/main/EasierGUI.py
267
+ os.chdir('/content/')
268
+ !mv /content/Mangio-RVC-Fork /content/Retrieval-based-Voice-Conversion-WebUI
269
+ edit_file("/content/Retrieval-based-Voice-Conversion-WebUI/infer-web.py")
270
+ # Make necessary output dirs and example files
271
+ !mkdir -p /content/Retrieval-based-Voice-Conversion-WebUI/audios
272
+ !wget https://github.com/777gt/EVC/raw/main/someguy.mp3 -O /content/Retrieval-based-Voice-Conversion-WebUI/audios/someguy.mp3
273
+ !wget https://github.com/777gt/EVC/raw/main/somegirl.mp3 -O /content/Retrieval-based-Voice-Conversion-WebUI/audios/somegirl.mp3
274
+ # Import custom translation
275
+ !rm -rf /content/Retrieval-based-Voice-Conversion-WebUI/il8n/en_US.json
276
+ !wget https://github.com/kalomaze/QuickMangioFixes/releases/download/release3/en_US.json -P /content/Retrieval-based-Voice-Conversion-WebUI/il8n/
277
+ else:
278
+ print(f"The repository already exists at {repo_path}. Skipping cloning.")
279
+
280
+ # Download the credentials file for RVC archive sheet
281
+ !mkdir -p /content/Retrieval-based-Voice-Conversion-WebUI/stats/
282
+ !wget -q https://cdn.discordapp.com/attachments/945486970883285045/1114717554481569802/peppy-generator-388800-07722f17a188.json -O /content/Retrieval-based-Voice-Conversion-WebUI/stats/peppy-generator-388800-07722f17a188.json
283
+
284
+ # Forcefully delete any existing torchcrepe dependency from an earlier run
285
+ !rm -rf /Retrieval-based-Voice-Conversion-WebUI/torchcrepe
286
+
287
+ # Download the torchcrepe folder from the maxrmorrison/torchcrepe repository
288
+ !git clone https://github.com/maxrmorrison/torchcrepe.git
289
+ !mv torchcrepe/torchcrepe Retrieval-based-Voice-Conversion-WebUI/
290
+ !rm -rf torchcrepe # Delete the torchcrepe repository folder
291
+
292
+ # Change the current directory to /content/Retrieval-based-Voice-Conversion-WebUI
293
+ os.chdir('/content/Retrieval-based-Voice-Conversion-WebUI')
294
+ !mkdir -p pretrained uvr5_weights
295
+
296
+ #@title Download the Base Model
297
+ #!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained/D32k.pth -d /content/Retrieval-based-Voice-Conversion-WebUI/pretrained -o D32k.pth
298
+ #!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained/D40k.pth -d /content/Retrieval-based-Voice-Conversion-WebUI/pretrained -o D40k.pth
299
+ #!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained/D48k.pth -d /content/Retrieval-based-Voice-Conversion-WebUI/pretrained -o D48k.pth
300
+ #!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained/G32k.pth -d /content/Retrieval-based-Voice-Conversion-WebUI/pretrained -o G32k.pth
301
+ #!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained/G40k.pth -d /content/Retrieval-based-Voice-Conversion-WebUI/pretrained -o G40k.pth
302
+ #!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained/G48k.pth -d /content/Retrieval-based-Voice-Conversion-WebUI/pretrained -o G48k.pth
303
+ #!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained/f0D32k.pth -d /content/Retrieval-based-Voice-Conversion-WebUI/pretrained -o f0D32k.pth
304
+ #!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained/f0D40k.pth -d /content/Retrieval-based-Voice-Conversion-WebUI/pretrained -o f0D40k.pth
305
+ #!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained/f0D48k.pth -d /content/Retrieval-based-Voice-Conversion-WebUI/pretrained -o f0D48k.pth
306
+ #!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained/f0G32k.pth -d /content/Retrieval-based-Voice-Conversion-WebUI/pretrained -o f0G32k.pth
307
+ #!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained/f0G40k.pth -d /content/Retrieval-based-Voice-Conversion-WebUI/pretrained -o f0G40k.pth
308
+ #!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained/f0G48k.pth -d /content/Retrieval-based-Voice-Conversion-WebUI/pretrained -o f0G48k.pth
309
+
310
+ #!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/uvr5_weights/HP2-人声vocals+非人声instrumentals.pth -d /content/Retrieval-based-Voice-Conversion-WebUI/uvr5_weights -o HP2-人声vocals+非人声instrumentals.pth
311
+ #!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/uvr5_weights/HP5-主旋律人声vocals+其他instrumentals.pth -d /content/Retrieval-based-Voice-Conversion-WebUI/uvr5_weights -o HP5-主旋律人声vocals+其他instrumentals.pth
312
+
313
+ !aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/hubert_base.pt -d /content/Retrieval-based-Voice-Conversion-WebUI -o hubert_base.pt
314
+
315
+ #@markdown This will also create an RVC and dataset folders in your drive if they don't already exist.
316
+ #from google.colab import drive
317
+ #drive.mount('/content/drive', force_remount=True)
318
+
319
+ """##Models List:
320
+ ###You can download from **any** link you have as long as it's RVC. (Mega, Drive, etc.)
321
+
322
+ Biggest organized voice collection at #voice-models in https://discord.gg/aihub
323
+
324
+ Model archive spreadsheet, sorted by popularity: https://docs.google.com/spreadsheets/d/1tAUaQrEHYgRsm1Lvrnj14HFHDwJWl0Bd9x0QePewNco/
325
+
326
+ Backup model archive (outdated): https://huggingface.co/QuickWick/Music-AI-Voices/tree/main
327
+ """
328
+
329
+ #@markdown #Step 2. Download The Model
330
+ #@markdown Link the URL path to the model (Mega, Drive, etc.) and start the code
331
+
332
+ from mega import Mega
333
+ import os
334
+ import shutil
335
+ from urllib.parse import urlparse, parse_qs
336
+ import urllib.parse
337
+ from google.oauth2.service_account import Credentials
338
+ import gspread
339
+ import pandas as pd
340
+ from tqdm import tqdm
341
+ from bs4 import BeautifulSoup
342
+ import requests
343
+ import hashlib
344
+
345
+ def calculate_md5(file_path):
346
+ hash_md5 = hashlib.md5()
347
+ with open(file_path, "rb") as f:
348
+ for chunk in iter(lambda: f.read(4096), b""):
349
+ hash_md5.update(chunk)
350
+ return hash_md5.hexdigest()
351
+
352
+ # Initialize gspread
353
+ scope = ['https://www.googleapis.com/auth/spreadsheets',
354
+ 'https://www.googleapis.com/auth/drive.file',
355
+ 'https://www.googleapis.com/auth/drive']
356
+
357
+ config_path = '/content/Retrieval-based-Voice-Conversion-WebUI/stats/peppy-generator-388800-07722f17a188.json'
358
+
359
+ if os.path.exists(config_path):
360
+ # File exists, proceed with creation of creds and client
361
+ creds = Credentials.from_service_account_file(config_path, scopes=scope)
362
+ client = gspread.authorize(creds)
363
+ else:
364
+ # File does not exist, print message and skip creation of creds and client
365
+ print("Sheet credential file missing.")
366
+
367
+ # Open the Google Sheet (this will write any URLs so I can easily track popular models)
368
+ book = client.open("RVC Model Archive Sheet")
369
+ sheet = book.get_worksheet(3) # get the fourth sheet
370
+
371
+ def update_sheet(url, filename, filesize, md5_hash, index_version):
372
+ data = sheet.get_all_records()
373
+ df = pd.DataFrame(data)
374
+
375
+ if md5_hash in df['MD5 Hash'].values:
376
+ idx = df[df['MD5 Hash'] == md5_hash].index[0]
377
+
378
+ # Update download count
379
+ df.loc[idx, 'Download Counter'] = int(df.loc[idx, 'Download Counter']) + 1
380
+ sheet.update_cell(idx+2, df.columns.get_loc('Download Counter') + 1, int(df.loc[idx, 'Download Counter']))
381
+
382
+ # Find the next available Alt URL field
383
+ alt_url_cols = [col for col in df.columns if 'Alt URL' in col]
384
+ alt_url_values = [df.loc[idx, col_name] for col_name in alt_url_cols]
385
+
386
+ # Check if url is the same as the main URL or any of the Alt URLs
387
+ if url not in alt_url_values and url != df.loc[idx, 'URL']:
388
+ for col_name in alt_url_cols:
389
+ if df.loc[idx, col_name] == '':
390
+ df.loc[idx, col_name] = url
391
+ sheet.update_cell(idx+2, df.columns.get_loc(col_name) + 1, url)
392
+ break
393
+ else:
394
+ # Prepare a new row as a dictionary
395
+ new_row_dict = {'URL': url, 'Download Counter': 1, 'Filename': filename,
396
+ 'Filesize (.pth)': filesize, 'MD5 Hash': md5_hash, 'RVC Version': index_version}
397
+
398
+ alt_url_cols = [col for col in df.columns if 'Alt URL' in col]
399
+ for col in alt_url_cols:
400
+ new_row_dict[col] = '' # Leave the Alt URL fields empty
401
+
402
+ # Convert fields other than 'Download Counter' and 'Filesize (.pth)' to string
403
+ new_row_dict = {key: str(value) if key not in ['Download Counter', 'Filesize (.pth)'] else value for key, value in new_row_dict.items()}
404
+
405
+ # Append new row to sheet in the same order as existing columns
406
+ ordered_row = [new_row_dict.get(col, '') for col in df.columns]
407
+ sheet.append_row(ordered_row, value_input_option='RAW')
408
+
409
+ condition1 = False
410
+ condition2 = False
411
+ already_downloaded = False
412
+
413
+ # condition1 here is to check if the .index was imported. 2 is for if the .pth was.
414
+
415
+ !rm -rf /content/unzips/
416
+ !rm -rf /content/zips/
417
+ !mkdir /content/unzips
418
+ !mkdir /content/zips
419
+
420
+ def sanitize_directory(directory):
421
+ for filename in os.listdir(directory):
422
+ file_path = os.path.join(directory, filename)
423
+ if os.path.isfile(file_path):
424
+ if filename == ".DS_Store" or filename.startswith("._"):
425
+ os.remove(file_path)
426
+ elif os.path.isdir(file_path):
427
+ sanitize_directory(file_path)
428
+
429
+ url = 'https://huggingface.co/Flyleaf/EltonJohnModern/resolve/main/2019Elton.zip' #@param {type:"string"}
430
+ model_zip = urlparse(url).path.split('/')[-2] + '.zip'
431
+ model_zip_path = '/content/zips/' + model_zip
432
+
433
+ #@markdown This option should only be ticked if you don't want your model listed on the public tracker.
434
+ private_model = False #@param{type:"boolean"}
435
+
436
+ if url != '':
437
+ MODEL = "" # Initialize MODEL variable
438
+ !mkdir -p /content/Retrieval-based-Voice-Conversion-WebUI/logs/$MODEL
439
+ !mkdir -p /content/zips/
440
+ !mkdir -p /content/Retrieval-based-Voice-Conversion-WebUI/weights/ # Create the 'weights' directory
441
+
442
+ if "drive.google.com" in url:
443
+ !gdown $url --fuzzy -O "$model_zip_path"
444
+ elif "/blob/" in url:
445
+ url = url.replace("blob", "resolve")
446
+ print("Resolved URL:", url) # Print the resolved URL
447
+ !wget "$url" -O "$model_zip_path"
448
+ elif "mega.nz" in url:
449
+ m = Mega()
450
+ print("Starting download from MEGA....")
451
+ m.download_url(url, '/content/zips')
452
+ elif "/tree/main" in url:
453
+ response = requests.get(url)
454
+ soup = BeautifulSoup(response.content, 'html.parser')
455
+ temp_url = ''
456
+ for link in soup.find_all('a', href=True):
457
+ if link['href'].endswith('.zip'):
458
+ temp_url = link['href']
459
+ break
460
+ if temp_url:
461
+ url = temp_url
462
+ print("Updated URL:", url) # Print the updated URL
463
+ url = url.replace("blob", "resolve")
464
+ print("Resolved URL:", url) # Print the resolved URL
465
+
466
+ if "huggingface.co" not in url:
467
+ url = "https://huggingface.co" + url
468
+
469
+ !wget "$url" -O "$model_zip_path"
470
+ else:
471
+ print("No .zip file found on the page.")
472
+ # Handle the case when no .zip file is found
473
+ else:
474
+ !wget "$url" -O "$model_zip_path"
475
+
476
+ for filename in os.listdir("/content/zips"):
477
+ if filename.endswith(".zip"):
478
+ zip_file = os.path.join("/content/zips", filename)
479
+ shutil.unpack_archive(zip_file, "/content/unzips", 'zip')
480
+
481
+ sanitize_directory("/content/unzips")
482
+
483
+ def find_pth_file(folder):
484
+ for root, dirs, files in os.walk(folder):
485
+ for file in files:
486
+ if file.endswith(".pth"):
487
+ file_name = os.path.splitext(file)[0]
488
+ if file_name.startswith("G_") or file_name.startswith("P_"):
489
+ config_file = os.path.join(root, "config.json")
490
+ if os.path.isfile(config_file):
491
+ print("Outdated .pth detected! This is not compatible with the RVC method. Find the RVC equivalent model!")
492
+ continue # Continue searching for a valid file
493
+ file_path = os.path.join(root, file)
494
+ if os.path.getsize(file_path) > 100 * 1024 * 1024: # Check file size in bytes (100MB)
495
+ print("Skipping unusable training file:", file)
496
+ continue # Continue searching for a valid file
497
+ return file_name
498
+ return None
499
+
500
+ MODEL = find_pth_file("/content/unzips")
501
+ if MODEL is not None:
502
+ print("Found .pth file:", MODEL + ".pth")
503
+ else:
504
+ print("Error: Could not find a valid .pth file within the extracted zip.")
505
+ print("If there's an error above this talking about 'Access denied', try one of the Alt URLs in the Google Sheets for this model.")
506
+ MODEL = ""
507
+ global condition3
508
+ condition3 = True
509
+
510
+ index_path = ""
511
+
512
+ def find_version_number(index_path):
513
+ if condition2 and not condition1:
514
+ if file_size >= 55180000:
515
+ return 'RVC v2'
516
+ else:
517
+ return 'RVC v1'
518
+
519
+ filename = os.path.basename(index_path)
520
+
521
+ if filename.endswith("_v2.index"):
522
+ return 'RVC v2'
523
+ elif filename.endswith("_v1.index"):
524
+ return 'RVC v1'
525
+ else:
526
+ if file_size >= 55180000:
527
+ return 'RVC v2'
528
+ else:
529
+ return 'RVC v1'
530
+
531
+ if MODEL != "":
532
+ # Move model into logs folder
533
+ for root, dirs, files in os.walk('/content/unzips'):
534
+ for file in files:
535
+ file_path = os.path.join(root, file)
536
+ if file.endswith(".index"):
537
+ print("Found index file:", file)
538
+ condition1 = True
539
+ logs_folder = os.path.join('/content/Retrieval-based-Voice-Conversion-WebUI/logs', MODEL)
540
+ os.makedirs(logs_folder, exist_ok=True) # Create the logs folder if it doesn't exist
541
+
542
+ # Delete identical .index file if it exists
543
+ if file.endswith(".index"):
544
+ identical_index_path = os.path.join(logs_folder, file)
545
+ if os.path.exists(identical_index_path):
546
+ os.remove(identical_index_path)
547
+
548
+ shutil.move(file_path, logs_folder)
549
+ index_path = os.path.join(logs_folder, file) # Set index_path variable
550
+
551
+ elif "G_" not in file and "D_" not in file and file.endswith(".pth"):
552
+ destination_path = f'/content/Retrieval-based-Voice-Conversion-WebUI/weights/{MODEL}.pth'
553
+ if os.path.exists(destination_path):
554
+ print("You already downloaded this model. Re-importing anyways..")
555
+ already_downloaded = True
556
+ shutil.move(file_path, destination_path)
557
+ condition2 = True
558
+ if already_downloaded is False and os.path.exists(config_path):
559
+ file_size = os.path.getsize(destination_path) # Get file size
560
+ md5_hash = calculate_md5(destination_path) # Calculate md5 hash
561
+ index_version = find_version_number(index_path) # Get the index version
562
+
563
+ if condition1 is False:
564
+ logs_folder = os.path.join('/content/Retrieval-based-Voice-Conversion-WebUI/logs', MODEL)
565
+ os.makedirs(logs_folder, exist_ok=True)
566
+ # this is here so it doesnt crash if the model is missing an index for some reason
567
+
568
+ if condition2 and not condition1:
569
+ print("Model partially imported! No .index file was found in the model download. The author may have forgotten to add the index file.")
570
+ if already_downloaded is False and os.path.exists(config_path) and not private_model:
571
+ update_sheet(url, MODEL, file_size, md5_hash, index_version)
572
+
573
+ elif condition1 and condition2:
574
+ print("Model successfully imported!")
575
+ if already_downloaded is False and os.path.exists(config_path) and not private_model:
576
+ update_sheet(url, MODEL, file_size, md5_hash, index_version)
577
+
578
+ elif condition3:
579
+ pass # Do nothing when condition3 is true
580
+ else:
581
+ print("URL cannot be left empty. If you don't want to download a model now, just skip this step.")
582
+
583
+ !rm -r /content/unzips/
584
+ !rm -r /content/zips/
585
+
586
+ """#Step 3. Start the GUI, then open the public URL. It's gonna look like this:
587
+ ![alt text](https://i.imgur.com/ZjuyG29.png)
588
+ """
589
+
590
+ # Commented out IPython magic to ensure Python compatibility.
591
+ # %cd /content/Retrieval-based-Voice-Conversion-WebUI
592
+
593
+ #@markdown Keep this option enabled to use the simplified, easy interface.
594
+ #@markdown <br>Otherwise, it will use the advanced one that you see in the YouTube guide.
595
+ easy_gui = True #@param{type:"boolean"}
596
+
597
+ if easy_gui:
598
+ !python3 EasierGUI.py --colab --pycmd python3
599
+ else:
600
+ !python3 infer-web.py --colab --pycmd python3
601
+
602
+ """* For the original RVC GUI, visit: https://github.com/RVC-Project/Retrieval-based-Voice-Conversion-WebUI
603
+ * If you need to train a model visit: https://colab.research.google.com/drive/1TU-kkQWVf-PLO_hSa2QCMZS1XF5xVHqs?usp=sharing
604
+
605
+ #Other
606
+ """
607
+
608
+ #@markdown #Upload files (or do it through colab panel instead)
609
+ #@markdown Run this cell to upload your vocal files that you want to use, (or zip files containing audio) to your Colab. <br>
610
+ #@markdown Alternatively, you can upload from the colab files panel as seen in the video, but this should be more convenient. This method may not work on iOS.
611
+ from google.colab import files
612
+ from IPython.display import display, Javascript
613
+ import os
614
+ import shutil
615
+ import zipfile
616
+ import ipywidgets as widgets
617
+
618
+ # Create the target directory if it doesn't exist
619
+ target_dir = '/content/Retrieval-based-Voice-Conversion-WebUI/audios/'
620
+ if not os.path.exists(target_dir):
621
+ os.makedirs(target_dir)
622
+
623
+ uploaded = files.upload()
624
+
625
+ for fn in uploaded.keys():
626
+ # Check if the uploaded file is a zip file
627
+ if fn.endswith('.zip'):
628
+ # Write the uploaded zip file to the target directory
629
+ zip_path = os.path.join(target_dir, fn)
630
+ with open(zip_path, 'wb') as f:
631
+ f.write(uploaded[fn])
632
+
633
+ unzip_dir = os.path.join(target_dir, fn[:-4]) # Remove the .zip extension from the folder name
634
+
635
+ # Extract the zip file
636
+ with zipfile.ZipFile(zip_path, 'r') as zip_ref:
637
+ zip_ref.extractall(unzip_dir)
638
+
639
+ # Delete the zip file
640
+ if os.path.exists(zip_path):
641
+ os.remove(zip_path)
642
+
643
+ print('Zip file "{name}" extracted and removed. Files are in: {folder}'.format(name=fn, folder=unzip_dir))
644
+
645
+ # Display copy path buttons for each extracted file
646
+ for extracted_file in os.listdir(unzip_dir):
647
+ extracted_file_path = os.path.join(unzip_dir, extracted_file)
648
+ extracted_file_length = os.path.getsize(extracted_file_path)
649
+
650
+ extracted_file_label = widgets.HTML(
651
+ value='Extracted file "{name}" with length {length} bytes'.format(name=extracted_file, length=extracted_file_length)
652
+ )
653
+ display(extracted_file_label)
654
+
655
+ extracted_file_path_text = widgets.HTML(
656
+ value='File saved to: <a href="{}" target="_blank">{}</a>'.format(extracted_file_path, extracted_file_path)
657
+ )
658
+
659
+ extracted_copy_button = widgets.Button(description='Copy')
660
+ extracted_copy_button_file_path = extracted_file_path # Make a local copy of the file path
661
+
662
+ def copy_to_clipboard(b):
663
+ js_code = '''
664
+ const el = document.createElement('textarea');
665
+ el.value = "{path}";
666
+ el.setAttribute('readonly', '');
667
+ el.style.position = 'absolute';
668
+ el.style.left = '-9999px';
669
+ document.body.appendChild(el);
670
+ el.select();
671
+ document.execCommand('copy');
672
+ document.body.removeChild(el);
673
+ '''
674
+ display(Javascript(js_code.format(path=extracted_copy_button_file_path)))
675
+
676
+ extracted_copy_button.on_click(copy_to_clipboard)
677
+ display(widgets.HBox([extracted_file_path_text, extracted_copy_button]))
678
+
679
+ continue
680
+
681
+ # For non-zip files
682
+ # Save the file to the target directory
683
+ file_path = os.path.join(target_dir, fn)
684
+ with open(file_path, 'wb') as f:
685
+ f.write(uploaded[fn])
686
+
687
+ file_length = len(uploaded[fn])
688
+ file_label = widgets.HTML(
689
+ value='User uploaded file "{name}" with length {length} bytes'.format(name=fn, length=file_length)
690
+ )
691
+ display(file_label)
692
+
693
+ # Check if the uploaded file is a .pth or .index file
694
+ if fn.endswith('.pth') or fn.endswith('.index'):
695
+ warning_text = widgets.HTML(
696
+ value='<b style="color: red;">Warning:</b> You are uploading a model file in the wrong place. Please ensure it is uploaded to the correct location.'
697
+ )
698
+ display(warning_text)
699
+
700
+ # Create a clickable path with copy button
701
+ file_path_text = widgets.HTML(
702
+ value='File saved to: <a href="{}" target="_blank">{}</a>'.format(file_path, file_path)
703
+ )
704
+
705
+ copy_button = widgets.Button(description='Copy')
706
+ copy_button_file_path = file_path # Make a local copy of the file path
707
+
708
+ def copy_to_clipboard(b):
709
+ js_code = '''
710
+ const el = document.createElement('textarea');
711
+ el.value = "{path}";
712
+ el.setAttribute('readonly', '');
713
+ el.style.position = 'absolute';
714
+ el.style.left = '-9999px';
715
+ document.body.appendChild(el);
716
+ el.select();
717
+ document.execCommand('copy');
718
+ document.body.removeChild(el);
719
+ '''
720
+ display(Javascript(js_code.format(path=copy_button_file_path)))
721
+
722
+ copy_button.on_click(copy_to_clipboard)
723
+ display(widgets.HBox([file_path_text, copy_button]))
724
+
725
+ # Remove the original uploaded files from /content/
726
+ for fn in uploaded.keys():
727
+ if os.path.exists(os.path.join("/content/", fn)):
728
+ os.remove(os.path.join("/content/", fn))
729
+
730
+ #@markdown ##Click this to import a ZIP of AUDIO FILES.
731
+ #@markdown Link the URL path to the audio files (Mega, Drive, etc.) and start the code
732
+ url = 'INSERTURLHERE' #@param {type:"string"}
733
+
734
+ import subprocess
735
+ import os
736
+ import shutil
737
+ from urllib.parse import urlparse, parse_qs
738
+ from google.colab import output
739
+ from google.colab import drive
740
+
741
+ mount_to_drive = True
742
+ mount_path = '/content/drive/MyDrive'
743
+
744
+ def mount(gdrive=False):
745
+ if gdrive:
746
+ if not os.path.exists("/content/drive/MyDrive"):
747
+ try:
748
+ drive.mount("/content/drive", force_remount=True)
749
+ except:
750
+ drive._mount("/content/drive", force_remount=True)
751
+ else:
752
+ pass
753
+
754
+ mount(mount_to_drive)
755
+
756
+ def check_package_installed(package_name):
757
+ command = f"pip show {package_name}"
758
+ result = subprocess.run(command.split(), stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
759
+ return result.returncode == 0
760
+
761
+ def install_package(package_name):
762
+ command = f"pip install {package_name} --quiet"
763
+ subprocess.run(command.split(), stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
764
+
765
+ if not check_package_installed("mega.py"):
766
+ install_package("mega.py")
767
+
768
+ from mega import Mega
769
+ import os
770
+ import shutil
771
+ from urllib.parse import urlparse, parse_qs
772
+ import urllib.parse
773
+
774
+ !rm -rf /content/unzips/
775
+ !rm -rf /content/zips/
776
+ !mkdir /content/unzips
777
+ !mkdir /content/zips
778
+
779
+ def sanitize_directory(directory):
780
+ for filename in os.listdir(directory):
781
+ file_path = os.path.join(directory, filename)
782
+ if os.path.isfile(file_path):
783
+ if filename == ".DS_Store" or filename.startswith("._"):
784
+ os.remove(file_path)
785
+ elif os.path.isdir(file_path):
786
+ sanitize_directory(file_path)
787
+
788
+ audio_zip = urlparse(url).path.split('/')[-2] + '.zip'
789
+ audio_zip_path = '/content/zips/' + audio_zip
790
+
791
+ if url != '':
792
+ if "drive.google.com" in url:
793
+ !gdown $url --fuzzy -O "$audio_zip_path"
794
+ elif "mega.nz" in url:
795
+ m = Mega()
796
+ m.download_url(url, '/content/zips')
797
+ else:
798
+ !wget "$url" -O "$audio_zip_path"
799
+
800
+ for filename in os.listdir("/content/zips"):
801
+ if filename.endswith(".zip"):
802
+ zip_file = os.path.join("/content/zips", filename)
803
+ shutil.unpack_archive(zip_file, "/content/unzips", 'zip')
804
+
805
+ sanitize_directory("/content/unzips")
806
+
807
+ !mkdir -p /content/Retrieval-based-Voice-Conversion-WebUI/audios
808
+ for filename in os.listdir("/content/unzips"):
809
+ if filename.endswith((".wav", ".mp3", ".m4a", ".flac")):
810
+ audio_file = os.path.join("/content/unzips", filename)
811
+ destination_file = os.path.join("/content/Retrieval-based-Voice-Conversion-WebUI/audios", filename)
812
+ shutil.copy2(audio_file, destination_file)
813
+ if os.path.exists(destination_file):
814
+ print(f"Copy successful: {destination_file}")
815
+ else:
816
+ print(f"Copy failed: {audio_file}")
817
+
818
+ !rm -r /content/unzips/
819
+ !rm -r /content/zips/
820
+
821
+ """#**Consider subscribing to my Patreon!**
822
+
823
+ Benefits include:
824
+ - Full on tech support for AI covers in general
825
+ - This includes audio mixing and how to train your own models, with any tier.
826
+ - Tech support priority is given to the latter tier.
827
+
828
+ https://patreon.com/kalomaze
829
+
830
+ Your support would be greatly appreciated! On top of maintaining this colab, I also write and maintain the Google Docs guides, and plan to create a video tutorial for training voices in the future.
831
+
832
+ ##Credits
833
+ **Rejekts** - Original colab author. Made easy GUI for RVC<br>
834
+ **RVC-Project dev team** - Original RVC software developers <br>
835
+ **Mangio621** - Developer of the RVC fork that added crepe support, helped me get it up and running + taught me how to use TensorBoard<br>
836
+ **Kalomaze** - Creator of this colab, added autobackup + loader feature, fixed downloader to work with zips that had parentheses + streamlined downloader, added TensorBoard picture, made the doc thats linked, general God amongst men (def not biased 100%)
837
+
838
+ #UVR Isolation Stuff
839
+
840
+ ##UVR Colab Method (MDX-Net)
841
+ The following allows you to use the following models recommended for isolating acapellas for your covers:
842
+ - Kim vocal 1
843
+ - Kim vocal 2 (higher quality, but may have more background vocals that need to be isolated with the Karaoke model)
844
+
845
+ Or for the best instrumental results you can later do:
846
+ - Inst HQ 1
847
+
848
+ Reverb should be removed with Reverb HQ. Other remaining echo effects can be dealt with using the VR Architecture UVR colab linked below using the De-Echo models. (or done with local UVR)
849
+ """
850
+
851
+ initialised = True
852
+ from time import sleep
853
+ from google.colab import output
854
+ from google.colab import drive
855
+
856
+ import sys
857
+ import os
858
+ import shutil
859
+ import psutil
860
+ import glob
861
+
862
+ mount_to_drive = True
863
+ mount_path = '/content/drive/MyDrive'
864
+
865
+ ai = 'https://github.com/kae0-0/Colab-for-MDX_B'
866
+ ai_version = 'https://github.com/kae0-0/Colab-for-MDX_B/raw/main/v'
867
+ onnx_list = 'https://raw.githubusercontent.com/kae0-0/Colab-for-MDX_B/main/onnx_list'
868
+ #@title Initialize UVR MDX-Net Models
869
+ #@markdown The 'ForceUpdate' option will update the models by fully reinstalling.
870
+ ForceUpdate = False #@param {type:"boolean"}
871
+ class h:
872
+ def __enter__(self):
873
+ self._original_stdout = sys.stdout
874
+ sys.stdout = open(os.devnull, 'w')
875
+ def __exit__(self, exc_type, exc_val, exc_tb):
876
+ sys.stdout.close()
877
+ sys.stdout = self._original_stdout
878
+ def get_size(bytes, suffix='B'): # read ram
879
+ global svmem
880
+ factor = 1024
881
+ for unit in ["", "K", "M", "G", "T", "P"]:
882
+ if bytes < factor:
883
+ return f'{bytes:.2f}{unit}{suffix}'
884
+ bytes /= factor
885
+ svmem = psutil.virtual_memory()
886
+ def console(t):
887
+ get_ipython().system(t)
888
+ def LinUzip(file): # unzip call linux, force replace
889
+ console(f'unzip -o {file}')
890
+ #-------------------------------------------------------
891
+ def getONNX():
892
+ console(f'wget {onnx_list} -O onnx_list')
893
+ _onnx = open("onnx_list", "r")
894
+ _onnx = _onnx.readlines()
895
+ os.remove('onnx_list')
896
+ for model in _onnx:
897
+ _model = sanitize_filename(os.path.basename(model))
898
+ console(f'wget {model}')
899
+ LinUzip(_model)
900
+ os.remove(_model)
901
+
902
+ def getDemucs(_path):
903
+ #https://dl.fbaipublicfiles.com/demucs/v3.0/demucs_extra-3646af93.th
904
+ root = "https://dl.fbaipublicfiles.com/demucs/v3.0/"
905
+ model = {
906
+ 'demucs_extra': '3646af93'
907
+ }
908
+ for models in zip(model.keys(),model.values()):
909
+ console(f'wget {root+models[0]+"-"+models[1]}.th -O {models[0]}.th')
910
+ for _ in glob.glob('*.th'):
911
+ if os.path.isfile(os.path.join(os.getcwd(),_path,_)):
912
+ os.remove(os.path.join(os.getcwd(),_path,_))
913
+ shutil.move(_,_path)
914
+
915
+ def mount(gdrive=False):
916
+ if gdrive:
917
+ if not os.path.exists("/content/drive/MyDrive"):
918
+ try:
919
+ drive.mount("/content/drive", force_remount=True)
920
+ except:
921
+ drive._mount("/content/drive", force_remount=True)
922
+ else:
923
+ pass
924
+
925
+ mount(mount_to_drive)
926
+
927
+ def toPath(path='local'):
928
+ if path == 'local':
929
+ os.chdir('/content')
930
+ elif path == 'gdrive':
931
+ os.chdir(mount_path)
932
+
933
+ def update():
934
+ with h():
935
+ console(f'wget {ai_version} -O nver')
936
+ f = open('nver', 'r')
937
+ nver = f.read()
938
+ f = open('v', 'r')
939
+ cver = f.read()
940
+ if nver != cver or ForceUpdate:
941
+ print('New update found! {}'.format(nver))
942
+ os.chdir('../')
943
+ print('Updating ai...',end=' ')
944
+ with h():
945
+ console(f'git clone {ai} temp_MDX_Colab')
946
+ console('cp -a temp_MDX_Colab/* MDX_Colab/')
947
+ console('rm -rf temp_MDX_Colab')
948
+ print('done')
949
+ os.chdir('MDX_Colab')
950
+ print('Refreshing models...', end=' ')
951
+ with h():
952
+ #getDemucs('model/')
953
+ getONNX()
954
+ print('done')
955
+ output.clear()
956
+ os.remove('v')
957
+ os.rename("nver",'v')
958
+ #os.chdir(f'{os.path.join(mount_path,"MDX_Colab")}')
959
+ else:
960
+ os.remove('nver')
961
+ print('Using latest version.')
962
+
963
+ def past_installation():
964
+ return os.path.exists('MDX_Colab')
965
+
966
+ def LoadMDX():
967
+ console(f'git clone {ai} MDX_Colab')
968
+
969
+ #-------------------------------------------------------
970
+ # install requirements
971
+ print('Installing dependencies will take 45 seconds...',end=' ')
972
+
973
+ gpu_info = !nvidia-smi
974
+ gpu_info = '\n'.join(gpu_info)
975
+ if gpu_info.find('failed') >= 0:
976
+ svmem = psutil.virtual_memory()
977
+ gpu_runtime = False
978
+ with h():
979
+ console('pip3 install onnxruntime==1.14.1')
980
+ else:
981
+ gpu_runtime = True
982
+ with h():
983
+ console('pip3 install onnxruntime-gpu==1.14.1')
984
+ with h():
985
+ deps = [
986
+ 'pathvalidate',
987
+ 'youtube-dl',
988
+ 'django'
989
+ ]
990
+ for dep in deps:
991
+ console('pip3 install {}'.format(dep))
992
+ # import modules
993
+ #console('pip3 install torch==1.13.1')
994
+ console('pip3 install soundfile==0.12.1')
995
+ console('pip3 install librosa==0.9.1')
996
+ from pathvalidate import sanitize_filename
997
+ print('done')
998
+ if not gpu_runtime:
999
+ print(f'GPU runtime is disabled. You have {get_size(svmem.total)} RAM.\nProcessing will be incredibly slow. 😈')
1000
+ elif gpu_info.find('Tesla T4') >= 0:
1001
+ print('You got a Tesla T4 GPU. (speeds are around 10-25 it/s)')
1002
+ elif gpu_info.find('Tesla P4') >= 0:
1003
+ print('You got a Tesla P4 GPU. (speeds are around 8-22 it/s)')
1004
+ elif gpu_info.find('Tesla K80') >= 0:
1005
+ print('You got a Tesla K80 GPU. (This is the common gpu, speeds are around 2-10 it/s)')
1006
+ elif gpu_info.find('Tesla P100') >= 0:
1007
+ print('You got a Tesla P100 GPU. (This is the Second to the fastest gpu, speeds are around 15-42 it/s)')
1008
+ else:
1009
+ if gpu_runtime:
1010
+ print('You got an unknown GPU. Please report the GPU you got!')
1011
+ !nvidia-smi
1012
+
1013
+ #console('pip3 install demucs')
1014
+ #-------------------------------------------------------
1015
+ # Scripting
1016
+ mount(mount_to_drive)
1017
+ toPath('gdrive' if mount_to_drive else 'local')
1018
+ #check for MDX existence
1019
+ if not past_installation():
1020
+ print('First time installation will take around 3-6 minutes.\nThis requires around 2-3 GB Free Gdrive space.\nPlease try not to interup installation process!!')
1021
+ print('Downloading AI...',end=' ')
1022
+ with h():
1023
+ LoadMDX()
1024
+ os.chdir('MDX_Colab')
1025
+ print('done')
1026
+
1027
+ print('Downloading models...',end=' ')
1028
+ with h():
1029
+ #getDemucs('model/')
1030
+ getONNX()
1031
+ if os.path.isfile('onnx_list'):
1032
+ os.remove('onnx_list')
1033
+ print('done')
1034
+
1035
+ else:
1036
+ os.chdir('MDX_Colab')
1037
+ update()
1038
+
1039
+ ################
1040
+ #outro
1041
+ print('Success!')
1042
+
1043
+ #@markdown ##Click this to import a ZIP of AUDIO FILES (for isolation.)
1044
+ #@markdown Or you can use the cell below this to upload files directly instead (which is more convenient) <br> <br>
1045
+ #@markdown Link the URL path to the audio files (Mega, Drive, etc.) and start the code
1046
+ url = 'INSERTURLHERE' #@param {type:"string"}
1047
+
1048
+ import subprocess
1049
+ import os
1050
+ import shutil
1051
+ from urllib.parse import urlparse, parse_qs
1052
+ from google.colab import output
1053
+ from google.colab import drive
1054
+
1055
+
1056
+ mount_to_drive = True
1057
+ mount_path = '/content/drive/MyDrive'
1058
+
1059
+ def mount(gdrive=False):
1060
+ if gdrive:
1061
+ if not os.path.exists("/content/drive/MyDrive"):
1062
+ try:
1063
+ drive.mount("/content/drive", force_remount=True)
1064
+ except:
1065
+ drive._mount("/content/drive", force_remount=True)
1066
+ else:
1067
+ pass
1068
+
1069
+ mount(mount_to_drive)
1070
+
1071
+ def check_package_installed(package_name):
1072
+ command = f"pip show {package_name}"
1073
+ result = subprocess.run(command.split(), stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
1074
+ return result.returncode == 0
1075
+
1076
+ def install_package(package_name):
1077
+ command = f"pip install {package_name} --quiet"
1078
+ subprocess.run(command.split(), stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
1079
+
1080
+ if not check_package_installed("mega.py"):
1081
+ install_package("mega.py")
1082
+
1083
+ from mega import Mega
1084
+ import os
1085
+ import shutil
1086
+ from urllib.parse import urlparse, parse_qs
1087
+ import urllib.parse
1088
+
1089
+ !rm -rf /content/unzips/
1090
+ !rm -rf /content/zips/
1091
+ !mkdir /content/unzips
1092
+ !mkdir /content/zips
1093
+
1094
+ def sanitize_directory(directory):
1095
+ for filename in os.listdir(directory):
1096
+ file_path = os.path.join(directory, filename)
1097
+ if os.path.isfile(file_path):
1098
+ if filename == ".DS_Store" or filename.startswith("._"):
1099
+ os.remove(file_path)
1100
+ elif os.path.isdir(file_path):
1101
+ sanitize_directory(file_path)
1102
+
1103
+ audio_zip = urlparse(url).path.split('/')[-2] + '.zip'
1104
+ audio_zip_path = '/content/zips/' + audio_zip
1105
+
1106
+ if url != '':
1107
+ if "drive.google.com" in url:
1108
+ !gdown $url --fuzzy -O "$audio_zip_path"
1109
+ elif "mega.nz" in url:
1110
+ m = Mega()
1111
+ m.download_url(url, '/content/zips')
1112
+ else:
1113
+ !wget "$url" -O "$audio_zip_path"
1114
+
1115
+ for filename in os.listdir("/content/zips"):
1116
+ if filename.endswith(".zip"):
1117
+ zip_file = os.path.join("/content/zips", filename)
1118
+ shutil.unpack_archive(zip_file, "/content/unzips", 'zip')
1119
+
1120
+ sanitize_directory("/content/unzips")
1121
+
1122
+ # Copy the unzipped audio files to the /content/drive/MyDrive/MDX_Colab/tracks folder
1123
+ !mkdir -p /content/drive/MyDrive/MDX_Colab/tracks
1124
+ for filename in os.listdir("/content/unzips"):
1125
+ if filename.endswith((".wav", ".mp3")):
1126
+ audio_file = os.path.join("/content/unzips", filename)
1127
+ destination_file = os.path.join("/content/drive/MyDrive/MDX_Colab/tracks", filename)
1128
+ shutil.copy2(audio_file, destination_file)
1129
+ if os.path.exists(destination_file):
1130
+ print(f"Copy successful: {destination_file}")
1131
+ else:
1132
+ print(f"Copy failed: {audio_file}")
1133
+
1134
+ !rm -r /content/unzips/
1135
+ !rm -r /content/zips/
1136
+
1137
+ """##Audio Isolation"""
1138
+
1139
+ #@markdown #Upload your files directly to UVR
1140
+ #@markdown Run this cell to upload your vocal files that you want to use, (or zip files containing audio), to your Colab. <br>
1141
+ #@markdown Alternatively, you can upload from the colab files panel, but this should be more convenient. This method may not work on iOS.
1142
+
1143
+ from google.colab import files
1144
+ from IPython.display import display, Javascript
1145
+ import os
1146
+ import shutil
1147
+ import zipfile
1148
+ import ipywidgets as widgets
1149
+
1150
+ # Create the target directory if it doesn't exist
1151
+ target_dir = '/content/drive/MyDrive/MDX_Colab/tracks'
1152
+ if not os.path.exists(target_dir):
1153
+ os.makedirs(target_dir)
1154
+
1155
+ uploaded = files.upload()
1156
+
1157
+ for fn in uploaded.keys():
1158
+ # Check if the uploaded file is a zip file
1159
+ if fn.endswith('.zip'):
1160
+ # Write the uploaded zip file to the target directory
1161
+ zip_path = os.path.join(target_dir, fn)
1162
+ with open(zip_path, 'wb') as f:
1163
+ f.write(uploaded[fn])
1164
+
1165
+ unzip_dir = os.path.join(target_dir, fn[:-4]) # Remove the .zip extension from the folder name
1166
+
1167
+ # Extract the zip file
1168
+ with zipfile.ZipFile(zip_path, 'r') as zip_ref:
1169
+ zip_ref.extractall(unzip_dir)
1170
+
1171
+ # Delete the zip file
1172
+ if os.path.exists(zip_path):
1173
+ os.remove(zip_path)
1174
+
1175
+ print('Zip file "{name}" extracted and removed. Files are in: {folder}'.format(name=fn, folder=unzip_dir))
1176
+
1177
+ # Display copy path buttons for each extracted file
1178
+ for extracted_file in os.listdir(unzip_dir):
1179
+ extracted_file_path = os.path.join(unzip_dir, extracted_file)
1180
+ extracted_file_length = os.path.getsize(extracted_file_path)
1181
+
1182
+ extracted_file_label = widgets.HTML(
1183
+ value='Extracted file "{name}" with length {length} bytes'.format(name=extracted_file, length=extracted_file_length)
1184
+ )
1185
+ display(extracted_file_label)
1186
+
1187
+ extracted_file_path_text = widgets.HTML(
1188
+ value='File saved to: <a href="{}" target="_blank">{}</a>'.format(extracted_file_path, extracted_file_path)
1189
+ )
1190
+
1191
+ extracted_copy_button = widgets.Button(description='Copy')
1192
+ extracted_copy_button_file_path = extracted_file_path # Make a local copy of the file path
1193
+
1194
+ def copy_to_clipboard(b):
1195
+ js_code = '''
1196
+ const el = document.createElement('textarea');
1197
+ el.value = "{path}";
1198
+ el.setAttribute('readonly', '');
1199
+ el.style.position = 'absolute';
1200
+ el.style.left = '-9999px';
1201
+ document.body.appendChild(el);
1202
+ el.select();
1203
+ document.execCommand('copy');
1204
+ document.body.removeChild(el);
1205
+ '''
1206
+ display(Javascript(js_code.format(path=extracted_copy_button_file_path)))
1207
+
1208
+ extracted_copy_button.on_click(copy_to_clipboard)
1209
+ display(widgets.HBox([extracted_file_path_text, extracted_copy_button]))
1210
+
1211
+ continue
1212
+
1213
+ # For non-zip files
1214
+ # Save the file to the target directory
1215
+ file_path = os.path.join(target_dir, fn)
1216
+ with open(file_path, 'wb') as f:
1217
+ f.write(uploaded[fn])
1218
+
1219
+ file_length = len(uploaded[fn])
1220
+ file_label = widgets.HTML(
1221
+ value='User uploaded file "{name}" with length {length} bytes'.format(name=fn, length=file_length)
1222
+ )
1223
+ display(file_label)
1224
+
1225
+ # Check if the uploaded file is a .pth or .index file
1226
+ if fn.endswith('.pth') or fn.endswith('.index'):
1227
+ warning_text = widgets.HTML(
1228
+ value='<b style="color: red;">Warning:</b> You are uploading a model file in the wrong place. Please ensure it is uploaded to the correct location.'
1229
+ )
1230
+ display(warning_text)
1231
+
1232
+ # Create a clickable path with copy button
1233
+ file_path_text = widgets.HTML(
1234
+ value='File saved to: <a href="{}" target="_blank">{}</a>'.format(file_path, file_path)
1235
+ )
1236
+
1237
+ copy_button = widgets.Button(description='Copy')
1238
+ copy_button_file_path = file_path # Make a local copy of the file path
1239
+
1240
+ def copy_to_clipboard(b):
1241
+ js_code = '''
1242
+ const el = document.createElement('textarea');
1243
+ el.value = "{path}";
1244
+ el.setAttribute('readonly', '');
1245
+ el.style.position = 'absolute';
1246
+ el.style.left = '-9999px';
1247
+ document.body.appendChild(el);
1248
+ el.select();
1249
+ document.execCommand('copy');
1250
+ document.body.removeChild(el);
1251
+ '''
1252
+ display(Javascript(js_code.format(path=copy_button_file_path)))
1253
+
1254
+ copy_button.on_click(copy_to_clipboard)
1255
+ display(widgets.HBox([file_path_text, copy_button]))
1256
+
1257
+ # Remove the original uploaded files from /content/
1258
+ for fn in uploaded.keys():
1259
+ if os.path.exists(os.path.join("/content/", fn)):
1260
+ os.remove(os.path.join("/content/", fn))
1261
+
1262
+ #@markdown ### Print a list of tracks
1263
+ for i in glob.glob('tracks/*'):
1264
+ print(os.path.basename(i))
1265
+
1266
+ if not 'initialised' in globals():
1267
+ raise NameError('Please run the first cell first!! #scrollTo=H_cTbwhVq4K6')
1268
+
1269
+ #import all models metadata
1270
+ import json
1271
+ with open('model_data.json', 'r') as f:
1272
+ model_data = json.load(f)
1273
+
1274
+ # Modifiable variables
1275
+ tracks_path = 'tracks/'
1276
+ separated_path = 'separated/'
1277
+
1278
+ #@markdown ### Input track
1279
+ #@markdown Enter any link/Filename (Upload your songs in tracks folder)
1280
+ track = "Butterfly.wav" #@param {type:"string"}
1281
+
1282
+ #@markdown ---
1283
+ #@markdown ### Models
1284
+ ONNX = "MDX-UVR Ins Model Full Band 498 (HQ_2)" #@param ["off", "Karokee", "Karokee_AGGR", "Karokee 2", "baseline", "MDX-UVR Ins Model 415", "MDX-UVR Ins Model 418", "MDX-UVR Ins Model 464", "MDX-UVR Ins Model 496 - inst main-MDX 2.1", "Kim ft other instrumental model", "MDX-UVR Vocal Model 427", "MDX-UVR-Kim Vocal Model (old)", "MDX-UVR Ins Model Full Band 292", "MDX-UVR Ins Model Full Band 403", "MDX-UVR Ins Model Full Band 450 (HQ_1)", "MDX-UVR Ins Model Full Band 498 (HQ_2)"]
1285
+ Demucs = 'off'#@param ["off","demucs_extra"]
1286
+
1287
+ #@markdown ---
1288
+ #@markdown ### Parameters
1289
+ denoise = False #@param {type:"boolean"}
1290
+ normalise = True #@param {type:"boolean"}
1291
+ #getting values from model_data.json related to ONNX var (model folder name)
1292
+ amplitude_compensation = model_data[ONNX]["compensate"]
1293
+ dim_f = model_data[ONNX]["mdx_dim_f_set"]
1294
+ dim_t = model_data[ONNX]["mdx_dim_t_set"]
1295
+ n_fft = model_data[ONNX]["mdx_n_fft_scale_set"]
1296
+
1297
+ mixing_algorithm = 'max_mag' #@param ["default","min_mag","max_mag"]
1298
+ chunks = 55 #@param {type:"slider", min:1, max:55, step:1}
1299
+ shifts = 10 #@param {type:"slider", min:0, max:10, step:0.1}
1300
+
1301
+ ##validate values
1302
+ track = track if 'http' in track else tracks_path+track
1303
+ normalise = '--normalise' if normalise else ''
1304
+ denoise = '--denoise' if denoise else ''
1305
+
1306
+ if ONNX == 'off':
1307
+ pass
1308
+ else:
1309
+ ONNX = 'onnx/'+ONNX
1310
+ if Demucs == 'off':
1311
+ pass
1312
+ else:
1313
+ Demucs = 'model/'+Demucs+'.th'
1314
+ #@markdown ---
1315
+ #@markdown ### Stems
1316
+ bass = False #@param {type:"boolean"}
1317
+ drums = False #@param {type:"boolean"}
1318
+ others = False #@param {type:"boolean"}
1319
+ vocals = True #@param {type:"boolean"}
1320
+ #@markdown ---
1321
+ #@markdown ### Invert stems to mixture
1322
+ invert_bass = False #@param {type:"boolean"}
1323
+ invert_drums = False #@param {type:"boolean"}
1324
+ invert_others = False #@param {type:"boolean"}
1325
+ invert_vocals = True #@param {type:"boolean"}
1326
+ invert_stems = []
1327
+ stems = []
1328
+ if bass:
1329
+ stems.append('b')
1330
+ if drums:
1331
+ stems.append('d')
1332
+ if others:
1333
+ stems.append('o')
1334
+ if vocals:
1335
+ stems.append('v')
1336
+
1337
+ invert_stems = []
1338
+ if invert_bass:
1339
+ invert_stems.append('b')
1340
+ if invert_drums:
1341
+ invert_stems.append('d')
1342
+ if invert_others:
1343
+ invert_stems.append('o')
1344
+ if invert_vocals:
1345
+ invert_stems.append('v')
1346
+
1347
+ margin = 44100
1348
+
1349
+ ###
1350
+ # incompatibilities
1351
+ ###
1352
+
1353
+ console(f"python main.py --n_fft {n_fft} --dim_f {dim_f} --dim_t {dim_t} --margin {margin} -i \"{track}\" --mixing {mixing_algorithm} --onnx \"{ONNX}\" --model {Demucs} --shifts {round(shifts)} --stems {''.join(stems)} --invert {''.join(invert_stems)} --chunks {chunks} --compensate {amplitude_compensation} {normalise} {denoise}")
1354
+
1355
+ """<sup>Models provided are from [Kuielab](https://github.com/kuielab/mdx-net-submission/), [UVR](https://github.com/Anjok07/ultimatevocalremovergui/) and [Kim](https://github.com/KimberleyJensen/) <br> (you can support UVR [here](https://www.buymeacoffee.com/uvr5/vip-model-download-instructions) and [here](https://boosty.to/uvr)).</sup></br>
1356
+ <sup>Original UVR notebook by [Audio Hacker](https://www.youtube.com/channel/UC0NiSV1jLMH-9E09wiDVFYw/), modified by Audio Separation community & then kalomaze (for RVC colab).</sup></br>
1357
+ <sup>Big thanks to the [Audio Separation Discord](https://discord.gg/zeYU2Wzbgj) for helping me implement this in the colab.</sup></br>
1358
+
1359
+ ##**UVR Colab Settings explanation**<br>
1360
+
1361
+ The defaults already provided are generally recommended. However, if you would like to try tweaking them, here's an explanation:
1362
+
1363
+ *Mixing algorithm* - max_mag - is generally for vocals (gives the most residues in instrumentals), min_mag - for instrumentals (the most aggresive) though "min_mag solve some un-wanted vocal soundings, but instrumental [is] more muffled and less detailed". Check out also "default" as it's in between both - a.k.a. average (it's also required for Demucs enabled which works only for vocal models).<br>
1364
+
1365
+ *Chunks* - Set it to 55 or 40 (less aggressive) to alleviate some occasional instrument dissapearing.
1366
+ Set 1 for the best clarity. It works for at least instrumental model (4:15 track, at least for Tesla T4 (shown at the top) generally better quality, but some instruments tend to disappear more using 1 than 10. For Demucs enabled and/or vocal model it can be set to 10 if your track is below 5:00 minutes. The more chunks, the faster separation up to ~40. For 4:15 track, 72 is max supported till memory allocation error shows up (disabled chunks returns error too). <br>
1367
+
1368
+ *Shifts* - can be set max to 10, but it only slightly increases SDR, while processing time is 1.7x longer for each shift and it gives similar result to shifts 5.
1369
+
1370
+ *Normalization* - "normalizes all input at first and then changes the wave peak back to original. This makes the separation process better, also less noise" (e.g. if you have to noisy hihats or big amplitude compensation - disable it).
1371
+ <br>
1372
+
1373
+ *Demucs* enabled works correctly with mixing algorithm set to default and only with vocal models (Kim and 427). It's also the only option to get rid of noise of MDX models. Normalization enabled is necessary (but that cnfiguration has slightly more vocal residues than instrumental model). Decrease chunks to 40 if you have ONNXRuntimeError with Demucs on (it requires lower chunks).
1374
+ <br>
1375
+
1376
+ ##**Recommended models**<br>
1377
+
1378
+ For vocals (by raw SDR output, not factoring in manual cleanup):
1379
+ - Kim vocal 2 (less instrumental residues in vocal stem)
1380
+ - Kim vocal 1
1381
+ <br>or alternatively
1382
+ - 427
1383
+ - 406
1384
+
1385
+ For best lead vocals:
1386
+ - Karaokee 2
1387
+
1388
+ For best backing vocals:
1389
+ - [HP_KAROKEE-MSB2-3BAND-3090](https://colab.research.google.com/drive/16Q44VBJiIrXOgTINztVDVeb0XKhLKHwl?usp=sharing)
1390
+
1391
+ It's rather inconvenient that the VR Architecture models aren't here and have to be run through the above colab, but they can't coexist in the same colab as of right now. I will attempting a better solution in the future.
1392
+ """