{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "0pKllbPyK_BC"
},
"source": [
"## **Applio NoUI**\n",
"A simple, high-quality voice conversion tool focused on ease of use and performance.\n",
"\n",
"[Support](https://discord.gg/urxFjYmYYh) — [GitHub](https://github.com/IAHispano/Applio) — [Terms of Use](https://github.com/IAHispano/Applio/blob/main/TERMS_OF_USE.md)\n",
"\n",
"
\n",
"\n",
"---\n",
"\n",
"
\n",
"\n",
"#### **Acknowledgments**\n",
"\n",
"To all external collaborators for their special help in the following areas: Hina (Encryption method), Poopmaster (Extra section), Shirou (UV installer), Kit Lemonfoot (NoUI inspiration)\n",
"\n",
"#### **Disclaimer**\n",
"By using Applio, you agree to comply with ethical and legal standards, respect intellectual property and privacy rights, avoid harmful or prohibited uses, and accept full responsibility for any outcomes, while Applio disclaims liability and reserves the right to amend these terms."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "ymMCTSD6m8qV"
},
"source": [
"### **Install Applio**\n",
"If the runtime restarts, re-run the installation steps."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"cellView": "form",
"id": "yFhAeKGOp9aa"
},
"outputs": [],
"source": [
"# @title Mount Google Drive\n",
"from google.colab import drive\n",
"\n",
"drive.mount(\"/content/drive\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"cellView": "form",
"id": "CAXW55BQm0PP"
},
"outputs": [],
"source": [
"# @title Setup runtime environment\n",
"from multiprocessing import cpu_count\n",
"cpu_cores = cpu_count()\n",
"post_process = False\n",
"hop_length = 128 # Common default value for hop_length, added for consistency across cells\n",
"\n",
"!git config --global advice.detachedHead false\n",
"!git clone https://github.com/IAHispano/Applio --branch 3.2.9 --single-branch\n",
"%cd /content/Applio\n",
"!sudo update-alternatives --set python3 /usr/bin/python3.10\n",
"!curl -LsSf https://astral.sh/uv/install.sh | sh\n",
"\n",
"print(\"Installing requirements...\")\n",
"!uv pip install -q -r requirements.txt\n",
"print(\"Finished installing requirements!\")\n",
"!python core.py \"prerequisites\" --models \"True\" --pretraineds_hifigan \"True\""
]
},
{
"cell_type": "code",
"source": [
"\n",
"# @title Unduh File Model\n",
"# @markdown Kode ini akan mengunduh file model yang diperlukan ke direktori `/content/`.\n",
"\n",
"import os\n",
"\n",
"# URL dan nama file\n",
"files_to_download = {\n",
" \"D_GKv1_48k.pth\": \"https://huggingface.co/glickko/GK_pretrain/resolve/main/D_GKv1_48k.pth?download=true\",\n",
" \"G_GKv1_48k.pth\": \"https://huggingface.co/glickko/GK_pretrain/resolve/main/G_GKv1_48k.pth?download=true\",\n",
"\n",
"}\n",
"\n",
"# Direktori tujuan\n",
"output_directory = \"/content\"\n",
"\n",
"# Proses pengunduhan\n",
"for filename, url in files_to_download.items():\n",
" output_path = os.path.join(output_directory, filename)\n",
" print(f\"Mengunduh {filename}...\")\n",
" # Menggunakan wget untuk mengunduh file\n",
" !wget -q --show-progress -O {output_path} \"{url}\"\n",
" print(f\"Selesai! File disimpan di: {output_path}\\n\")\n",
"\n",
"print(\"🎉 Semua file telah berhasil diunduh.\")\n",
"\n",
"# Menampilkan isi folder /content untuk verifikasi\n",
"print(\"\\nIsi folder /content saat ini:\")\n",
"!ls -lh /content"
],
"metadata": {
"id": "eYCTi9pE90fU"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "1QkabnLlF2KB"
},
"source": [
"### **Train**"
]
},
{
"cell_type": "code",
"source": [
"# @title Setup model variables\n",
"model_name = \"\" # @param {type:\"string\"}\n",
"sample_rate = \"48k\" # @param [\"32k\", \"40k\", \"48k\"] {allow-input: false}\n",
"sr = int(sample_rate.rstrip(\"k\")) * 1000"
],
"metadata": {
"cellView": "form",
"id": "64V5TWxp05cn"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"cellView": "form",
"id": "oBzqm4JkGGa0"
},
"outputs": [],
"source": [
"# @title Preprocess Dataset\n",
"from os import environ\n",
"environ['TF_CPP_MIN_LOG_LEVEL'] = '3'\n",
"dataset_path = \"\" # @param {type:\"string\"}\n",
"\n",
"cut_preprocess = \"Simple\" # @param [\"Skip\",\"Simple\",\"Automatic\"]\n",
"chunk_len = 5 # @param {type:\"slider\", min:0.5, max:5.0, step:0.5}\n",
"overlap_len = 0.3 # @param {type:\"slider\", min:0, max:0.5, step:0.1}\n",
"process_effects = False # @param{type:\"boolean\"}\n",
"noise_reduction = False # @param{type:\"boolean\"}\n",
"noise_reduction_strength = 0.7 # @param {type:\"slider\", min:0.0, max:1.0, step:0.1}\n",
"\n",
"%cd /content/Applio\n",
"!python core.py preprocess --model_name \"{model_name}\" --dataset_path \"{dataset_path}\" --sample_rate \"{sr}\" --cpu_cores \"{cpu_cores}\" --cut_preprocess \"{cut_preprocess}\" --process_effects \"{process_effects}\" --noise_reduction \"{noise_reduction}\" --noise_reduction_strength \"{noise_reduction_strength}\" --chunk_len \"{chunk_len}\" --overlap_len \"{overlap_len}\""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"cellView": "form",
"id": "zWMiMYfRJTJv"
},
"outputs": [],
"source": [
"# @title Extract Features\n",
"f0_method = \"rmvpe\" # @param [\"crepe\", \"crepe-tiny\", \"rmvpe\"] {allow-input: false}\n",
"\n",
"sr = int(sample_rate.rstrip(\"k\")) * 1000\n",
"include_mutes = 2 # @param {type:\"slider\", min:0, max:10, step:1}\n",
"embedder_model = \"contentvec\" # @param [\"contentvec\", \"chinese-hubert-base\", \"japanese-hubert-base\", \"korean-hubert-base\", \"custom\"] {allow-input: false}\n",
"embedder_model_custom = \"\" # @param {type:\"string\"}\n",
"\n",
"%cd /content/Applio\n",
"!python core.py extract --model_name \"{model_name}\" --f0_method \"{f0_method}\" --hop_length \"{hop_length}\" --sample_rate \"{sr}\" --cpu_cores \"{cpu_cores}\" --gpu \"0\" --embedder_model \"{embedder_model}\" --embedder_model_custom \"{embedder_model_custom}\" --include_mutes \"{include_mutes}\""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"cellView": "form",
"id": "bHLs5AT4Q1ck"
},
"outputs": [],
"source": [
"# @title Generate index file\n",
"index_algorithm = \"Auto\" # @param [\"Auto\", \"Faiss\", \"KMeans\"] {allow-input: false}\n",
"\n",
"%cd /content/Applio\n",
"!python core.py index --model_name \"{model_name}\" --index_algorithm \"{index_algorithm}\""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"cellView": "form",
"id": "TI6LLdIzKAIa"
},
"outputs": [],
"source": [
"# @title Start Training\n",
"import threading\n",
"import time\n",
"import os\n",
"import shutil\n",
"import hashlib\n",
"import time\n",
"\n",
"LOGS_FOLDER = \"/content/Applio/logs/\"\n",
"GOOGLE_DRIVE_PATH = \"/content/drive/MyDrive/RVC_Backup\"\n",
"\n",
"\n",
"def import_google_drive_backup():\n",
" print(\"Importing Google Drive backup...\")\n",
" for root, dirs, files in os.walk(GOOGLE_DRIVE_PATH):\n",
" for filename in files:\n",
" filepath = os.path.join(root, filename)\n",
" if os.path.isfile(filepath):\n",
" backup_filepath = os.path.join(\n",
" LOGS_FOLDER, os.path.relpath(filepath, GOOGLE_DRIVE_PATH)\n",
" )\n",
" backup_folderpath = os.path.dirname(backup_filepath)\n",
" if not os.path.exists(backup_folderpath):\n",
" os.makedirs(backup_folderpath)\n",
" print(f\"Created backup folder: {backup_folderpath}\", flush=True)\n",
" shutil.copy2(filepath, backup_filepath)\n",
" print(f\"Imported file from Google Drive backup: {filename}\")\n",
" print(\"Google Drive backup import completed.\")\n",
"\n",
"\n",
"if \"autobackups\" not in globals():\n",
" autobackups = False\n",
"# @markdown ### 💾 AutoBackup\n",
"cooldown = 15 # @param {type:\"slider\", min:0, max:100, step:0}\n",
"auto_backups = True # @param{type:\"boolean\"}\n",
"def backup_files():\n",
" print(\"\\nStarting backup loop...\")\n",
" last_backup_timestamps_path = os.path.join(\n",
" LOGS_FOLDER, \"last_backup_timestamps.txt\"\n",
" )\n",
" fully_updated = False\n",
"\n",
" while True:\n",
" try:\n",
" updated_files = 0\n",
" deleted_files = 0\n",
" new_files = 0\n",
" last_backup_timestamps = {}\n",
"\n",
" try:\n",
" with open(last_backup_timestamps_path, \"r\") as f:\n",
" last_backup_timestamps = dict(line.strip().split(\":\") for line in f)\n",
" except FileNotFoundError:\n",
" pass\n",
"\n",
" for root, dirs, files in os.walk(LOGS_FOLDER):\n",
" # Excluding \"zips\" and \"mute\" directories\n",
" if \"zips\" in dirs:\n",
" dirs.remove(\"zips\")\n",
" if \"mute\" in dirs:\n",
" dirs.remove(\"mute\")\n",
"\n",
" for filename in files:\n",
" if filename != \"last_backup_timestamps.txt\":\n",
" filepath = os.path.join(root, filename)\n",
" if os.path.isfile(filepath):\n",
" backup_filepath = os.path.join(\n",
" GOOGLE_DRIVE_PATH,\n",
" os.path.relpath(filepath, LOGS_FOLDER),\n",
" )\n",
" backup_folderpath = os.path.dirname(backup_filepath)\n",
" if not os.path.exists(backup_folderpath):\n",
" os.makedirs(backup_folderpath)\n",
" last_backup_timestamp = last_backup_timestamps.get(filepath)\n",
" current_timestamp = os.path.getmtime(filepath)\n",
" if (\n",
" last_backup_timestamp is None\n",
" or float(last_backup_timestamp) < current_timestamp\n",
" ):\n",
" shutil.copy2(filepath, backup_filepath)\n",
" last_backup_timestamps[filepath] = str(current_timestamp)\n",
" if last_backup_timestamp is None:\n",
" new_files += 1\n",
" else:\n",
" updated_files += 1\n",
"\n",
"\n",
" for filepath in list(last_backup_timestamps.keys()):\n",
" if not os.path.exists(filepath):\n",
" backup_filepath = os.path.join(\n",
" GOOGLE_DRIVE_PATH, os.path.relpath(filepath, LOGS_FOLDER)\n",
" )\n",
" if os.path.exists(backup_filepath):\n",
" os.remove(backup_filepath)\n",
" deleted_files += 1\n",
" del last_backup_timestamps[filepath]\n",
"\n",
"\n",
" if updated_files > 0 or deleted_files > 0 or new_files > 0:\n",
" print(f\"Backup Complete: {new_files} new, {updated_files} updated, {deleted_files} deleted.\")\n",
" fully_updated = False\n",
" elif not fully_updated:\n",
" print(\"Files are up to date.\")\n",
" fully_updated = True\n",
"\n",
" with open(last_backup_timestamps_path, \"w\") as f:\n",
" for filepath, timestamp in last_backup_timestamps.items():\n",
" f.write(f\"{filepath}:{timestamp}\\n\")\n",
"\n",
" time.sleep(cooldown if fully_updated else 0.1)\n",
"\n",
"\n",
" except Exception as error:\n",
" print(f\"An error occurred during backup: {error}\")\n",
"\n",
"\n",
"if autobackups:\n",
" autobackups = False\n",
" print(\"Autobackup Disabled\")\n",
"else:\n",
" autobackups = True\n",
" print(\"Autobackup Enabled\")\n",
"# @markdown ### ⚙️ Train Settings\n",
"total_epoch = 150 # @param {type:\"integer\"}\n",
"batch_size = 19 # @param {type:\"slider\", min:1, max:25, step:0}\n",
"gpu = 0\n",
"sr = int(sample_rate.rstrip(\"k\")) * 1000\n",
"pretrained = True # @param{type:\"boolean\"}\n",
"cleanup = False # @param{type:\"boolean\"}\n",
"cache_data_in_gpu = False # @param{type:\"boolean\"}\n",
"vocoder = \"HiFi-GAN\" # @param [\"HiFi-GAN\"]\n",
"checkpointing = False\n",
"tensorboard = True # @param{type:\"boolean\"}\n",
"# @markdown ### ➡️ Choose how many epochs your model will be stored\n",
"save_every_epoch = 10 # @param {type:\"slider\", min:1, max:100, step:0}\n",
"save_only_latest = True # @param{type:\"boolean\"}\n",
"save_every_weights = True # @param{type:\"boolean\"}\n",
"overtraining_detector = False # @param{type:\"boolean\"}\n",
"overtraining_threshold = 50 # @param {type:\"slider\", min:1, max:100, step:0}\n",
"# @markdown ### ❓ Optional\n",
"# @markdown In case you select custom pretrained, you will have to download the pretraineds and enter the path of the pretraineds.\n",
"custom_pretrained = True # @param{type:\"boolean\"}\n",
"g_pretrained_path = \"/content/G_GKv1_48k.pth\" # @param {type:\"string\"}\n",
"d_pretrained_path = \"/content/D_GKv1_48k.pth\" # @param {type:\"string\"}\n",
"\n",
"if \"pretrained\" not in globals():\n",
" pretrained = True\n",
"\n",
"if \"custom_pretrained\" not in globals():\n",
" custom_pretrained = False\n",
"\n",
"if \"g_pretrained_path\" not in globals():\n",
" g_pretrained_path = \"Custom Path\"\n",
"\n",
"if \"d_pretrained_path\" not in globals():\n",
" d_pretrained_path = \"Custom Path\"\n",
"\n",
"\n",
"def start_train():\n",
" if tensorboard == True:\n",
" %load_ext tensorboard\n",
" %tensorboard --logdir /content/Applio/logs/\n",
" %cd /content/Applio\n",
" !python core.py train --model_name \"{model_name}\" --save_every_epoch \"{save_every_epoch}\" --save_only_latest \"{save_only_latest}\" --save_every_weights \"{save_every_weights}\" --total_epoch \"{total_epoch}\" --sample_rate \"{sr}\" --batch_size \"{batch_size}\" --gpu \"{gpu}\" --pretrained \"{pretrained}\" --custom_pretrained \"{custom_pretrained}\" --g_pretrained_path \"{g_pretrained_path}\" --d_pretrained_path \"{d_pretrained_path}\" --overtraining_detector \"{overtraining_detector}\" --overtraining_threshold \"{overtraining_threshold}\" --cleanup \"{cleanup}\" --cache_data_in_gpu \"{cache_data_in_gpu}\" --vocoder \"{vocoder}\" --checkpointing \"{checkpointing}\"\n",
"\n",
"\n",
"server_thread = threading.Thread(target=start_train)\n",
"server_thread.start()\n",
"\n",
"if auto_backups:\n",
" backup_files()\n",
"else:\n",
" while True:\n",
" time.sleep(10)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"cellView": "form",
"id": "X_eU_SoiHIQg"
},
"source": [
"# @title Export model\n",
"from pathlib import Path\n",
"\n",
"export_for = \"training\" # @param [\"training\", \"inference\"] {allow-input: false}\n",
"\n",
"logs_folder = Path(f\"/content/Applio/logs/{model_name}/\")\n",
"if not (logs_folder.exists() and logs_folder.is_dir()):\n",
" raise FileNotFoundError(f\"{model_name} model folder not found\")\n",
"\n",
"%cd {logs_folder}/..\n",
"if export_for == \"training\":\n",
" !zip -r \"/content/{model_name}.zip\" \"{model_name}\"\n",
"else:\n",
" # find latest trained weight file\n",
" !ls -t \"{model_name}/{model_name}\"_*e_*s.pth | head -n 1 > /tmp/weight.txt\n",
" weight_path = open(\"/tmp/weight.txt\", \"r\").read().strip()\n",
" if weight_path == \"\":\n",
" raise FileNotFoundError(\"Model has no weight file, please finish training first\")\n",
" weight_name = Path(weight_path).name\n",
" # command does not fail if index is missing, and i allow it\n",
" !zip \"/content/{model_name}.zip\" \"{model_name}/{weight_name}\" \"{model_name}/{model_name}.index\"\n",
"\n",
"BACKUP_PATH = \"/content/drive/MyDrive/RVC_Backup/\"\n",
"if Path(\"/content/drive\").is_mount():\n",
" !mkdir -p \"{BACKUP_PATH}\"\n",
" !mv \"/content/{model_name}.zip\" \"{BACKUP_PATH}\" && echo \"Exported model as {BACKUP_PATH}{model_name}.zip\"\n",
"else:\n",
" !echo \"Drive not mounted, exporting model as /content/{model_name}.zip\""
],
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "OaKoymXsyEYN"
},
"source": [
"### **Resume training**"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"cellView": "form",
"id": "d3KgLAYnyHkP"
},
"outputs": [],
"source": [
"# @title Load a Backup\n",
"from google.colab import drive\n",
"import os\n",
"import shutil\n",
"\n",
"# @markdown Put the exact name you put as your Model Name in Applio.\n",
"modelname = \"My-Project\" # @param {type:\"string\"}\n",
"source_path = \"/content/drive/MyDrive/RVC_Backup/\" + modelname\n",
"destination_path = \"/content/Applio/logs/\" + modelname\n",
"backup_timestamps_file = \"last_backup_timestamps.txt\"\n",
"if not os.path.exists(source_path):\n",
" print(\n",
" \"The model folder does not exist. Please verify the name is correct or check your Google Drive.\"\n",
" )\n",
"else:\n",
" time_ = os.path.join(\"/content/drive/MyDrive/RVC_Backup/\", backup_timestamps_file)\n",
" time__ = os.path.join(\"/content/Applio/logs/\", backup_timestamps_file)\n",
" if os.path.exists(time_):\n",
" shutil.copy(time_, time__)\n",
" shutil.copytree(source_path, destination_path)\n",
" print(\"Model backup loaded successfully.\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"cellView": "form",
"id": "sc9DzvRCyJ2d"
},
"outputs": [],
"source": [
"# @title Set training variables\n",
"# @markdown ### ➡️ Use the same as you did previously\n",
"model_name = \"Darwin\" # @param {type:\"string\"}\n",
"sample_rate = \"40k\" # @param [\"32k\", \"40k\", \"48k\"] {allow-input: false}\n",
"f0_method = \"rmvpe\" # @param [\"crepe\", \"crepe-tiny\", \"rmvpe\"] {allow-input: false}\n",
"sr = int(sample_rate.rstrip(\"k\")) * 1000"
]
}
],
"metadata": {
"accelerator": "GPU",
"colab": {
"collapsed_sections": [
"ymMCTSD6m8qV"
],
"provenance": [],
"private_outputs": true
},
"kernelspec": {
"display_name": "Python 3",
"name": "python3"
},
"language_info": {
"name": "python"
}
},
"nbformat": 4,
"nbformat_minor": 0
}