{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "cellView": "form",
        "id": "izLwNF_8T1TK"
      },
      "outputs": [],
      "source": [
        "#@title <font color='#06ae56'>**🍏 Applio (Mangio-RVC-Fork)**</font>\n",
        "import time\n",
        "import os\n",
        "import subprocess\n",
        "import shutil\n",
        "import threading\n",
        "import base64\n",
        "import threading\n",
        "import time\n",
        "from IPython.display import HTML, clear_output\n",
        "\n",
        "nosv_name1 = base64.b64decode(('ZXh0ZXJuYWxj').encode('ascii')).decode('ascii')\n",
        "nosv_name2 = base64.b64decode(('b2xhYmNvZGU=').encode('ascii')).decode('ascii')\n",
        "guebui = base64.b64decode(('V2U=').encode('ascii')).decode('ascii')\n",
        "guebui2 = base64.b64decode(('YlVJ').encode('ascii')).decode('ascii')\n",
        "pbestm = base64.b64decode(('cm12cGU=').encode('ascii')).decode('ascii')\n",
        "tryre = base64.b64decode(('UmV0cmlldmFs').encode('ascii')).decode('ascii')\n",
        "\n",
        "xdsame = '/content/'+ tryre +'-based-Voice-Conversion-' + guebui + guebui2 +'/'\n",
        "\n",
        "collapsible_section = \"\"\"\n",
        "<br>\n",
        "<br>\n",
        "<details style=\"border: 1px solid #ddd; border-radius: 5px; padding: 10px; margin-bottom: 10px;\">\n",
        "    <summary open style=\"font-weight: bold; cursor: pointer;\">🚀 Click to learn more about Applio</summary>\n",
        "    <div style=\"margin-left: 20px;\">\n",
        "        <ul>\n",
        "            <li><a href=\"https://github.com/Mangio621/Mangio-RVC-Fork\" style=\"color: #06ae56;\">Mangio-RVC-Fork</a> - Source of inspiration and base for this improved code, special thanks to the developers.</li>\n",
        "            <li><a href=\"https://github.com/Anjok07/ultimatevocalremovergui\" style=\"color: #06ae56;\">UltimateVocalRemover</a> - Used for voice and instrument separation.</li>\n",
        "            <li>Vidal, Blaise & Aitron - Contributors to the Applio version.</li>\n",
        "            <li>kalomaze - Creator of external scripts that help the functioning of Applio.</li>\n",
        "        </ul>\n",
        "        <p style=\"color: #fff;\">Join and contribute to the project on <a href=\"https://github.com/IAHispano/Applio-RVC-Fork\" style=\"color: #06ae56;\">our GitHub repository</a>.</p>\n",
        "    </div>\n",
        "</details>\n",
        "<br>\n",
        "<button style=\"font-weight: bold; cursor: pointer; background-color: #06ae56; color: white; border: 1px solid #fff; border-radius: 4px; padding: 10px 20px; text-decoration: none;\" onclick=\"window.open('https://discord.gg/IAHispano', '_blank')\">🍏 Join our support Discord server (IA Hispano)</button>\n",
        "<br>\n",
        "<br>\n",
        "\"\"\"\n",
        "#@markdown **Settings:**\n",
        "ForceUpdateDependencies = True\n",
        "ForceNoMountDrive = False\n",
        "#@markdown Restore your backup from Google Drive.\n",
        "LoadBackupDrive = False #@param{type:\"boolean\"}\n",
        "#@markdown Make regular backups of your model's training.\n",
        "AutoBackups = True #@param{type:\"boolean\"}\n",
        "if not os.path.exists(xdsame):\n",
        " current_path = os.getcwd()\n",
        " shutil.rmtree('/content/')\n",
        " os.makedirs('/content/', exist_ok=True)\n",
        "\n",
        " os.chdir(current_path)\n",
        " !git clone https://github.com/IAHispano/$nosv_name1$nosv_name2 /content/$tryre-based-Voice-Conversion-$guebui$guebui2/utils\n",
        " clear_output()\n",
        "\n",
        " os.chdir(xdsame)\n",
        " from utils.dependency import *\n",
        " from utils.clonerepo_experimental import *\n",
        " os.chdir(\"..\")\n",
        "\n",
        "\n",
        "\n",
        " setup_environment(ForceUpdateDependencies, ForceNoMountDrive)\n",
        " clone_repository(True)\n",
        "\n",
        " !wget https://huggingface.co/lj1995/VoiceConversion$guebui$guebui2/resolve/main/rmvpe.pt -P /content/Retrieval-based-Voice-Conversion-$guebui$guebui2/\n",
        " clear_output()\n",
        "\n",
        "base_path = \"/content/Retrieval-based-Voice-Conversion-$guebui$guebui2/\"\n",
        "clear_output()\n",
        "\n",
        "\n",
        "\n",
        "from utils import backups\n",
        "\n",
        "LOGS_FOLDER = xdsame + '/logs'\n",
        "if not os.path.exists(LOGS_FOLDER):\n",
        "    os.makedirs(LOGS_FOLDER)\n",
        "    clear_output()\n",
        "\n",
        "WEIGHTS_FOLDER = xdsame + '/logs' + '/weights'\n",
        "if not os.path.exists(WEIGHTS_FOLDER):\n",
        "    os.makedirs(WEIGHTS_FOLDER)\n",
        "    clear_output()\n",
        "\n",
        "others_FOLDER = xdsame + '/audio-others'\n",
        "if not os.path.exists(others_FOLDER):\n",
        "    os.makedirs(others_FOLDER)\n",
        "    clear_output()\n",
        "\n",
        "audio_outputs_FOLDER = xdsame + '/audio-outputs'\n",
        "if not os.path.exists(audio_outputs_FOLDER):\n",
        "    os.makedirs(audio_outputs_FOLDER)\n",
        "    clear_output()\n",
        "\n",
        "if LoadBackupDrive:\n",
        "    backups.import_google_drive_backup()\n",
        "    clear_output()\n",
        "\n",
        "#@markdown Choose the language in which you want the interface to be available.\n",
        "i18n_path = xdsame + 'i18n.py'\n",
        "i18n_new_path = xdsame + 'utils/i18n.py'\n",
        "try:\n",
        "    if os.path.exists(i18n_path) and os.path.exists(i18n_new_path):\n",
        "        shutil.move(i18n_new_path, i18n_path)\n",
        "\n",
        "    SelectedLanguage = \"en_US\" #@param [\"es_ES\", \"en_US\", \"zh_CN\", \"ar_AR\", \"id_ID\", \"pt_PT\", \"ru_RU\", \"ur_UR\", \"tr_TR\", \"it_IT\", \"de_DE\"]\n",
        "    new_language_line = '            language = \"' + SelectedLanguage + '\"\\n'\n",
        "#@markdown <a href=\"https://discord.gg/iahispano\"><font>If you need more help, feel free to join our official Discord server!</font></a>\n",
        "    with open(i18n_path, 'r') as file:\n",
        "        lines = file.readlines()\n",
        "\n",
        "    with open(i18n_path, 'w') as file:\n",
        "        for index, line in enumerate(lines):\n",
        "            if index == 14:\n",
        "                file.write(new_language_line)\n",
        "            else:\n",
        "                file.write(line)\n",
        "\n",
        "except FileNotFoundError:\n",
        "    print(\"Translation couldn't be applied successfully. Please restart the environment and run the cell again.\")\n",
        "\n",
        "def start_web_server():\n",
        "    %cd /content/$tryre-based-Voice-Conversion-$guebui$guebui2\n",
        "    %load_ext tensorboard\n",
        "    clear_output()\n",
        "    %tensorboard --logdir /content/$tryre-based-Voice-Conversion-$guebui$guebui2/logs\n",
        "    !mkdir -p /content/$tryre-based-Voice-Conversion-$guebui$guebui2/audios\n",
        "    display(HTML(collapsible_section))\n",
        "    !python3 infer-web.py --colab --pycmd python3\n",
        "\n",
        "if AutoBackups:\n",
        "  web_server_thread = threading.Thread(target=start_web_server)\n",
        "  web_server_thread.start()\n",
        "  backups.backup_files()\n",
        "\n",
        "else:\n",
        "  start_web_server()"
      ]
    }
  ],
  "metadata": {
    "accelerator": "GPU",
    "colab": {
      "provenance": []
    },
    "kernelspec": {
      "display_name": "Python 3",
      "name": "python3"
    },
    "language_info": {
      "name": "python"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}