File size: 9,830 Bytes
a8c39f5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
{
    "cells": [
        {
            "cell_type": "markdown",
            "metadata": {},
            "source": [
                "## **Applio**\n",
                "A simple, high-quality voice conversion tool focused on ease of use and performance.\n",
                "\n",
                "[Support](https://discord.gg/urxFjYmYYh) — [Discord Bot](https://discord.com/oauth2/authorize?client_id=1144714449563955302&permissions=1376674695271&scope=bot%20applications.commands) — [Find Voices](https://applio.org/models) — [GitHub](https://github.com/IAHispano/Applio)\n",
                "\n",
                "<br>\n",
                "\n",
                "### **Credits**\n",
                "- Encryption method: [Hina](https://github.com/hinabl)\n",
                "- Main development: [Applio Team](https://github.com/IAHispano)"
            ]
        },
        {
            "cell_type": "markdown",
            "metadata": {},
            "source": [
                "## Install"
            ]
        },
        {
            "cell_type": "code",
            "execution_count": null,
            "metadata": {
                "trusted": true
            },
            "outputs": [],
            "source": [
                "import codecs\n",
                "import os\n",
                "import tarfile\n",
                "import subprocess\n",
                "from pathlib import Path\n",
                "from IPython.display import clear_output\n",
                "rot_47 = lambda encoded_text: \"\".join(\n",
                "    [\n",
                "        (\n",
                "            chr(\n",
                "                (ord(c) - (ord(\"a\") if c.islower() else ord(\"A\")) - 47) % 26\n",
                "                + (ord(\"a\") if c.islower() else ord(\"A\"))\n",
                "            )\n",
                "            if c.isalpha()\n",
                "            else c\n",
                "        )\n",
                "        for c in encoded_text\n",
                "    ]\n",
                ")\n",
                "\n",
                "new_name = rot_47(\"kmjbmvh_hg\")\n",
                "findme = rot_47(codecs.decode(\"pbbxa://oqbpcj.kwu/Dqlitvb/qurwg-mtnqvlmz.oqb\", \"rot_13\"))\n",
                "uioawhd = rot_47(codecs.decode(\"pbbxa://oqbpcj.kwu/QIPqaxivw/Ixxtqw.oqb\", \"rot_13\"))\n",
                "!pip install uv\n",
                "!git clone --depth 1 $uioawhd $new_name --branch 3.2.7\n",
                "clear_output()\n",
                "!mkdir -p /kaggle/tmp\n",
                "%cd /kaggle/tmp\n",
                "!uv venv .venv > /dev/null 2>&1\n",
                "def vidal_setup(ForceIn):\n",
                "    def F():\n",
                "        print(\"Installing pip packages...\")\n",
                "        subprocess.check_call([\"uv\", \"pip\", \"install\", \"-r\", \"requirements.txt\", \"--quiet\"])\n",
                "\n",
                "    A = \"/kaggle/working\" + rot_47(\"Kikpm.ovm.bu\")\n",
                "    D = \"/kaggle/tmp\"\n",
                "    if not os.path.exists(A):\n",
                "        M = os.path.dirname(A)\n",
                "        os.makedirs(M, exist_ok=True)\n",
                "        print(\"No cached install found..\")\n",
                "        try:\n",
                "            N = rot_47(codecs.decode(\"pbbxa://pcooqvonikm.kw/QIPqaxivw/Ixxtqw/zmawtdm/uiqv/Mvdqzwumvb/Siootm/SiootmD2.biz.oh?lwevtwil=bzcm\", \"rot_13\"))\n",
                "            subprocess.run([\"wget\",\"-q\" ,\"-O\", A, N])\n",
                "            print(\"Download completed successfully!\")\n",
                "        except Exception as H:\n",
                "            print(str(H))\n",
                "            if os.path.exists(A):\n",
                "                os.remove(A)\n",
                "    if Path(A).exists():\n",
                "        with tarfile.open(A, \"r:gz\") as I:\n",
                "            I.extractall(D)\n",
                "            print(f\"Extraction of {A} to {D} completed.\")\n",
                "        if os.path.exists(A):\n",
                "            os.remove(A)\n",
                "    else:\n",
                "        F()\n",
                "\n",
                "vidal_setup(False)\n",
                "%cd /kaggle/working/program_ml\n",
                "!source /kaggle/tmp/.venv/bin/activate; python core.py \"prerequisites\" --models \"True\" --exe \"True\" --pretraineds_v1_f0 \"False\" --pretraineds_v2_f0 \"True\" --pretraineds_v1_nof0 \"False\" --pretraineds_v2_nof0 \"False\" > /dev/null 2>&1\n",
                "!sudo curl -fsSL https://raw.githubusercontent.com/filebrowser/get/master/get.sh | sudo bash\n",
                "!filebrowser config init\n",
                "!filebrowser config set --auth.method=noauth\n",
                "!filebrowser users add  \"applio\" \"\" --perm.admin\n",
                "clear_output()\n",
                "print(\"Finished\")"
            ]
        },
        {
            "cell_type": "markdown",
            "metadata": {},
            "source": [
                "## Setup Ngrok"
            ]
        },
        {
            "cell_type": "code",
            "execution_count": null,
            "metadata": {
                "trusted": true
            },
            "outputs": [],
            "source": [
                "#https://dashboard.ngrok.com/get-started/your-authtoken (Token Ngrok)\n",
                "!pip install pyngrok\n",
                "!ngrok config add-authtoken token"
            ]
        },
        {
            "cell_type": "markdown",
            "metadata": {},
            "source": [
                "## Start"
            ]
        },
        {
            "cell_type": "code",
            "execution_count": null,
            "metadata": {
                "trusted": true
            },
            "outputs": [],
            "source": [
                "import os\n",
                "from pyngrok import ngrok\n",
                "from IPython.display import clear_output\n",
                "ngrok.kill()\n",
                "%cd /kaggle/working/program_ml\n",
                "os.system(f\"filebrowser -r /kaggle -p 9876 > /dev/null 2>&1 &\")\n",
                "clear_output()\n",
                "%load_ext tensorboard\n",
                "%tensorboard --logdir logs --port 8077\n",
                "p_tunnel = ngrok.connect(6969)\n",
                "t_tunnel = ngrok.connect(8077)\n",
                "f_tunnel = ngrok.connect(9876)\n",
                "clear_output()\n",
                "print(\"Applio Url:\", p_tunnel.public_url)\n",
                "print(\"Tensorboard Url:\", t_tunnel.public_url)\n",
                "print(\"File Url:\", f_tunnel.public_url)\n",
                "print(\"Save the link for later, this will take a while...\")\n",
                "\n",
                "!source /kaggle/tmp/.venv/bin/activate; python app.py"
            ]
        },
        {
            "cell_type": "markdown",
            "metadata": {
                "_kg_hide-input": false
            },
            "source": [
                "## Extra"
            ]
        },
        {
            "cell_type": "markdown",
            "metadata": {},
            "source": [
                "## Setup new logs folder format\n",
                "- Put the exact name you put as your Model Name in Applio."
            ]
        },
        {
            "cell_type": "code",
            "execution_count": null,
            "metadata": {},
            "outputs": [],
            "source": [
                "\n",
                "modelname = \"Test\"\n",
                "logs_folder = f\"/kaggle/working/program_ml/logs/\" + modelname\n",
                "\n",
                "import os\n",
                "\n",
                "folder_renames = {\n",
                "    \"0_gt_wavs\": \"sliced_audios\",\n",
                "    \"1_16k_wavs\": \"sliced_audios_16k\",\n",
                "    \"2a_f0\": \"f0\",\n",
                "    \"2b-f0nsf\": \"f0_voiced\",\n",
                "    \"3_feature768\": \"v2_extracted\"\n",
                "}\n",
                "\n",
                "def rename_folders(base_path, rename_dict):\n",
                "    for old_name, new_name in rename_dict.items():\n",
                "        old_path = os.path.join(base_path, old_name)\n",
                "        new_path = os.path.join(base_path, new_name)\n",
                "        if os.path.exists(old_path):\n",
                "            os.rename(old_path, new_path)\n",
                "            print(f\"Renamed {old_path} to {new_path}\")\n",
                "        else:\n",
                "            print(f\"Folder {old_path} does not exist\")\n",
                "\n",
                "rename_folders(logs_folder, folder_renames)\n"
            ]
        }
    ],
    "metadata": {
        "kaggle": {
            "accelerator": "nvidiaTeslaT4",
            "dataSources": [],
            "dockerImageVersionId": 30558,
            "isGpuEnabled": true,
            "isInternetEnabled": true,
            "language": "python",
            "sourceType": "notebook"
        },
        "kernelspec": {
            "display_name": "Python 3",
            "language": "python",
            "name": "python3"
        },
        "language_info": {
            "codemirror_mode": {
                "name": "ipython",
                "version": 3
            },
            "file_extension": ".py",
            "mimetype": "text/x-python",
            "name": "python",
            "nbconvert_exporter": "python",
            "pygments_lexer": "ipython3",
            "version": "3.10.12"
        }
    },
    "nbformat": 4,
    "nbformat_minor": 4
}