Colab を使用して作成されました

This commit is contained in:
w-okada 2024-06-30 15:42:31 +09:00
parent 4159106430
commit 1c5f3ee2a2

View File

@ -21,8 +21,8 @@
"## READ ME - VERY IMPORTANT\n", "## READ ME - VERY IMPORTANT\n",
"This is an attempt to run [Realtime Voice Changer](https://github.com/w-okada/voice-changer) on Google Colab, still not perfect but is totally usable, you can use the following settings for better results:\n", "This is an attempt to run [Realtime Voice Changer](https://github.com/w-okada/voice-changer) on Google Colab, still not perfect but is totally usable, you can use the following settings for better results:\n",
"\n", "\n",
"If you're using a index: `f0: RMVPE_ONNX | Chunk: 112 or higher | Extra: 8192`\\\n", "If you're using a index: `f0: RMVPE_ONNX | Chunk: 24000 or higher | Extra: 7680`\\\n",
"If you're not using a index: `f0: RMVPE_ONNX | Chunk: 96 or higher | Extra: 16384`\\\n", "If you're not using a index: `f0: RMVPE_ONNX | Chunk: 24000 or higher | Extra: 7680`\\\n",
"**Don't forget to select your Colab GPU in the GPU field (<b>Tesla T4</b>, for free users)*\n", "**Don't forget to select your Colab GPU in the GPU field (<b>Tesla T4</b>, for free users)*\n",
"> Seems that PTH models performance better than ONNX for now, you can still try ONNX models and see if it satisfies you\n", "> Seems that PTH models performance better than ONNX for now, you can still try ONNX models and see if it satisfies you\n",
"\n", "\n",
@ -52,14 +52,14 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 1,
"metadata": { "metadata": {
"id": "W2GYWTHWmRIY", "id": "W2GYWTHWmRIY",
"cellView": "form", "outputId": "e4ce3296-81f9-4004-daf0-219a2977077b",
"outputId": "8ee57273-7774-44b6-a955-2f9408e489f1",
"colab": { "colab": {
"base_uri": "https://localhost:8080/" "base_uri": "https://localhost:8080/"
} },
"cellView": "form"
}, },
"outputs": [ "outputs": [
{ {
@ -71,13 +71,13 @@
"Welcome to ColabMod\n", "Welcome to ColabMod\n",
"Mounted at /content/drive\n", "Mounted at /content/drive\n",
"Checking latest version...\n", "Checking latest version...\n",
"current_version_hash: 1221695f103b2c68f822e61fd5bcfc4c\n", "current_version_hash: eae1b7592ec7c44b88730d2044b7bd9a\n",
"latest_version_hash : \n", "latest_version_hash : de736169a1c6213e63479eda109c1baf\n",
"hash not match -> download latest version\n", "hash not match -> download latest version\n",
" % Total % Received % Xferd Average Speed Time Time Time Current\n", " % Total % Received % Xferd Average Speed Time Time Time Current\n",
" Dload Upload Total Spent Left Speed\n", " Dload Upload Total Spent Left Speed\n",
"100 1155 100 1155 0 0 5130 0 --:--:-- --:--:-- --:--:-- 5133\n", "100 1161 100 1161 0 0 6715 0 --:--:-- --:--:-- --:--:-- 6750\n",
"100 3027M 100 3027M 0 0 69.7M 0 0:00:43 0:00:43 --:--:-- 42.0M\n", "100 3028M 100 3028M 0 0 23.8M 0 0:02:07 0:02:07 --:--:-- 53.9M\n",
"Download is done.\n", "Download is done.\n",
"/content/drive/MyDrive/vcclient\n", "/content/drive/MyDrive/vcclient\n",
"Installing modules... Install is done.\n" "Installing modules... Install is done.\n"
@ -87,7 +87,7 @@
"source": [ "source": [
"#=================Updated=================\n", "#=================Updated=================\n",
"# @title **[1]** Clone repository and install dependencies\n", "# @title **[1]** Clone repository and install dependencies\n",
"# @markdown This first step will download the latest version of Voice Changer and install the dependencies. **It can take some time to complete.(~10min)**\n", "# @markdown This first step will download the latest version of Voice Changer and install the dependencies. **It can take some time to complete.(~5min)**\n",
"\n", "\n",
"#@markdown ---\n", "#@markdown ---\n",
"# @markdown By using Google Drive, you can avoid re-downloading already downloaded versions.\n", "# @markdown By using Google Drive, you can avoid re-downloading already downloaded versions.\n",
@ -193,7 +193,7 @@
" print(f\"Unzip is done.\")\n", " print(f\"Unzip is done.\")\n",
"\n", "\n",
"if mode == \"elf\":\n", "if mode == \"elf\":\n",
" %cd {work_dir}/{latest_version_hash}\n", " %cd {work_dir}\n",
" !chmod 0700 vcclient_latest_for_colab\n", " !chmod 0700 vcclient_latest_for_colab\n",
"elif mode == \"zip\":\n", "elif mode == \"zip\":\n",
" %cd {work_dir}/{latest_version_hash}/main\n", " %cd {work_dir}/{latest_version_hash}/main\n",
@ -209,82 +209,15 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 2,
"metadata": {
"id": "Dbx41M-zlknc",
"cellView": "form",
"outputId": "ae3d8a18-aa4c-4eb2-98aa-11e725cee2bf",
"colab": {
"base_uri": "https://localhost:8080/"
}
},
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"ngrock ready\n"
]
}
],
"source": [
"PORT=8003\n",
"\n",
"import codecs\n",
"\n",
"# @title **[2]** Start ngrock\n",
"# @markdown This cell will start the ngrok.\n",
"\n",
"# @markdown ---\n",
"# @markdown You'll need a ngrok account, but <font color=green>**it's free**</font> and easy to create!\n",
"# @markdown ---\n",
"# @markdown **1** - Create a <font color=green>**free**</font> account at [ngrok](https://dashboard.ngrok.com/signup) or **login with Google/Github account**\\\n",
"# @markdown **2** - If you didn't logged in with Google/Github, you will need to **verify your e-mail**!\\\n",
"# @markdown **3** - Click [this link](https://dashboard.ngrok.com/get-started/your-authtoken) to get your auth token, and place it here:\n",
"Token = '' # @param {type:\"string\"}\n",
"# @markdown **4** - *(optional)* Change to a region near to you or keep at United States if increase latency\\\n",
"# @markdown `Default Region: ap - Asia/Pacific (Singapore)`\n",
"Region = \"jp - Japan (Tokyo)\" # @param [\"ap - Asia/Pacific (Singapore)\", \"au - Australia (Sydney)\",\"eu - Europe (Frankfurt)\", \"in - India (Mumbai)\",\"jp - Japan (Tokyo)\",\"sa - South America (Sao Paulo)\", \"us - United States (Ohio)\"]\n",
"\n",
"#@markdown **5** - *(optional)* Other options:\n",
"ClearConsole = True # @param {type:\"boolean\"}\n",
"Play_Notification = False # @param {type:\"boolean\"}\n",
"\n",
"# ---------------------------------\n",
"# DO NOT TOUCH ANYTHING DOWN BELOW!\n",
"# ---------------------------------\n",
"\n",
"# Check if Run_Cell\n",
"if 'Run_Cell' not in globals():\n",
" print(\"No, Go back to the first cell and run it\")\n",
" exit\n",
"if Run_Cell == 0:\n",
" print(\"No, Go back to the first cell and run it\")\n",
" exit\n",
"\n",
"\n",
"from pyngrok import conf, ngrok\n",
"MyConfig = conf.PyngrokConfig()\n",
"MyConfig.auth_token = Token\n",
"MyConfig.region = Region[0:2]\n",
"conf.set_default(MyConfig);\n",
"\n",
"from pyngrok import ngrok\n",
"ngrokConnection = ngrok.connect(PORT)\n",
"public_url = ngrokConnection.public_url\n",
"print(f\"ngrock ready\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": { "metadata": {
"id": "s7mYqKtW6VOI", "id": "s7mYqKtW6VOI",
"cellView": "form", "outputId": "e86ad79b-cb62-4ea5-a8d9-dc7b9ca9e6ed",
"outputId": "afa5d810-4904-4422-967e-54ba1642d01a",
"colab": { "colab": {
"base_uri": "https://localhost:8080/" "base_uri": "https://localhost:8080/",
} "height": 148
},
"cellView": "form"
}, },
"outputs": [ "outputs": [
{ {
@ -292,17 +225,48 @@
"name": "stdout", "name": "stdout",
"text": [ "text": [
"--------- SERVER READY! ---------\n", "--------- SERVER READY! ---------\n",
"Your server is available. elapsed: 145sec\n", "Your server is available. elapsed: 173sec\n",
"https://ae1e-34-125-45-231.ngrok-free.app\n", "https://2bj201er26o-496ff2e9c6d22116-8003-colab.googleusercontent.com/\n",
"---------------------------------\n" "---------------------------------\n"
] ]
},
{
"output_type": "display_data",
"data": {
"text/plain": [
"<IPython.lib.display.Audio object>"
],
"text/html": [
"\n",
" <audio controls=\"controls\" autoplay=\"autoplay\">\n",
" <source src=\"https://huggingface.co/wok000/voices/resolve/main/vcclient001_vctk229_gpt-sovits_vcclient-ready.wav\" type=\"audio/x-wav\" />\n",
" Your browser does not support the audio element.\n",
" </audio>\n",
" "
]
},
"metadata": {}
} }
], ],
"source": [ "source": [
"# @title **[3]** Start server\n", "# @title **[2]** Start server\n",
"# @markdown This cell will start the server, the first time that you run it will download the models, so it can take a while (~1-2 minutes)\n", "# @markdown This cell will start the server, the first time that you run it will download the models, so it can take a while (2~4 minutes)\n",
"\n",
"#@markdown - Options:\n",
"ClearConsole = True # @param {type:\"boolean\"}\n",
"Play_Notification = True # @param {type:\"boolean\"}\n",
"\n",
"PORT=8003\n",
"\n", "\n",
"LOG_FILE = f\"/content/LOG_FILE_{PORT}\"\n", "LOG_FILE = f\"/content/LOG_FILE_{PORT}\"\n",
"\n",
"from IPython.display import Audio, display\n",
"def play_notification_sound(url):\n",
" display(Audio(url=url, autoplay=True))\n",
"\n",
"from google.colab.output import eval_js\n",
"\n",
"\n",
"if mode == \"elf\":\n", "if mode == \"elf\":\n",
" # !LD_LIBRARY_PATH=/usr/lib64-nvidia:/usr/lib/x86_64-linux-gnu ./vcclient_latest_for_colab cui --port {PORT} --no_cui true &\n", " # !LD_LIBRARY_PATH=/usr/lib64-nvidia:/usr/lib/x86_64-linux-gnu ./vcclient_latest_for_colab cui --port {PORT} --no_cui true &\n",
"\n", "\n",
@ -341,28 +305,20 @@
" clear_output()\n", " clear_output()\n",
" print(\"--------- SERVER READY! ---------\")\n", " print(\"--------- SERVER READY! ---------\")\n",
" print(f\"Your server is available. elapsed: {elapsed_time}sec\")\n", " print(f\"Your server is available. elapsed: {elapsed_time}sec\")\n",
" print(public_url)\n", " proxy = eval_js( \"google.colab.kernel.proxyPort(\" + str(PORT) + \")\" )\n",
" print(f\"{proxy}\")\n",
" print(\"---------------------------------\")\n", " print(\"---------------------------------\")\n",
" # if Play_Notification==True:\n", " if Play_Notification==True:\n",
" # play_notification_sound()\n", " play_notification_sound('https://huggingface.co/wok000/voices/resolve/main/vcclient001_vctk229_gpt-sovits_vcclient-ready.wav')\n",
"wait_for_server()\n" "wait_for_server()\n"
] ]
},
{
"cell_type": "code",
"source": [],
"metadata": {
"id": "WpjWNYwNXydp"
},
"execution_count": null,
"outputs": []
} }
], ],
"metadata": { "metadata": {
"colab": { "colab": {
"provenance": [], "provenance": [],
"gpuType": "T4", "gpuType": "T4",
"authorship_tag": "ABX9TyO6EVNYbFuRgZrxgqHQjwuH", "authorship_tag": "ABX9TyO4xBCjHQ5g0B28Cfbnr1eo",
"include_colab_link": true "include_colab_link": true
}, },
"kernelspec": { "kernelspec": {