Skip to content

Commit 408b87b

Browse files
committed
Created using Colab
1 parent 8859074 commit 408b87b

File tree

1 file changed

+136
-5
lines changed

1 file changed

+136
-5
lines changed

Advanced-RVC.ipynb

Lines changed: 136 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,18 +94,149 @@
9494
},
9595
{
9696
"cell_type": "code",
97+
"source": [
98+
"#@title youtube downloader for separation\n",
99+
"import yt_dlp\n",
100+
"import os\n",
101+
"\n",
102+
"def download_wav(video_url, output_dir):\n",
103+
" ydl_opts = {\n",
104+
" 'format': 'bestaudio/best',\n",
105+
" 'outtmpl': os.path.join(output_dir, '%(title)s.%(ext)s'),\n",
106+
" 'noplaylist': True, # Download only a single video, not a playlist\n",
107+
" 'extract_audio': True,\n",
108+
" 'audio_format': 'wav', # Ensure WAV format\n",
109+
" 'postprocessors': [{\n",
110+
" 'key': 'FFmpegExtractAudio',\n",
111+
" 'preferredcodec': 'wav',\n",
112+
" }]\n",
113+
" }\n",
114+
"\n",
115+
" try:\n",
116+
" with yt_dlp.YoutubeDL(ydl_opts) as ydl:\n",
117+
" ydl.download([video_url])\n",
118+
" print(f\"Download completed. Audio saved in {output_dir}\")\n",
119+
" except yt_dlp.utils.DownloadError as e:\n",
120+
" print(f\"An error occurred: {e}\")\n",
121+
"\n",
122+
"# Example usage\n",
123+
"video_url = 'YOUR_YOUTUBE_URL' #@param {type:\"string\"}\n",
124+
" # Replace with your YouTube video URL\n",
125+
"output_directory = '/content/yt_dlp/' #@param {type:\"string\"}\n",
126+
" # customize your output directory\n",
127+
"\n",
128+
"# Create the output directory if it doesn't exist.\n",
129+
"os.makedirs(output_directory, exist_ok=True)\n",
130+
"\n",
131+
"download_wav(video_url, output_directory)"
132+
],
133+
"metadata": {
134+
"cellView": "form",
135+
"id": "hDYUwhTXJI3_"
136+
},
97137
"execution_count": null,
138+
"outputs": []
139+
},
140+
{
141+
"cell_type": "code",
142+
"source": [
143+
"#@title audio separator for infernece\n",
144+
"\n",
145+
"\n",
146+
"\n",
147+
"from audio_separator.separator import Separator\n",
148+
"\n",
149+
"aud_input = \"Input_aud\" #@param {type:\"string\"}\n",
150+
"\n",
151+
"output_dir = \"/content/separated\" #@param {type:\"string\"}\n",
152+
"\n",
153+
"# Initialize the Separator class (with optional configuration properties, below)\n",
154+
"separator = Separator(output_dir=output_dir, output_format=\"wav\")\n",
155+
"\n",
156+
"separator.load_model()\n",
157+
"\n",
158+
"output_names = {\n",
159+
" \"Vocals\": \"vocals_output\",\n",
160+
" \"Instrumental\": \"instrumental_output\",\n",
161+
"}\n",
162+
"output_files = separator.separate(aud_input, output_names)\n",
163+
"print(f\"Separation complete!\")"
164+
],
98165
"metadata": {
99166
"cellView": "form",
100-
"id": "zG9oR-iDrEPX"
167+
"id": "1pwvdDeHJmU6"
101168
},
102-
"outputs": [],
169+
"execution_count": null,
170+
"outputs": []
171+
},
172+
{
173+
"cell_type": "code",
103174
"source": [
104-
"#@title Run WebUI\n",
105175
"\n",
106176
"\n",
107-
"!python infer.py --colab"
108-
]
177+
"\n",
178+
"\n",
179+
"#@title ## Inference\n",
180+
"import os\n",
181+
"main_dir = \"/content/Harmonify\"\n",
182+
"os.chdir(main_dir)\n",
183+
"from lib.infer import infer_audio\n",
184+
"from google.colab import files\n",
185+
"from pydub import AudioSegment\n",
186+
"import shutil\n",
187+
"\n",
188+
"MODEL_NAME = \"\" #@param {type:\"string\"}\n",
189+
"SOUND_PATH = \"\" #@param {type:\"string\"}\n",
190+
"F0_CHANGE = 0 #@param {type:\"integer\"}\n",
191+
"F0_METHOD = \"fcpe\" #@param [\"crepe\", \"harvest\", \"mangio-crepe\", \"rmvpe\", \"rmvpe+\", \"fcpe\", \"fcpe_legacy\", \"hybrid[mangio-crepe+rmvpe]\", \"hybrid[mangio-crepe+fcpe]\", \"hybrid[rmvpe+fcpe]\", \"hybrid[mangio-crepe+rmvpe+fcpe]\"] {allow-input:true}\n",
192+
"CREPE_HOP_LENGTH = 120 #@param {type:\"integer\"}\n",
193+
"INDEX_RATE = 0.75 #@param {type:\"number\"}\n",
194+
"FILTER_RADIUS = 3 #@param {type:\"integer\"}\n",
195+
"RMS_MIX_RATE = 0.25 #@param {type:\"number\"}\n",
196+
"PROTECT = 0.33 #@param {type:\"number\"}\n",
197+
"SPLIT_INFER = False #@param {type:\"boolean\"}\n",
198+
"MIN_SILENCE = 500 #@param {type:\"number\"}\n",
199+
"SILENCE_THRESHOLD = -50 #@param {type:\"number\"}\n",
200+
"SEEK_STEP = 1 #@param {type:\"slider\", min:1, max:10, step:1}\n",
201+
"KEEP_SILENCE = 200 #@param {type:\"number\"}\n",
202+
"QUEFRENCY = 0 #@param {type:\"number\"}\n",
203+
"TIMBRE = 1 #@param {type:\"number\"}\n",
204+
"F0_AUTOTUNE = False #@param {type:\"boolean\"}\n",
205+
"OUTPUT_FORMAT = \"wav\" #@param [\"wav\", \"flac\", \"mp3\"]\n",
206+
"\n",
207+
"\n",
208+
"\n",
209+
"inferred_audio = infer_audio(\n",
210+
" MODEL_NAME,\n",
211+
" SOUND_PATH,\n",
212+
" F0_CHANGE,\n",
213+
" F0_METHOD,\n",
214+
" CREPE_HOP_LENGTH,\n",
215+
" INDEX_RATE,\n",
216+
" FILTER_RADIUS,\n",
217+
" RMS_MIX_RATE,\n",
218+
" PROTECT,\n",
219+
" SPLIT_INFER,\n",
220+
" MIN_SILENCE,\n",
221+
" SILENCE_THRESHOLD,\n",
222+
" SEEK_STEP,\n",
223+
" KEEP_SILENCE,\n",
224+
" QUEFRENCY,\n",
225+
" TIMBRE,\n",
226+
" F0_AUTOTUNE,\n",
227+
" OUTPUT_FORMAT\n",
228+
")\n",
229+
"os.chdir(main_dir)\n",
230+
"\n",
231+
"print(f\"Showing {inferred_audio}.\")\n",
232+
"AudioSegment.from_file(inferred_audio)"
233+
],
234+
"metadata": {
235+
"cellView": "form",
236+
"id": "PKIrHe_nIou9"
237+
},
238+
"execution_count": null,
239+
"outputs": []
109240
}
110241
],
111242
"metadata": {

0 commit comments

Comments
 (0)