File size: 9,341 Bytes
96134ee
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "view-in-github",
        "colab_type": "text"
      },
      "source": [
        "<a href=\"https://colab.research.google.com/github/TheNeodev/RVC-MAKER/blob/main/webui.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "# RVC MAKER 🎡"
      ],
      "metadata": {
        "id": "vOlZ8mQ0XMpC"
      }
    },
    {
      "cell_type": "markdown",
      "source": [
        "**This project was created by [TheNeoDev](https://github.com/TheNeodev)** base on [PhamHuynhAnh16/Vietnamese-RVC](https://github.com/PhamHuynhAnh16/Vietnamese-RVC)\n",
        "\n",
        "---"
      ],
      "metadata": {
        "id": "nwKyFp0aaJsS"
      }
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "LVAACnvlmE4I"
      },
      "source": [
        "\n",
        "\n",
        "<big>**Please do not use the project for any purposes that violate ethics, laws, or cause harm to individuals, organizations...**\n",
        "\n",
        "---\n",
        " **In case the user does not comply with the terms or violates them, I will not be responsible for any claims, damages, or legal liabilities, whether in contract, due to negligence, or other reasons, arising from, out of, or related to the software, the use of the software, or other transactions related to the software.**</big>"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "cellView": "form",
        "id": "BJeRif5jjL5s"
      },
      "outputs": [],
      "source": [
        "#@title **🌟Settings**\n",
        "\n",
        "import os\n",
        "from ipywidgets import Button\n",
        "from IPython.display import clear_output\n",
        "print(\"πŸ‘©πŸ»β€πŸ’» INSTALLING...\")\n",
        "\n",
        "os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'\n",
        "\n",
        "!git clone https://github.com/unchCrew/RVC-MAKER.git /content/RVC-MAKER > /dev/null 2>&1\n",
        "!pip install -r /content/RVC-MAKER/requirements.txt --no-cache-dir -q > /dev/null 2>&1\n",
        "!pip install pyngrok --no-cache-dir -q > /dev/null 2>&1\n",
        "\n",
        "#@markdown **πŸ’» Installation will take about 2 minutes to complete!**\n",
        "clear_output()\n",
        "Button(description=\"\\u2714 done!\", button_style=\"success\")"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "cIsBEvHaQWMJ",
        "cellView": "form"
      },
      "outputs": [],
      "source": [
        "#@title **Run webui**\n",
        "import os\n",
        "import shutil\n",
        "\n",
        "%cd /content/RVC-MAKER\n",
        "#@markdown **To experience all the features, use the interface :)**\n",
        "\n",
        "#@markdown **If you know you can use the tensorboard to check for overtraining πŸ‘**\n",
        "tensorboard = False #@param {type:\"boolean\"}\n",
        "\n",
        "\n",
        "\n",
        "\n",
        "\n",
        "# @markdown  ### Choose a sharing method:\n",
        "\n",
        "import codecs\n",
        "import threading\n",
        "import urllib.request\n",
        "import time\n",
        "import ipywidgets as widgets\n",
        "from IPython.display import display\n",
        "import os\n",
        "from pyngrok import ngrok\n",
        "os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'\n",
        "\n",
        "method = \"gradio\"  # @param [\"gradio\", \"localtunnel\", \"ngrok\"]\n",
        "\n",
        "\n",
        "#@markdown If you selected the 'ngrok' method, obtain your auth token here: https://dashboard.ngrok.com/get-started/your-authtoken\n",
        "ngrok_token = \"\" # @param {type:\"string\"}\n",
        "\n",
        "def start_gradio():\n",
        "    !python main/app/app.py --share\n",
        "\n",
        "def start_localtunnel():\n",
        "    !npm install -g localtunnel &>/dev/null\n",
        "    with open('url.txt', 'w') as file:\n",
        "        file.write('')\n",
        "    get_ipython().system_raw('lt --port 7860 >> url.txt 2>&1 &')\n",
        "    time.sleep(2)\n",
        "    endpoint_ip = urllib.request.urlopen('https://ipv4.icanhazip.com').read().decode('utf8').strip(\"\\n\")\n",
        "\n",
        "    with open('url.txt', 'r') as file:\n",
        "        tunnel_url = file.read()\n",
        "        tunnel_url = tunnel_url.replace(\"your url is: \", \"\")\n",
        "\n",
        "    print(f\"Share Link: \\033[0m\\033[93m{tunnel_url}\\033[0m\", end=\"\\033[0m\\n\")\n",
        "\n",
        "    password_endpoint_widget = widgets.Text(\n",
        "    value=endpoint_ip,\n",
        "    description='Password IP:',\n",
        "    disabled=True\n",
        "    )\n",
        "    display(password_endpoint_widget)\n",
        "    !python main/app/app.py\n",
        "\n",
        "\n",
        "def start_ngrok():\n",
        "    try:\n",
        "        ngrok.set_auth_token(ngrok_token)\n",
        "        ngrok.kill()\n",
        "        tunnel = ngrok.connect(7860)\n",
        "        print(f\"Ngrok URL: \\033[0m\\033[93m{tunnel.public_url}\\033[0m\", end=\"\\033[0m\\n\")\n",
        "        !python app.py --listen\n",
        "    except Exception as e:\n",
        "        print(f\"Error starting ngrok: {e}\")\n",
        "\n",
        "def start_app():\n",
        "    if method == 'gradio':\n",
        "        start_gradio()\n",
        "    elif method == 'localtunnel':\n",
        "        start_localtunnel()\n",
        "    elif method == 'ngrok':\n",
        "        start_ngrok()\n",
        "\n",
        "if tensorboard:\n",
        "  %load_ext tensorboard\n",
        "  %tensorboard --logdir ./assets/logs --port=6870\n",
        "\n",
        "\n",
        "thread_app = threading.Thread(target=start_app)\n",
        "thread_app.start()\n",
        "\n",
        "\n",
        "while True:\n",
        "    time.sleep(5)"
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "# Extra"
      ],
      "metadata": {
        "id": "OVg-SqBKXIFL"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "\n",
        "#@title upload model to HF model\n",
        "repo_hf = \"NeoPy/TTS-G\" # @param {type:\"string\"}\n",
        "pth = \"/content/RVC-MAKER/assets/weights/TTS_100e_500s.pth\" # @param {type:\"string\"}\n",
        "index = \"/content/RVC-MAKER/assets/logs/TTS/added_IVF59_Flat_nprobe_1_TTS_v2.index\" # @param {type:\"string\"}\n",
        "\n",
        "#@markdown get token on https://huggingface.co/settings/tokens\n",
        "\n",
        "token = \"hf_\" # @param {type:\"string\"}\n",
        "\n",
        "\n",
        "import huggingface_hub\n",
        "import zipfile\n",
        "import os\n",
        "def upload_model(repo, pth, index, token):\n",
        "    \"\"\"\n",
        "    Upload a model to the Hugging Face Hub\n",
        "\n",
        "    Args:\n",
        "        repo: str, the name of the repository (including user/org, e.g., \"username/repo_name\")\n",
        "        pth: str, path to the model file\n",
        "        index: str, the index of the model in the repository\n",
        "        token: str, the API token\n",
        "\n",
        "    Returns:\n",
        "        str, message indicating the success of the operation\n",
        "    \"\"\"\n",
        "    readme = f\"\"\"\n",
        "    # {repo}\n",
        "    This is a model uploaded by RVC Maker, using [NeoDev](https://github.com/TheNeodev)'s script.\n",
        "    \"\"\"\n",
        "    repo_name = repo.split('/')[1]\n",
        "    with zipfile.ZipFile(f'{repo_name}.zip', 'w') as zipf:\n",
        "        zipf.write(pth, os.path.basename(pth))\n",
        "        zipf.write(index, os.path.basename(index))\n",
        "        zipf.writestr('README.md', readme)\n",
        "\n",
        "    # Corrected: Pass the repo_id directly as the first argument\n",
        "    huggingface_hub.HfApi().create_repo(repo_id=repo, token=token, exist_ok=True)\n",
        "    # Change 'path' to 'path_or_fileobj' as per the error and common usage in newer versions\n",
        "    huggingface_hub.HfApi().upload_file(token=token, path_or_fileobj=f'{repo.split(\"/\")[1]}.zip', repo_id=repo, path_in_repo=f'{repo.split(\"/\")[1]}.zip')\n",
        "    os.remove(f'{repo.split(\"/\")[1]}.zip')\n",
        "    return \"Model uploaded successfully\"\n",
        "\n",
        "\n",
        "upload_model(repo_hf, pth, index, token)"
      ],
      "metadata": {
        "cellView": "form",
        "id": "Y1Jke8epTHFj"
      },
      "execution_count": null,
      "outputs": []
    }
  ],
  "metadata": {
    "accelerator": "GPU",
    "colab": {
      "collapsed_sections": [
        "tkqks7bO2Cye",
        "XP4ifZaG_yd5",
        "ekfkFFNqppfM",
        "ers351v_CMGN"
      ],
      "gpuType": "T4",
      "provenance": [],
      "include_colab_link": true
    },
    "kernelspec": {
      "display_name": "Python 3",
      "name": "python3"
    },
    "language_info": {
      "name": "python"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}