soiz1/Retrieval-based-Voice-Conversion-WebUI
0
1{2 "cells": [3 {4 "attachments": {},5 "cell_type": "markdown",6 "metadata": {},7 "source": [8 "# [Retrieval-based-Voice-Conversion-WebUI](https://github.com/RVC-Project/Retrieval-based-Voice-Conversion-WebUI) Training notebook"9 ]10 },11 {12 "attachments": {},13 "cell_type": "markdown",14 "metadata": {15 "id": "ZFFCx5J80SGa"16 },17 "source": [18 "[](https://colab.research.google.com/github/RVC-Project/Retrieval-based-Voice-Conversion-WebUI/blob/main/Retrieval_based_Voice_Conversion_WebUI_v2.ipynb)"19 ]20 },21 {22 "cell_type": "code",23 "execution_count": null,24 "metadata": {25 "id": "GmFP6bN9dvOq"26 },27 "outputs": [],28 "source": [29 "# @title #查看显卡\n",30 "!nvidia-smi"31 ]32 },33 {34 "cell_type": "code",35 "execution_count": null,36 "metadata": {37 "id": "jwu07JgqoFON"38 },39 "outputs": [],40 "source": [41 "# @title 挂载谷歌云盘\n",42 "\n",43 "from google.colab import drive\n",44 "\n",45 "drive.mount(\"/content/drive\")"46 ]47 },48 {49 "cell_type": "code",50 "execution_count": null,51 "metadata": {52 "id": "wjddIFr1oS3W"53 },54 "outputs": [],55 "source": [56 "# @title #安装依赖\n",57 "!apt-get -y install build-essential python3-dev ffmpeg\n",58 "!pip3 install --upgrade setuptools wheel\n",59 "!pip3 install --upgrade pip\n",60 "!pip3 install faiss-cpu==1.7.2 fairseq gradio==3.14.0 ffmpeg ffmpeg-python praat-parselmouth pyworld numpy==1.23.5 numba==0.56.4 librosa==0.9.2"61 ]62 },63 {64 "cell_type": "code",65 "execution_count": null,66 "metadata": {67 "id": "ge_97mfpgqTm"68 },69 "outputs": [],70 "source": [71 "# @title #克隆仓库\n",72 "\n",73 "!mkdir Retrieval-based-Voice-Conversion-WebUI\n",74 "%cd /content/Retrieval-based-Voice-Conversion-WebUI\n",75 "!git init\n",76 "!git remote add origin https://github.com/RVC-Project/Retrieval-based-Voice-Conversion-WebUI.git\n",77 "!git fetch origin cfd984812804ddc9247d65b14c82cd32e56c1133 --depth=1\n",78 "!git reset --hard FETCH_HEAD"79 ]80 },81 {82 "cell_type": "code",83 "execution_count": null,84 "metadata": {85 "id": "BLDEZADkvlw1"86 },87 "outputs": [],88 "source": [89 "# @title #更新仓库(一般无需执行)\n",90 "!git pull"91 ]92 },93 {94 "cell_type": "code",95 "execution_count": null,96 "metadata": {97 "id": "pqE0PrnuRqI2"98 },99 "outputs": [],100 "source": [101 "# @title #安装aria2\n",102 "!apt -y install -qq aria2"103 ]104 },105 {106 "cell_type": "code",107 "execution_count": null,108 "metadata": {109 "id": "UG3XpUwEomUz"110 },111 "outputs": [],112 "source": [113 "# @title 下载底模\n",114 "\n",115 "# v1\n",116 "!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\n",117 "!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\n",118 "!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\n",119 "!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\n",120 "!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\n",121 "!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\n",122 "!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\n",123 "!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\n",124 "!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\n",125 "!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\n",126 "!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\n",127 "!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\n",128 "\n",129 "# v2\n",130 "# !aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained_v2/D32k.pth -d /content/Retrieval-based-Voice-Conversion-WebUI/pretrained_v2 -o D32k.pth\n",131 "!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained_v2/D40k.pth -d /content/Retrieval-based-Voice-Conversion-WebUI/pretrained_v2 -o D40k.pth\n",132 "# !aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained_v2/D48k.pth -d /content/Retrieval-based-Voice-Conversion-WebUI/pretrained_v2 -o D48k.pth\n",133 "# !aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained_v2/G32k.pth -d /content/Retrieval-based-Voice-Conversion-WebUI/pretrained_v2 -o G32k.pth\n",134 "!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained_v2/G40k.pth -d /content/Retrieval-based-Voice-Conversion-WebUI/pretrained_v2 -o G40k.pth\n",135 "# !aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained_v2/G48k.pth -d /content/Retrieval-based-Voice-Conversion-WebUI/pretrained_v2 -o G48k.pth\n",136 "# !aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained_v2/f0D32k.pth -d /content/Retrieval-based-Voice-Conversion-WebUI/pretrained_v2 -o f0D32k.pth\n",137 "!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained_v2/f0D40k.pth -d /content/Retrieval-based-Voice-Conversion-WebUI/pretrained_v2 -o f0D40k.pth\n",138 "# !aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained_v2/f0D48k.pth -d /content/Retrieval-based-Voice-Conversion-WebUI/pretrained_v2 -o f0D48k.pth\n",139 "# !aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained_v2/f0G32k.pth -d /content/Retrieval-based-Voice-Conversion-WebUI/pretrained_v2 -o f0G32k.pth\n",140 "!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained_v2/f0G40k.pth -d /content/Retrieval-based-Voice-Conversion-WebUI/pretrained_v2 -o f0G40k.pth\n",141 "# !aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/pretrained_v2/f0G48k.pth -d /content/Retrieval-based-Voice-Conversion-WebUI/pretrained_v2 -o f0G48k.pth"142 ]143 },144 {145 "cell_type": "code",146 "execution_count": null,147 "metadata": {148 "id": "HugjmZqZRuiF"149 },150 "outputs": [],151 "source": [152 "# @title #下载人声分离模型\n",153 "!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\n",154 "!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"155 ]156 },157 {158 "cell_type": "code",159 "execution_count": null,160 "metadata": {161 "id": "2RCaT9FTR0ej"162 },163 "outputs": [],164 "source": [165 "# @title #下载hubert_base\n",166 "!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"167 ]168 },169 {170 "cell_type": "code",171 "execution_count": null,172 "metadata": {},173 "outputs": [],174 "source": [175 "# @title #下载rmvpe模型\n",176 "!aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/rmvpe.pt -d /content/Retrieval-based-Voice-Conversion-WebUI -o rmvpe.pt"177 ]178 },179 {180 "cell_type": "code",181 "execution_count": null,182 "metadata": {183 "id": "Mwk7Q0Loqzjx"184 },185 "outputs": [],186 "source": [187 "# @title #从谷歌云盘加载打包好的数据集到/content/dataset\n",188 "\n",189 "# @markdown 数据集位置\n",190 "DATASET = (\n",191 " \"/content/drive/MyDrive/dataset/lulu20230327_32k.zip\" # @param {type:\"string\"}\n",192 ")\n",193 "\n",194 "!mkdir -p /content/dataset\n",195 "!unzip -d /content/dataset -B {DATASET}"196 ]197 },198 {199 "cell_type": "code",200 "execution_count": null,201 "metadata": {202 "id": "PDlFxWHWEynD"203 },204 "outputs": [],205 "source": [206 "# @title #重命名数据集中的重名文件\n",207 "!ls -a /content/dataset/\n",208 "!rename 's/(\\w+)\\.(\\w+)~(\\d*)/$1_$3.$2/' /content/dataset/*.*~*"209 ]210 },211 {212 "cell_type": "code",213 "execution_count": null,214 "metadata": {215 "id": "7vh6vphDwO0b"216 },217 "outputs": [],218 "source": [219 "# @title #启动webui\n",220 "%cd /content/Retrieval-based-Voice-Conversion-WebUI\n",221 "# %load_ext tensorboard\n",222 "# %tensorboard --logdir /content/Retrieval-based-Voice-Conversion-WebUI/logs\n",223 "!python3 infer-web.py --colab --pycmd python3"224 ]225 },226 {227 "cell_type": "code",228 "execution_count": null,229 "metadata": {230 "id": "FgJuNeAwx5Y_"231 },232 "outputs": [],233 "source": [234 "# @title #手动将训练后的模型文件备份到谷歌云盘\n",235 "# @markdown #需要自己查看logs文件夹下模型的文件名,手动修改下方命令末尾的文件名\n",236 "\n",237 "# @markdown #模型名\n",238 "MODELNAME = \"lulu\" # @param {type:\"string\"}\n",239 "# @markdown #模型epoch\n",240 "MODELEPOCH = 9600 # @param {type:\"integer\"}\n",241 "\n",242 "!cp /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}/G_{MODELEPOCH}.pth /content/drive/MyDrive/{MODELNAME}_D_{MODELEPOCH}.pth\n",243 "!cp /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}/D_{MODELEPOCH}.pth /content/drive/MyDrive/{MODELNAME}_G_{MODELEPOCH}.pth\n",244 "!cp /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}/added_*.index /content/drive/MyDrive/\n",245 "!cp /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}/total_*.npy /content/drive/MyDrive/\n",246 "\n",247 "!cp /content/Retrieval-based-Voice-Conversion-WebUI/weights/{MODELNAME}.pth /content/drive/MyDrive/{MODELNAME}{MODELEPOCH}.pth"248 ]249 },250 {251 "cell_type": "code",252 "execution_count": null,253 "metadata": {254 "id": "OVQoLQJXS7WX"255 },256 "outputs": [],257 "source": [258 "# @title 从谷歌云盘恢复pth\n",259 "# @markdown 需要自己查看logs文件夹下模型的文件名,手动修改下方命令末尾的文件名\n",260 "\n",261 "# @markdown 模型名\n",262 "MODELNAME = \"lulu\" # @param {type:\"string\"}\n",263 "# @markdown 模型epoch\n",264 "MODELEPOCH = 7500 # @param {type:\"integer\"}\n",265 "\n",266 "!mkdir -p /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}\n",267 "\n",268 "!cp /content/drive/MyDrive/{MODELNAME}_D_{MODELEPOCH}.pth /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}/G_{MODELEPOCH}.pth\n",269 "!cp /content/drive/MyDrive/{MODELNAME}_G_{MODELEPOCH}.pth /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}/D_{MODELEPOCH}.pth\n",270 "!cp /content/drive/MyDrive/*.index /content/\n",271 "!cp /content/drive/MyDrive/*.npy /content/\n",272 "!cp /content/drive/MyDrive/{MODELNAME}{MODELEPOCH}.pth /content/Retrieval-based-Voice-Conversion-WebUI/weights/{MODELNAME}.pth"273 ]274 },275 {276 "cell_type": "code",277 "execution_count": null,278 "metadata": {279 "id": "ZKAyuKb9J6dz"280 },281 "outputs": [],282 "source": [283 "# @title 手动预处理(不推荐)\n",284 "# @markdown 模型名\n",285 "MODELNAME = \"lulu\" # @param {type:\"string\"}\n",286 "# @markdown 采样率\n",287 "BITRATE = 48000 # @param {type:\"integer\"}\n",288 "# @markdown 使用的进程数\n",289 "THREADCOUNT = 8 # @param {type:\"integer\"}\n",290 "\n",291 "!python3 trainset_preprocess_pipeline_print.py /content/dataset {BITRATE} {THREADCOUNT} logs/{MODELNAME} True"292 ]293 },294 {295 "cell_type": "code",296 "execution_count": null,297 "metadata": {298 "id": "CrxJqzAUKmPJ"299 },300 "outputs": [],301 "source": [302 "# @title 手动提取特征(不推荐)\n",303 "# @markdown 模型名\n",304 "MODELNAME = \"lulu\" # @param {type:\"string\"}\n",305 "# @markdown 使用的进程数\n",306 "THREADCOUNT = 8 # @param {type:\"integer\"}\n",307 "# @markdown 音高提取算法\n",308 "ALGO = \"harvest\" # @param {type:\"string\"}\n",309 "\n",310 "!python3 extract_f0_print.py logs/{MODELNAME} {THREADCOUNT} {ALGO}\n",311 "\n",312 "!python3 extract_feature_print.py cpu 1 0 0 logs/{MODELNAME} True"313 ]314 },315 {316 "cell_type": "code",317 "execution_count": null,318 "metadata": {319 "id": "IMLPLKOaKj58"320 },321 "outputs": [],322 "source": [323 "# @title 手动训练(不推荐)\n",324 "# @markdown 模型名\n",325 "MODELNAME = \"lulu\" # @param {type:\"string\"}\n",326 "# @markdown 使用的GPU\n",327 "USEGPU = \"0\" # @param {type:\"string\"}\n",328 "# @markdown 批大小\n",329 "BATCHSIZE = 32 # @param {type:\"integer\"}\n",330 "# @markdown 停止的epoch\n",331 "MODELEPOCH = 3200 # @param {type:\"integer\"}\n",332 "# @markdown 保存epoch间隔\n",333 "EPOCHSAVE = 100 # @param {type:\"integer\"}\n",334 "# @markdown 采样率\n",335 "MODELSAMPLE = \"48k\" # @param {type:\"string\"}\n",336 "# @markdown 是否缓存训练集\n",337 "CACHEDATA = 1 # @param {type:\"integer\"}\n",338 "# @markdown 是否仅保存最新的ckpt文件\n",339 "ONLYLATEST = 0 # @param {type:\"integer\"}\n",340 "\n",341 "!python3 train_nsf_sim_cache_sid_load_pretrain.py -e lulu -sr {MODELSAMPLE} -f0 1 -bs {BATCHSIZE} -g {USEGPU} -te {MODELEPOCH} -se {EPOCHSAVE} -pg pretrained/f0G{MODELSAMPLE}.pth -pd pretrained/f0D{MODELSAMPLE}.pth -l {ONLYLATEST} -c {CACHEDATA}"342 ]343 },344 {345 "cell_type": "code",346 "execution_count": null,347 "metadata": {348 "id": "haYA81hySuDl"349 },350 "outputs": [],351 "source": [352 "# @title 删除其它pth,只留选中的(慎点,仔细看代码)\n",353 "# @markdown 模型名\n",354 "MODELNAME = \"lulu\" # @param {type:\"string\"}\n",355 "# @markdown 选中模型epoch\n",356 "MODELEPOCH = 9600 # @param {type:\"integer\"}\n",357 "\n",358 "!echo \"备份选中的模型。。。\"\n",359 "!cp /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}/G_{MODELEPOCH}.pth /content/{MODELNAME}_D_{MODELEPOCH}.pth\n",360 "!cp /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}/D_{MODELEPOCH}.pth /content/{MODELNAME}_G_{MODELEPOCH}.pth\n",361 "\n",362 "!echo \"正在删除。。。\"\n",363 "!ls /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}\n",364 "!rm /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}/*.pth\n",365 "\n",366 "!echo \"恢复选中的模型。。。\"\n",367 "!mv /content/{MODELNAME}_D_{MODELEPOCH}.pth /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}/G_{MODELEPOCH}.pth\n",368 "!mv /content/{MODELNAME}_G_{MODELEPOCH}.pth /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}/D_{MODELEPOCH}.pth\n",369 "\n",370 "!echo \"删除完成\"\n",371 "!ls /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}"372 ]373 },374 {375 "cell_type": "code",376 "execution_count": null,377 "metadata": {378 "id": "QhSiPTVPoIRh"379 },380 "outputs": [],381 "source": [382 "# @title 清除项目下所有文件,只留选中的模型(慎点,仔细看代码)\n",383 "# @markdown 模型名\n",384 "MODELNAME = \"lulu\" # @param {type:\"string\"}\n",385 "# @markdown 选中模型epoch\n",386 "MODELEPOCH = 9600 # @param {type:\"integer\"}\n",387 "\n",388 "!echo \"备份选中的模型。。。\"\n",389 "!cp /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}/G_{MODELEPOCH}.pth /content/{MODELNAME}_D_{MODELEPOCH}.pth\n",390 "!cp /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}/D_{MODELEPOCH}.pth /content/{MODELNAME}_G_{MODELEPOCH}.pth\n",391 "\n",392 "!echo \"正在删除。。。\"\n",393 "!ls /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}\n",394 "!rm -rf /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}/*\n",395 "\n",396 "!echo \"恢复选中的模型。。。\"\n",397 "!mv /content/{MODELNAME}_D_{MODELEPOCH}.pth /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}/G_{MODELEPOCH}.pth\n",398 "!mv /content/{MODELNAME}_G_{MODELEPOCH}.pth /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}/D_{MODELEPOCH}.pth\n",399 "\n",400 "!echo \"删除完成\"\n",401 "!ls /content/Retrieval-based-Voice-Conversion-WebUI/logs/{MODELNAME}"402 ]403 }404 ],405 "metadata": {406 "accelerator": "GPU",407 "colab": {408 "private_outputs": true,409 "provenance": []410 },411 "gpuClass": "standard",412 "kernelspec": {413 "display_name": "Python 3",414 "name": "python3"415 },416 "language_info": {417 "name": "python"418 }419 },420 "nbformat": 4,421 "nbformat_minor": 0422}423 