voice-changer/VoiceChangerDemo_Simple.ipynb

330 lines
12 KiB
Plaintext
Raw Normal View History

{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"provenance": [],
"authorship_tag": "ABX9TyMxmV4RpK/p2+W+xEK9aM2U",
"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": "785be88d-b741-4824-8b99-6863d172fa3b"
},
"execution_count": 1,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Sun Jan 29 12:17:09 2023 \n",
"+-----------------------------------------------------------------------------+\n",
"| NVIDIA-SMI 510.47.03 Driver Version: 510.47.03 CUDA Version: 11.6 |\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 67C P0 30W / 70W | 0MiB / 15360MiB | 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.7\n",
"%cd voice-changer/server\n",
"!git clone https://github.com/isletennos/MMVC_Client.git\n",
"!cd MMVC_Client && git checkout 04f3fec4fd82dea6657026ec4e1cd80fb29a415c && cd -\n"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "86wTFmqsNMnD",
"outputId": "b0bd865c-acec-47e5-b309-ac7fb6906f97"
},
"execution_count": 2,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Cloning into 'voice-changer'...\n",
"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 | 1.90 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 | 875.00 KiB/s, done.\n",
"Resolving deltas: 100% (360/360), done.\n",
"Note: switching to '04f3fec4fd82dea6657026ec4e1cd80fb29a415c'.\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 switching back to a branch.\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 -c with the switch command. Example:\n",
"\n",
" git switch -c <new-branch-name>\n",
"\n",
"Or undo this operation with:\n",
"\n",
" git switch -\n",
"\n",
"Turn off this advice by setting config variable advice.detachedHead to false\n",
"\n",
"HEAD is now at 04f3fec Merge pull request #30 from Mokuichi147/setupcheck\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 fastapi &> /dev/null\n",
"!pip install pyOpenSSL &> /dev/null\n",
"!pip install python-multipart &> /dev/null\n",
"!pip install python-socketio &> /dev/null\n",
"!pip install uvicorn &> /dev/null\n",
"!pip install websockets &> /dev/null\n",
"!pip install onnxruntime-gpu &> /dev/null\n"
],
"metadata": {
"id": "LwZAAuqxX7yY"
},
"execution_count": 3,
"outputs": []
},
{
"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",
" Voice Changerを起動しています。\n",
" -- 設定 -- \n",
" CONFIG:None, MODEL:None ONNX_MODEL:None\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} --https False --colab True >{LOG_FILE} 2>&1 &')\n",
"#print(f\"PORT:{PORT}, LOG_FILE:{LOG_FILE}\")"
],
"metadata": {
"id": "G-nMdPxEW1rc"
},
"execution_count": 4,
"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": "a9cb8947-3902-43ba-c3b9-e5857c0cc7b6"
},
"execution_count": 5,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"VoiceChanger Initialized (GPU_NUM:1, mps_enabled:False)\n",
"\u001b[32m Voice Changerを起動しています。\u001b[0m\n",
"\u001b[34m -- 設定 -- \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/?colab=true\")"
],
"metadata": {
"id": "nkRjZm95l87C",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 34
},
"outputId": "5c2ff7a0-f10a-46b9-eaec-96d1874e255f"
},
"execution_count": 6,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"https://xzok7khbzs-496ff2e9c6d22116-13279-colab.googleusercontent.com/front/?colab=true\n"
]
}
]
},
{
"cell_type": "code",
"source": [],
"metadata": {
"id": "axkt5BjhoiPV"
},
"execution_count": 6,
"outputs": []
}
]
}