2022-08-31 09:21:16 +03:00
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "VoiceChangerDemo",
"provenance": [],
2023-08-26 10:40:09 +03:00
"authorship_tag": "ABX9TyPFsamraQogYywSbvGGKbNM",
2022-08-31 09:21:16 +03:00
"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": [
2023-08-26 10:40:09 +03:00
"<a href=\"https://colab.research.google.com/github/w-okada/voice-changer/blob/master/VoiceChangerDemo.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
2022-08-31 09:21:16 +03:00
]
},
2023-08-26 10:40:09 +03:00
{
"cell_type": "markdown",
"source": [
"# このノートブックは管理されていません。\n",
"# VCClientをColabで使用する場合は、次のノ ートブックをご使用ください。\n",
"\n",
"# This notebook is not being managed.\n",
"# If you're using VCClient in Colab, please use the following notebook.\n",
"\n",
"https://github.com/w-okada/voice-changer/blob/master/Realtime_Voice_Changer_on_Colab.ipynb\n",
"\n"
],
"metadata": {
"id": "Vm9wBO9-xWFP"
}
},
2022-08-31 09:27:34 +03:00
{
2022-08-31 09:59:55 +03:00
"cell_type": "markdown",
2022-08-31 09:27:34 +03:00
"source": [
2022-12-04 15:45:59 +03:00
"MMVCプレイヤー( 普通版) \n",
2022-08-31 09:59:55 +03:00
"---\n",
"\n",
2022-12-04 15:45:59 +03:00
"このノ ートはColab上でMMVCのボイチェンを行うノ ートです。\n",
2022-08-31 09:59:55 +03:00
"\n",
2023-01-30 00:25:34 +03:00
"正式版はローカルPC上で動かすアプリケーションです。\n",
2022-08-31 09:59:55 +03:00
"\n",
"正式版は、多くの場合より少ないタイムラグで滑らかに音声を変換できます。\n",
"\n",
2022-08-31 13:55:50 +03:00
"詳細な使用方法はこちらの[リポジトリ](https://github.com/w-okada/voice-changer)からご確認ください。\n"
2022-08-31 09:27:34 +03:00
],
"metadata": {
2022-08-31 09:59:55 +03:00
"id": "Lbbmx_Vjl0zo"
}
2022-08-31 09:27:34 +03:00
},
2022-08-31 09:21:16 +03:00
{
"cell_type": "markdown",
2022-08-31 09:59:55 +03:00
"source": [
"# GPUを確認\n",
"GPUを用いたほうが高速に処理が行えます。\n",
"\n",
"下記のコマンドでGPUが確認できない場合は、上のメニューから\n",
"\n",
"「ランタイム」→「ランタイムの変更」→「ハードウェア アクセラレータ」\n",
"\n",
"でGPUを選択してください。"
],
2022-08-31 09:21:16 +03:00
"metadata": {
2022-08-31 09:59:55 +03:00
"id": "oUKi1NYMmXrr"
2022-08-31 09:21:16 +03:00
}
},
{
"cell_type": "code",
"source": [
2022-08-31 09:59:55 +03:00
"# (1) GPUの確認\n",
2022-08-31 09:21:16 +03:00
"!nvidia-smi"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "vV1t7PBRm-o6",
2023-01-29 15:13:48 +03:00
"outputId": "de727091-7c9f-4dbc-a0cc-5985409b289f"
2022-08-31 09:21:16 +03:00
},
2023-01-30 00:25:34 +03:00
"execution_count": null,
2022-08-31 09:21:16 +03:00
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
2023-01-29 15:13:48 +03:00
"Sun Jan 29 12:09:35 2023 \n",
2022-08-31 09:21:16 +03:00
"+-----------------------------------------------------------------------------+\n",
2023-01-29 15:13:48 +03:00
"| NVIDIA-SMI 510.47.03 Driver Version: 510.47.03 CUDA Version: 11.6 |\n",
2022-08-31 09:21:16 +03:00
"|-------------------------------+----------------------+----------------------+\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",
2023-01-29 15:13:48 +03:00
"| N/A 47C P0 26W / 70W | 0MiB / 15360MiB | 0% Default |\n",
2022-08-31 09:21:16 +03:00
"| | | 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"
]
}
]
},
2022-08-31 09:59:55 +03:00
{
"cell_type": "markdown",
"source": [
"# 使用するモデルとコンフィグファイルの指定\n",
"\n",
"使用するトレーニング済みのモデルと、トレーニングで使用したコンフィグファイルのパスを指定してください。\n",
"\n",
"多くの場合はGoogle Driveに格納されているファイルを使用すると思います。その場合は、下の(2-2)のセルを実行してドライブをマウントしてください"
],
"metadata": {
"id": "mHvGrgaWnIPA"
}
},
2022-08-31 09:21:16 +03:00
{
"cell_type": "code",
"source": [
2022-08-31 09:59:55 +03:00
"# (2-1) 使用するモデルとコンフィグファイルの指定\n",
2023-01-12 12:33:47 +03:00
"if \"MODEL\" in locals():\n",
" del MODEL\n",
"if \"ONNX\" in locals():\n",
" del ONNX\n",
"\n",
2022-08-31 09:21:16 +03:00
"CONFIG=\"/content/drive/MyDrive/VoiceChanger/config.json\"\n",
2023-01-12 12:33:47 +03:00
"#MODEL=\"/content/drive/MyDrive/VoiceChanger/G_326000.pth\"\n",
"ONNX=\"/content/drive/MyDrive/VoiceChanger/G_326000.onnx\""
2022-08-31 09:21:16 +03:00
],
"metadata": {
"id": "nSXATMWYb4Ik"
},
2023-01-30 00:25:34 +03:00
"execution_count": null,
2022-08-31 09:21:16 +03:00
"outputs": []
},
{
"cell_type": "code",
2023-01-30 00:25:34 +03:00
"execution_count": null,
2022-08-31 09:21:16 +03:00
"metadata": {
2022-08-31 09:59:55 +03:00
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "2wxD-gRSMU5R",
2023-01-29 15:13:48 +03:00
"outputId": "4c9da537-a5cb-4c5d-f999-2795b00d41a8"
2022-08-31 09:21:16 +03:00
},
2022-08-31 09:59:55 +03:00
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Mounted at /content/drive\n"
]
}
],
2022-08-31 09:21:16 +03:00
"source": [
2022-08-31 09:59:55 +03:00
"# (2-2) Google Driveのマウント\n",
2022-08-31 09:21:16 +03:00
"from google.colab import drive\n",
"drive.mount('/content/drive')"
]
},
2022-08-31 09:59:55 +03:00
{
"cell_type": "markdown",
"source": [
"# リポジトリのクローン\n",
"リポジトリをクローンします"
],
"metadata": {
"id": "sLBfykjBnjWc"
}
},
2022-08-31 09:21:16 +03:00
{
"cell_type": "code",
"source": [
2022-08-31 09:59:55 +03:00
"# (3) リポジトリのクローン\n",
2023-01-29 15:13:48 +03:00
"!git clone --depth 1 https://github.com/w-okada/voice-changer.git -b v.1.3.7\n",
2023-01-12 12:33:47 +03:00
"%cd voice-changer/server\n",
2023-01-14 01:23:18 +03:00
"!git clone https://github.com/isletennos/MMVC_Client.git\n",
"!cd MMVC_Client && git checkout 04f3fec4fd82dea6657026ec4e1cd80fb29a415c && cd -"
2022-08-31 09:21:16 +03:00
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "86wTFmqsNMnD",
2023-01-29 15:13:48 +03:00
"outputId": "2b329892-41b2-4560-e4f0-ab49b4ef83bc"
2022-08-31 09:21:16 +03:00
},
2023-01-30 00:25:34 +03:00
"execution_count": null,
2022-08-31 09:21:16 +03:00
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Cloning into 'voice-changer'...\n",
2023-01-29 15:13:48 +03:00
"remote: Enumerating objects: 157, done.\u001b[K\n",
"remote: Counting objects: 100% (157/157), done.\u001b[K\n",
"remote: Compressing objects: 100% (141/141), done.\u001b[K\n",
"remote: Total 157 (delta 21), reused 70 (delta 5), pack-reused 0\u001b[K\n",
"Receiving objects: 100% (157/157), 1.61 MiB | 4.03 MiB/s, done.\n",
"Resolving deltas: 100% (21/21), done.\n",
"/content/voice-changer/server\n",
"Cloning into 'MMVC_Client'...\n",
"remote: Enumerating objects: 611, done.\u001b[K\n",
"remote: Counting objects: 100% (337/337), done.\u001b[K\n",
"remote: Compressing objects: 100% (120/120), done.\u001b[K\n",
"remote: Total 611 (delta 238), reused 285 (delta 214), pack-reused 274\u001b[K\n",
"Receiving objects: 100% (611/611), 752.38 KiB | 21.50 MiB/s, done.\n",
"Resolving deltas: 100% (360/360), done.\n",
"Note: switching to '04f3fec4fd82dea6657026ec4e1cd80fb29a415c'.\n",
2023-01-14 14:00:44 +03:00
"\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",
2023-01-29 15:13:48 +03:00
"state without impacting any branches by switching back to a branch.\n",
2023-01-14 14:00:44 +03:00
"\n",
"If you want to create a new branch to retain commits you create, you may\n",
2023-01-29 15:13:48 +03:00
"do so (now or later) by using -c with the switch command. Example:\n",
2023-01-14 14:00:44 +03:00
"\n",
2023-01-29 15:13:48 +03:00
" git switch -c <new-branch-name>\n",
2022-12-09 04:47:54 +03:00
"\n",
2023-01-29 15:13:48 +03:00
"Or undo this operation with:\n",
2022-12-09 04:47:54 +03:00
"\n",
2023-01-29 15:13:48 +03:00
" git switch -\n",
2022-12-09 04:47:54 +03:00
"\n",
2023-01-29 15:13:48 +03:00
"Turn off this advice by setting config variable advice.detachedHead to false\n",
2022-12-09 04:47:54 +03:00
"\n",
2023-01-14 01:23:18 +03:00
"HEAD is now at 04f3fec Merge pull request #30 from Mokuichi147/setupcheck\n",
2023-01-12 12:33:47 +03:00
"/content/voice-changer/server\n"
2022-08-31 09:21:16 +03:00
]
}
]
},
{
"cell_type": "markdown",
"source": [
2022-08-31 09:59:55 +03:00
"# モジュールのインストール\n",
2022-08-31 09:21:16 +03:00
"\n",
2022-08-31 09:59:55 +03:00
"必要なモジュールをインストールします。"
2022-08-31 09:21:16 +03:00
],
"metadata": {
"id": "8Na2PbLZSWgZ"
}
},
{
"cell_type": "code",
"source": [
2022-08-31 09:59:55 +03:00
"# (5) 設定ファイルの確認\n",
2023-01-14 01:23:18 +03:00
"!apt-get install -y libsndfile1-dev &> /dev/null\n",
2022-11-04 01:34:37 +03:00
"!pip install fastapi &> /dev/null\n",
2023-01-14 01:23:18 +03:00
"!pip install pyOpenSSL &> /dev/null\n",
2022-11-04 01:34:37 +03:00
"!pip install python-multipart &> /dev/null\n",
2023-01-14 01:23:18 +03:00
"!pip install python-socketio &> /dev/null\n",
2022-11-04 01:34:37 +03:00
"!pip install uvicorn &> /dev/null\n",
"!pip install websockets &> /dev/null\n",
2023-01-12 12:33:47 +03:00
"!pip install onnxruntime-gpu &> /dev/null"
2022-08-31 09:21:16 +03:00
],
"metadata": {
2022-11-04 01:34:37 +03:00
"id": "LwZAAuqxX7yY"
2022-08-31 09:21:16 +03:00
},
2023-01-30 00:25:34 +03:00
"execution_count": null,
2022-11-04 01:34:37 +03:00
"outputs": []
2022-08-31 09:21:16 +03:00
},
2022-08-31 09:59:55 +03:00
{
"cell_type": "markdown",
"source": [
"# サーバの起動\n",
"\n",
"サーバを起動します。(6-1)\n",
"\n",
2023-08-26 10:40:09 +03:00
"サーバの起動状況を確認します。(6-2)\n",
2022-08-31 09:59:55 +03:00
"\n",
"このセルは繰り返し実行することになるのでCtrl+Retでセルを実行してください。\n",
"\n",
"アクセスできるようになるまで、1~2分かかるようです。コーヒーでも飲みに行きましょう。\n",
"\n",
"下記のようなテキストが表示されたら起動完了です。\n",
2023-01-14 14:00:44 +03:00
"(warningは無視して問題ありません。)\n",
2022-08-31 09:59:55 +03:00
"```\n",
2023-01-14 14:00:44 +03:00
"/usr/local/lib/python3.8/dist-packages/onnxruntime/capi/onnxruntime_inference_collection.py:54: UserWarning: Specified provider 'OpenVINOExecutionProvider' is not in available provider names.Available providers: 'TensorrtExecutionProvider, CUDAExecutionProvider, CPUExecutionProvider'\n",
" warnings.warn(\n",
"/usr/local/lib/python3.8/dist-packages/onnxruntime/capi/onnxruntime_inference_collection.py:54: UserWarning: Specified provider 'DmlExecutionProvider' is not in available provider names.Available providers: 'TensorrtExecutionProvider, CUDAExecutionProvider, CPUExecutionProvider'\n",
2023-01-12 12:44:23 +03:00
" warnings.warn(\n",
2023-01-12 12:33:47 +03:00
"VoiceChanger Initialized (GPU_NUM:1, mps_enabled:False)\n",
2023-01-14 14:00:44 +03:00
" Voice Changerを起動しています。\n",
2023-08-26 10:40:09 +03:00
" -- 設定 --\n",
2023-01-30 00:25:34 +03:00
" CONFIG:/content/drive/MyDrive/VoiceChanger/config.json, MODEL:None ONNX_MODEL:/content/drive/MyDrive/VoiceChanger/G_326000.onnx\n",
"```\n",
2022-08-31 09:59:55 +03:00
"\n"
],
"metadata": {
"id": "-_2OcN9Borke"
}
},
2022-08-31 09:21:16 +03:00
{
"cell_type": "code",
"source": [
2022-08-31 09:59:55 +03:00
"# (6-1) サーバの起動\n",
2022-11-04 01:34:37 +03:00
"import random\n",
"PORT = 10000 + random.randint(1, 9999)\n",
"LOG_FILE = f\"LOG_FILE_{PORT}\"\n",
"\n",
2023-01-12 12:33:47 +03:00
"if \"MODEL\" in locals() and \"ONNX\" in locals():\n",
" model_param = f\" -m {MODEL} -o {ONNX}\"\n",
"elif \"MODEL\" in locals():\n",
" model_param = f\" -m {MODEL}\"\n",
"elif \"ONNX\" in locals():\n",
" model_param = f\" -o {ONNX}\"\n",
"else:\n",
" model_param = f\"\"\n",
"\n",
2023-01-14 14:00:44 +03:00
"get_ipython().system_raw(f'python3 MMVCServerSIO.py -t MMVC -p {PORT} -c {CONFIG} {model_param} --https False --colab True >{LOG_FILE} 2>&1 &')\n",
2022-11-04 01:34:37 +03:00
"#print(f\"PORT:{PORT}, LOG_FILE:{LOG_FILE}\")"
2022-08-31 09:21:16 +03:00
],
"metadata": {
2023-01-12 12:44:23 +03:00
"id": "iNOAB7zISI6J"
2022-08-31 09:21:16 +03:00
},
2023-01-30 00:25:34 +03:00
"execution_count": null,
2023-01-12 12:44:23 +03:00
"outputs": []
2022-08-31 09:21:16 +03:00
},
{
"cell_type": "code",
"source": [
2022-08-31 09:59:55 +03:00
"# (6-2) サーバの起動確認 (Ctrl+Retで実行)\n",
2022-11-04 01:34:37 +03:00
"!tail -20 {LOG_FILE}"
2022-08-31 09:21:16 +03:00
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "chu06KpAjEK6",
2023-01-29 15:13:48 +03:00
"outputId": "cf0d26f3-66a9-406e-e739-f588483d2851"
2022-08-31 09:21:16 +03:00
},
2023-01-30 00:25:34 +03:00
"execution_count": null,
2022-08-31 09:21:16 +03:00
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
2023-01-12 12:44:23 +03:00
"/usr/local/lib/python3.8/dist-packages/onnxruntime/capi/onnxruntime_inference_collection.py:54: UserWarning: Specified provider 'OpenVINOExecutionProvider' is not in available provider names.Available providers: 'TensorrtExecutionProvider, CUDAExecutionProvider, CPUExecutionProvider'\n",
" warnings.warn(\n",
"/usr/local/lib/python3.8/dist-packages/onnxruntime/capi/onnxruntime_inference_collection.py:54: UserWarning: Specified provider 'DmlExecutionProvider' is not in available provider names.Available providers: 'TensorrtExecutionProvider, CUDAExecutionProvider, CPUExecutionProvider'\n",
" warnings.warn(\n",
2023-01-14 14:00:44 +03:00
"VoiceChanger Initialized (GPU_NUM:1, mps_enabled:False)\n",
"\u001b[32m Voice Changerを起動しています。\u001b[0m\n",
"\u001b[34m -- 設定 -- \u001b[0m\n",
"\u001b[34m CONFIG:/content/drive/MyDrive/VoiceChanger/config.json, MODEL:None ONNX_MODEL:/content/drive/MyDrive/VoiceChanger/G_326000.onnx\u001b[0m\n"
2022-08-31 09:21:16 +03:00
]
}
]
},
2022-08-31 09:59:55 +03:00
{
"cell_type": "markdown",
"source": [
"# プロキシを起動\n",
"ウェブサーバへのアクセスをするためのプロキシを起動します。\n",
"\n",
2022-09-02 06:11:05 +03:00
"表示されたURLをクリックして開くと別タブでアプリが開きます。\n",
2022-08-31 09:59:55 +03:00
"\n",
2022-09-02 06:11:05 +03:00
"Colabなので、ロードにある程度時間がかかります(30秒くらい)。"
2022-08-31 09:59:55 +03:00
],
"metadata": {
"id": "WhxcFLQEpctq"
}
},
2022-08-31 09:21:16 +03:00
{
"cell_type": "code",
"source": [
2022-08-31 09:59:55 +03:00
"# (7) プロキシを起動\n",
2022-09-19 00:01:50 +03:00
"from google.colab.output import eval_js\n",
"proxy = eval_js( \"google.colab.kernel.proxyPort(\" + str(PORT) + \")\" )\n",
2023-01-12 12:44:23 +03:00
"print(f\"{proxy}front/?colab=true\")"
2022-08-31 09:21:16 +03:00
],
"metadata": {
"id": "nkRjZm95l87C",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 34
},
2023-01-29 15:13:48 +03:00
"outputId": "b6ef1db3-37b4-4025-fdbf-711e00646902"
2022-08-31 09:21:16 +03:00
},
2023-01-30 00:25:34 +03:00
"execution_count": null,
2022-10-28 14:01:34 +03:00
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
2023-01-29 15:13:48 +03:00
"https://nafdn2dmorn-496ff2e9c6d22116-18341-colab.googleusercontent.com/front/?colab=true\n"
2022-10-28 14:01:34 +03:00
]
}
]
2022-12-03 13:51:13 +03:00
},
{
"cell_type": "code",
"source": [],
"metadata": {
"id": "Jos5WZHGmz4s"
},
"execution_count": null,
"outputs": []
2022-08-31 09:21:16 +03:00
}
]
}