File size: 7,135 Bytes
1503e4f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "45857cb2",
   "metadata": {
    "_cell_guid": "b1076dfc-b9ad-4769-8c92-a6c4dae69d19",
    "_uuid": "8f2839f25d086af736a60e9eeb907d3b93b6e0e5",
    "execution": {
     "iopub.execute_input": "2024-02-18T14:43:46.735480Z",
     "iopub.status.busy": "2024-02-18T14:43:46.735183Z",
     "iopub.status.idle": "2024-02-18T14:48:10.724175Z",
     "shell.execute_reply": "2024-02-18T14:48:10.723059Z"
    },
    "papermill": {
     "duration": 263.994935,
     "end_time": "2024-02-18T14:48:10.726613",
     "exception": false,
     "start_time": "2024-02-18T14:43:46.731678",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "!git clone https://github.com/RVC-Boss/GPT-SoVITS.git\n",
    "%cd GPT-SoVITS\n",
    "!apt-get update && apt-get install -y --no-install-recommends tzdata ffmpeg libsox-dev parallel aria2 git git-lfs && git lfs install\n",
    "!pip install -r requirements.txt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b9d346b4",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2024-02-18T14:48:10.815802Z",
     "iopub.status.busy": "2024-02-18T14:48:10.814899Z",
     "iopub.status.idle": "2024-02-18T14:50:31.253276Z",
     "shell.execute_reply": "2024-02-18T14:50:31.252024Z"
    },
    "papermill": {
     "duration": 140.484893,
     "end_time": "2024-02-18T14:50:31.255720",
     "exception": false,
     "start_time": "2024-02-18T14:48:10.770827",
     "status": "completed"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "# @title Download pretrained models 下载预训练模型\n",
    "!mkdir -p /kaggle/working/GPT-SoVITS/GPT_SoVITS/pretrained_models\n",
    "!mkdir -p /kaggle/working/GPT-SoVITS/tools/asr/models\n",
    "!mkdir -p /kaggle/working/GPT-SoVITS/tools/uvr5\n",
    "%cd /kaggle/working/GPT-SoVITS/GPT_SoVITS/pretrained_models\n",
    "!git clone https://huggingface.co/lj1995/GPT-SoVITS\n",
    "%cd /kaggle/working/GPT-SoVITS/tools/asr/models\n",
    "!git clone https://www.modelscope.cn/damo/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch.git\n",
    "!git clone https://www.modelscope.cn/damo/speech_fsmn_vad_zh-cn-16k-common-pytorch.git\n",
    "!git clone https://www.modelscope.cn/damo/punc_ct-transformer_zh-cn-common-vocab272727-pytorch.git\n",
    "# # @title UVR5 pretrains 安装uvr5模型\n",
    "%cd /kaggle/working/GPT-SoVITS/tools/uvr5\n",
    "!git clone https://huggingface.co/Delik/uvr5_weights\n",
    "!git config core.sparseCheckout true\n",
    "!mv /kaggle/working/GPT-SoVITS/GPT_SoVITS/pretrained_models/GPT-SoVITS/* /kaggle/working/GPT-SoVITS/GPT_SoVITS/pretrained_models/"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ea94d245",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2024-02-18T14:29:01.071549Z",
     "iopub.status.busy": "2024-02-18T14:29:01.070592Z",
     "iopub.status.idle": "2024-02-18T14:40:45.318368Z",
     "shell.execute_reply": "2024-02-18T14:40:45.317130Z",
     "shell.execute_reply.started": "2024-02-18T14:29:01.071512Z"
    },
    "papermill": {
     "duration": null,
     "end_time": null,
     "exception": false,
     "start_time": "2024-02-18T14:50:31.309013",
     "status": "running"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "# @title launch WebUI 启动WebUI\n",
    "%cd /kaggle/working/GPT-SoVITS/\n",
    "!npm install -g localtunnel\n",
    "import subprocess\n",
    "import threading\n",
    "import time\n",
    "import socket\n",
    "import urllib.request\n",
    "def iframe_thread(port):\n",
    "    while True:\n",
    "        time.sleep(0.5)\n",
    "        sock= socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n",
    "        result = sock.connect_ex(('127.0.0.1', port))\n",
    "        if result == 0:\n",
    "            break\n",
    "        sock.close()\n",
    "\n",
    "        from colorama import Fore, Style\n",
    "    print (Fore.GREEN + \"\\nIP: \", Fore. RED, urllib.request.urlopen('https://ipv4.icanhazip.com').read().decode('utf8').strip(\"\\n\"), \"\\n\", Style. RESET_ALL)\n",
    "    p = subprocess.Popen([\"lt\", \"--port\", \"{}\".format(port)], stdout=subprocess.PIPE)\n",
    "    for line in p.stdout:\n",
    "        print(line.decode(), end='')\n",
    "threading.Thread (target=iframe_thread, daemon=True, args=(9874,)).start()\n",
    "\n",
    "!python  webui.py"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "dda88a6d",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2024-02-18T14:40:56.880608Z",
     "iopub.status.busy": "2024-02-18T14:40:56.879879Z"
    },
    "papermill": {
     "duration": null,
     "end_time": null,
     "exception": null,
     "start_time": null,
     "status": "pending"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "# 开启推理页面\n",
    "%cd /kaggle/working/GPT-SoVITS/\n",
    "!npm install -g localtunnel\n",
    "import subprocess\n",
    "import threading\n",
    "import time\n",
    "import socket\n",
    "import urllib.request\n",
    "def iframe_thread(port):\n",
    "    while True:\n",
    "        time.sleep(0.5)\n",
    "        sock= socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n",
    "        result = sock.connect_ex(('127.0.0.1', port))\n",
    "        if result == 0:\n",
    "            break\n",
    "        sock.close()\n",
    "\n",
    "        from colorama import Fore, Style\n",
    "    print (Fore.GREEN + \"\\nIP: \", Fore. RED, urllib.request.urlopen('https://ipv4.icanhazip.com').read().decode('utf8').strip(\"\\n\"), \"\\n\", Style. RESET_ALL)\n",
    "    p = subprocess.Popen([\"lt\", \"--port\", \"{}\".format(port)], stdout=subprocess.PIPE)\n",
    "    for line in p.stdout:\n",
    "        print(line.decode(), end='')\n",
    "threading.Thread (target=iframe_thread, daemon=True, args=(9872,)).start()\n",
    "\n",
    "!python  ./GPT_SoVITS/inference_webui.py"
   ]
  }
 ],
 "metadata": {
  "kaggle": {
   "accelerator": "nvidiaTeslaT4",
   "dataSources": [
    {
     "datasetId": 4459328,
     "sourceId": 7649639,
     "sourceType": "datasetVersion"
    }
   ],
   "dockerImageVersionId": 30646,
   "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.13"
  },
  "papermill": {
   "default_parameters": {},
   "duration": null,
   "end_time": null,
   "environment_variables": {},
   "exception": null,
   "input_path": "__notebook__.ipynb",
   "output_path": "__notebook__.ipynb",
   "parameters": {},
   "start_time": "2024-02-18T14:43:44.011910",
   "version": "2.5.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}