mirror of
https://github.com/w-okada/voice-changer.git
synced 2025-01-23 13:35:12 +03:00
376 lines
16 KiB
Plaintext
376 lines
16 KiB
Plaintext
{
|
||
"nbformat": 4,
|
||
"nbformat_minor": 0,
|
||
"metadata": {
|
||
"colab": {
|
||
"provenance": [],
|
||
"authorship_tag": "ABX9TyNSRTUjuUmmq9gIRJWCoVVn",
|
||
"include_colab_link": true
|
||
},
|
||
"kernelspec": {
|
||
"name": "python3",
|
||
"display_name": "Python 3"
|
||
},
|
||
"language_info": {
|
||
"name": "python"
|
||
},
|
||
"accelerator": "GPU",
|
||
"gpuClass": "standard"
|
||
},
|
||
"cells": [
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {
|
||
"id": "view-in-github",
|
||
"colab_type": "text"
|
||
},
|
||
"source": [
|
||
"<a href=\"https://colab.research.google.com/github/w-okada/voice-changer/blob/dev/VoiceChangerDemo_Simple.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"source": [
|
||
"MMVCプレイヤー(超簡単版)\n",
|
||
"---\n",
|
||
"\n",
|
||
"このノートはColab上でMMVCのボイチェンを行うノートです。\n",
|
||
"\n",
|
||
"正式版はローカルPCのDocker上で動かすアプリケーションです。\n",
|
||
"\n",
|
||
"正式版は、多くの場合より少ないタイムラグで滑らかに音声を変換できます。\n",
|
||
"\n",
|
||
"詳細な使用方法はこちらの[リポジトリ](https://github.com/w-okada/voice-changer)からご確認ください。\n"
|
||
],
|
||
"metadata": {
|
||
"id": "Lbbmx_Vjl0zo"
|
||
}
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"source": [
|
||
"# GPUを確認\n",
|
||
"GPUを用いたほうが高速に処理が行えます。\n",
|
||
"\n",
|
||
"下記のコマンドでGPUが確認できない場合は、上のメニューから\n",
|
||
"\n",
|
||
"「ランタイム」→「ランタイムの変更」→「ハードウェア アクセラレータ」\n",
|
||
"\n",
|
||
"でGPUを選択してください。"
|
||
],
|
||
"metadata": {
|
||
"id": "oUKi1NYMmXrr"
|
||
}
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"source": [
|
||
"# (1) GPUの確認\n",
|
||
"!nvidia-smi"
|
||
],
|
||
"metadata": {
|
||
"colab": {
|
||
"base_uri": "https://localhost:8080/"
|
||
},
|
||
"id": "vV1t7PBRm-o6",
|
||
"outputId": "aa02d901-b65d-40bf-ff88-c06b88155031"
|
||
},
|
||
"execution_count": 1,
|
||
"outputs": [
|
||
{
|
||
"output_type": "stream",
|
||
"name": "stdout",
|
||
"text": [
|
||
"Wed Jan 11 08:52:42 2023 \n",
|
||
"+-----------------------------------------------------------------------------+\n",
|
||
"| NVIDIA-SMI 460.32.03 Driver Version: 460.32.03 CUDA Version: 11.2 |\n",
|
||
"|-------------------------------+----------------------+----------------------+\n",
|
||
"| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |\n",
|
||
"| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |\n",
|
||
"| | | MIG M. |\n",
|
||
"|===============================+======================+======================|\n",
|
||
"| 0 Tesla T4 Off | 00000000:00:04.0 Off | 0 |\n",
|
||
"| N/A 64C P8 12W / 70W | 0MiB / 15109MiB | 0% Default |\n",
|
||
"| | | N/A |\n",
|
||
"+-------------------------------+----------------------+----------------------+\n",
|
||
" \n",
|
||
"+-----------------------------------------------------------------------------+\n",
|
||
"| Processes: |\n",
|
||
"| GPU GI CI PID Type Process name GPU Memory |\n",
|
||
"| ID ID Usage |\n",
|
||
"|=============================================================================|\n",
|
||
"| No running processes found |\n",
|
||
"+-----------------------------------------------------------------------------+\n"
|
||
]
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"source": [
|
||
"# リポジトリのクローン\n",
|
||
"リポジトリをクローンします"
|
||
],
|
||
"metadata": {
|
||
"id": "sLBfykjBnjWc"
|
||
}
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"source": [
|
||
"# (2) リポジトリのクローン\n",
|
||
"!git clone --depth 1 https://github.com/w-okada/voice-changer.git -b v.1.3.0\n",
|
||
"%cd voice-changer/server\n",
|
||
"!git clone --depth 1 https://github.com/isletennos/MMVC_Trainer.git -b v1.3.2.2\n",
|
||
"!cd MMVC_Trainer/monotonic_align/ && python setup.py build_ext --inplace && cd -\n",
|
||
"\n",
|
||
"# !cythonize -3 -i core.pyx &> /dev/null\n",
|
||
"# !mv core.cpython-*.so monotonic_align &> /dev/null\n",
|
||
"# %cd /content/voice-changer/demo/\n",
|
||
"\n",
|
||
"# !cp ../template/setting_mmvc_colab.json ../frontend/dist/assets/setting.json"
|
||
],
|
||
"metadata": {
|
||
"colab": {
|
||
"base_uri": "https://localhost:8080/"
|
||
},
|
||
"id": "86wTFmqsNMnD",
|
||
"outputId": "6bf049ac-02e3-43e9-95d3-77cd42c05eb1"
|
||
},
|
||
"execution_count": 2,
|
||
"outputs": [
|
||
{
|
||
"output_type": "stream",
|
||
"name": "stdout",
|
||
"text": [
|
||
"Cloning into 'voice-changer'...\n",
|
||
"remote: Enumerating objects: 138, done.\u001b[K\n",
|
||
"remote: Counting objects: 100% (138/138), done.\u001b[K\n",
|
||
"remote: Compressing objects: 100% (119/119), done.\u001b[K\n",
|
||
"remote: Total 138 (delta 18), reused 64 (delta 8), pack-reused 0\u001b[K\n",
|
||
"Receiving objects: 100% (138/138), 1.51 MiB | 4.72 MiB/s, done.\n",
|
||
"Resolving deltas: 100% (18/18), done.\n",
|
||
"/content/voice-changer/server\n",
|
||
"Cloning into 'MMVC_Trainer'...\n",
|
||
"remote: Enumerating objects: 920, done.\u001b[K\n",
|
||
"remote: Counting objects: 100% (920/920), done.\u001b[K\n",
|
||
"remote: Compressing objects: 100% (830/830), done.\u001b[K\n",
|
||
"remote: Total 920 (delta 4), reused 893 (delta 1), pack-reused 0\u001b[K\n",
|
||
"Receiving objects: 100% (920/920), 53.04 MiB | 33.98 MiB/s, done.\n",
|
||
"Resolving deltas: 100% (4/4), done.\n",
|
||
"Note: checking out 'f17c8c57d1ab7512633e6c57521f1eef6851bd0e'.\n",
|
||
"\n",
|
||
"You are in 'detached HEAD' state. You can look around, make experimental\n",
|
||
"changes and commit them, and you can discard any commits you make in this\n",
|
||
"state without impacting any branches by performing another checkout.\n",
|
||
"\n",
|
||
"If you want to create a new branch to retain commits you create, you may\n",
|
||
"do so (now or later) by using -b with the checkout command again. Example:\n",
|
||
"\n",
|
||
" git checkout -b <new-branch-name>\n",
|
||
"\n",
|
||
"Compiling core.pyx because it changed.\n",
|
||
"[1/1] Cythonizing core.pyx\n",
|
||
"/usr/local/lib/python3.8/dist-packages/Cython/Compiler/Main.py:369: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: /content/voice-changer/server/MMVC_Trainer/monotonic_align/core.pyx\n",
|
||
" tree = Parsing.p_module(s, pxd, full_module_name)\n",
|
||
"running build_ext\n",
|
||
"building 'monotonic_align.core' extension\n",
|
||
"creating build\n",
|
||
"creating build/temp.linux-x86_64-3.8\n",
|
||
"x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/local/lib/python3.8/dist-packages/numpy/core/include -I/usr/include/python3.8 -c core.c -o build/temp.linux-x86_64-3.8/core.o\n",
|
||
"x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -g -fwrapv -O2 -Wl,-Bsymbolic-functions -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 build/temp.linux-x86_64-3.8/core.o -o /content/voice-changer/server/MMVC_Trainer/monotonic_align/monotonic_align/core.cpython-38-x86_64-linux-gnu.so\n",
|
||
"/content/voice-changer/server\n"
|
||
]
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"source": [
|
||
"# モジュールのインストール\n",
|
||
"\n",
|
||
"必要なモジュールをインストールします。"
|
||
],
|
||
"metadata": {
|
||
"id": "8Na2PbLZSWgZ"
|
||
}
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"source": [
|
||
"# (3) 設定ファイルの確認\n",
|
||
"!apt-get install -y libsndfile1-dev &> /dev/null\n",
|
||
"!pip install unidecode &> /dev/null\n",
|
||
"!pip install phonemizer &> /dev/null\n",
|
||
"!pip install retry &> /dev/null\n",
|
||
"!pip install python-socketio &> /dev/null\n",
|
||
"!pip install fastapi &> /dev/null\n",
|
||
"!pip install python-multipart &> /dev/null\n",
|
||
"!pip install uvicorn &> /dev/null\n",
|
||
"!pip install websockets &> /dev/null\n",
|
||
"!pip install pyOpenSSL &> /dev/null\n",
|
||
"!pip install onnxruntime-gpu &> /dev/null"
|
||
],
|
||
"metadata": {
|
||
"id": "LwZAAuqxX7yY",
|
||
"outputId": "42f08570-62bf-4573-bd73-f0a3bb7f4f03",
|
||
"colab": {
|
||
"base_uri": "https://localhost:8080/"
|
||
}
|
||
},
|
||
"execution_count": 4,
|
||
"outputs": [
|
||
{
|
||
"output_type": "stream",
|
||
"name": "stdout",
|
||
"text": [
|
||
"Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/\n",
|
||
"Collecting onnxruntime-gpu\n",
|
||
" Downloading onnxruntime_gpu-1.13.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (115.3 MB)\n",
|
||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m115.3/115.3 MB\u001b[0m \u001b[31m9.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||
"\u001b[?25hRequirement already satisfied: numpy>=1.21.6 in /usr/local/lib/python3.8/dist-packages (from onnxruntime-gpu) (1.21.6)\n",
|
||
"Requirement already satisfied: packaging in /usr/local/lib/python3.8/dist-packages (from onnxruntime-gpu) (21.3)\n",
|
||
"Requirement already satisfied: protobuf in /usr/local/lib/python3.8/dist-packages (from onnxruntime-gpu) (3.19.6)\n",
|
||
"Requirement already satisfied: flatbuffers in /usr/local/lib/python3.8/dist-packages (from onnxruntime-gpu) (1.12)\n",
|
||
"Requirement already satisfied: sympy in /usr/local/lib/python3.8/dist-packages (from onnxruntime-gpu) (1.7.1)\n",
|
||
"Collecting coloredlogs\n",
|
||
" Downloading coloredlogs-15.0.1-py2.py3-none-any.whl (46 kB)\n",
|
||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m46.0/46.0 KB\u001b[0m \u001b[31m7.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||
"\u001b[?25hCollecting humanfriendly>=9.1\n",
|
||
" Downloading humanfriendly-10.0-py2.py3-none-any.whl (86 kB)\n",
|
||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m86.8/86.8 KB\u001b[0m \u001b[31m13.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||
"\u001b[?25hRequirement already satisfied: pyparsing!=3.0.5,>=2.0.2 in /usr/local/lib/python3.8/dist-packages (from packaging->onnxruntime-gpu) (3.0.9)\n",
|
||
"Requirement already satisfied: mpmath>=0.19 in /usr/local/lib/python3.8/dist-packages (from sympy->onnxruntime-gpu) (1.2.1)\n",
|
||
"Installing collected packages: humanfriendly, coloredlogs, onnxruntime-gpu\n",
|
||
"Successfully installed coloredlogs-15.0.1 humanfriendly-10.0 onnxruntime-gpu-1.13.1\n"
|
||
]
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"source": [
|
||
"# サーバの起動\n",
|
||
"\n",
|
||
"サーバを起動します。(4-1)\n",
|
||
"\n",
|
||
"サーバの起動状況を確認します。(4-2) \n",
|
||
"\n",
|
||
"このセルは繰り返し実行することになるのでCtrl+Retでセルを実行してください。\n",
|
||
"\n",
|
||
"下記のようなテキストが表示されたら起動完了です。\n",
|
||
"\n",
|
||
"**`DEBUG:asyncio:Using selector: EpollSelector`**\n",
|
||
"\n",
|
||
"```\n",
|
||
" Phase name:__main__\n",
|
||
" PHASE3:__main__\n",
|
||
" PHASE1:__main__\n",
|
||
"Start MMVC SocketIO Server\n",
|
||
" CONFIG:None, MODEL:None\n",
|
||
"DEBUG:asyncio:Using selector: EpollSelector\n",
|
||
"```\n",
|
||
"\n"
|
||
],
|
||
"metadata": {
|
||
"id": "-_2OcN9Borke"
|
||
}
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"source": [
|
||
"# (4-1) サーバの起動\n",
|
||
"import random\n",
|
||
"PORT = 10000 + random.randint(1, 9999)\n",
|
||
"LOG_FILE = f\"LOG_FILE_{PORT}\"\n",
|
||
"\n",
|
||
"get_ipython().system_raw(f'python3 MMVCServerSIO.py -t MMVC -p {PORT} --colab True >{LOG_FILE} 2>&1 &')\n",
|
||
"#print(f\"PORT:{PORT}, LOG_FILE:{LOG_FILE}\")"
|
||
],
|
||
"metadata": {
|
||
"id": "G-nMdPxEW1rc"
|
||
},
|
||
"execution_count": 5,
|
||
"outputs": []
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"source": [
|
||
"# (4-2) サーバの起動確認\n",
|
||
"!sleep 30\n",
|
||
"!tail -20 {LOG_FILE}"
|
||
],
|
||
"metadata": {
|
||
"colab": {
|
||
"base_uri": "https://localhost:8080/"
|
||
},
|
||
"id": "chu06KpAjEK6",
|
||
"outputId": "a714391f-616b-44ec-9290-c29246bc773f"
|
||
},
|
||
"execution_count": 6,
|
||
"outputs": [
|
||
{
|
||
"output_type": "stream",
|
||
"name": "stdout",
|
||
"text": [
|
||
"\u001b[32m Phase name:__main__\u001b[0m\n",
|
||
"\u001b[32m PHASE3:__main__\u001b[0m\n",
|
||
"\u001b[32m PHASE1:__main__\u001b[0m\n",
|
||
"\u001b[17mStart MMVC SocketIO Server\u001b[0m\n",
|
||
"\u001b[34m CONFIG:None, MODEL:None ONNX_MODEL:None\u001b[0m\n"
|
||
]
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"source": [
|
||
"# プロキシを起動\n",
|
||
"ウェブサーバへのアクセスをするためのプロキシを起動します。\n",
|
||
"\n",
|
||
"表示されたURLをクリックして開くと別タブでアプリが開きます。\n",
|
||
"\n",
|
||
"Colabなので、ロードにある程度時間がかかります(30秒くらい)。"
|
||
],
|
||
"metadata": {
|
||
"id": "WhxcFLQEpctq"
|
||
}
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"source": [
|
||
"# (5) プロキシを起動\n",
|
||
"from google.colab.output import eval_js\n",
|
||
"proxy = eval_js( \"google.colab.kernel.proxyPort(\" + str(PORT) + \")\" )\n",
|
||
"print(f\"{proxy}front/\")"
|
||
],
|
||
"metadata": {
|
||
"id": "nkRjZm95l87C",
|
||
"colab": {
|
||
"base_uri": "https://localhost:8080/",
|
||
"height": 34
|
||
},
|
||
"outputId": "8ca21533-b852-45d5-ca3c-19f0b5d8bf1f"
|
||
},
|
||
"execution_count": 7,
|
||
"outputs": [
|
||
{
|
||
"output_type": "stream",
|
||
"name": "stdout",
|
||
"text": [
|
||
"https://3n0321xyvvj-496ff2e9c6d22116-11464-colab.googleusercontent.com/front/\n"
|
||
]
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"source": [],
|
||
"metadata": {
|
||
"id": "axkt5BjhoiPV"
|
||
},
|
||
"execution_count": null,
|
||
"outputs": []
|
||
}
|
||
]
|
||
} |