forked from w-okada/voice-changer
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Kaggle Notebook | Voice Changer (Public) | Version 12
- Loading branch information
Showing
1 changed file
with
1 addition
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"metadata":{"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.12"}},"nbformat_minor":4,"nbformat":4,"cells":[{"source":"<a href=\"https://www.kaggle.com/code/suneku/voice-changer-public?scriptVersionId=191573360\" target=\"_blank\"><img align=\"left\" alt=\"Kaggle\" title=\"Open in Kaggle\" src=\"https://kaggle.com/static/images/open-in-kaggle.svg\"></a>","metadata":{},"cell_type":"markdown"},{"cell_type":"markdown","source":"### [w-okada's Voice Changer](https://github.com/deiteris/voice-changer) | **Kaggle**\n\n---\n\n## **⬇ VERY IMPORTANT ⬇**\n\nYou can use the following settings for optimal results:\n\nBest performance: `f0: fcpe | Chunk: 56.0ms or higher | Extra: 2.7s`<br>\nBest quality: `f0: rmvpe | Chunk: 64.0ms or higher | Extra: 5s`<br>\n**Don't forget to select a GPU in the GPU field, <b>NEVER</b> use CPU!\n\nYou can tune `Chunk` for lower/higher delay and `Extra` for better quality.\n\n---\n**Credits**<br>\nRealtime Voice Changer by [w-okada](https://github.com/w-okada)<br>\nOriginal instructions by [Hina](https://github.com/HinaBl)<br>\n\n**Need help?** [AI Hub Discord](https://discord.gg/aihub) » ***#help-realtime-vc***\n\n---","metadata":{"id":"Lbbmx_Vjl0zo"}},{"cell_type":"markdown","source":"# Kaggle Tutorial\nRunning this notebook can be a bit complicated.\\\nAfter created your Kaggle account, you'll need to **verify your phone number** to be able to use Internet Connection and GPUs.\n\nFollow the instructions on the image below and don't forget to set **PERSISTENCE** to **Files only**.\n\n![instructions.png](https://i.imgur.com/0NutkD8.png)","metadata":{}},{"cell_type":"markdown","source":"# Clone repository and install dependencies\nThis first step will download the latest version of Voice Changer and install the dependencies. **It will take some time to complete.**","metadata":{}},{"cell_type":"code","source":"# This will make that we're on the right folder before installing\n%cd /kaggle/working/\n\n# To workaround an issue with METADATA not found for aiohttp\n# !conda install -y aiohttp\n!pip install colorama python-dotenv pyngrok --quiet\n\nfrom colorama import Fore, Style\nimport requests, os\n\nprint(f\"{Fore.CYAN}> Downloading prebuilt executable...{Style.RESET_ALL}\")\n\ndef download_and_unpack(assets: list[dict]):\n for asset in assets:\n if not asset['name'].startswith('voice-changer-linux-amd64-cuda.tar.gz'):\n continue\n download_url = asset['browser_download_url']\n !wget -q --show-progress {download_url}\n\n print(f\"{Fore.GREEN}> Unpacking...{Style.RESET_ALL}\")\n !cat voice-changer-linux-amd64-cuda.tar.gz.* | tar xzf -\n print(f\"{Fore.GREEN}> Finished unpacking!{Style.RESET_ALL}\")\n !rm -rf voice-changer-linux-amd64-cuda.tar.gz.*\n\n !mv /kaggle/working/MMVCServerSIO/MMVCServerSIO /kaggle/working/MMVCServerSIO/VoiceChanger\n\ndef get_local_version(base: str) -> str:\n local_version = !cat {base}/_internal/version.txt\n return local_version[0].strip()\n\nres = requests.get('https://api.github.com/repos/deiteris/voice-changer/releases/latest')\nrelease_info = res.json()\n\nremote_version = release_info['tag_name']\n# Check and upgrade\nif os.path.exists('MMVCServerSIO'):\n local_version = get_local_version(\"/kaggle/working/MMVCServerSIO\")\n if remote_version != local_version:\n print(f\"{Fore.CYAN}> Found new version. Current version {local_version}, remote version {remote_version}. Upgrading...{Style.RESET_ALL}\")\n !rm -rf /kaggle/working/MMVCServerSIO/_internal /kaggle/working/MMVCServerSIO/VoiceChanger /kaggle/working/MMVCServerSIO/MMVCServerSIO\n download_and_unpack(release_info['assets'])\n else:\n print(f\"{Fore.CYAN}> Current version {local_version} is the latest. Skipping download.{Style.RESET_ALL}\")\nelse:\n print(f\"{Fore.CYAN}> Downloading and installing version {remote_version}.{Style.RESET_ALL}\")\n download_and_unpack(release_info['assets'])\n\n%cd MMVCServerSIO\n\nprint(f\"{Fore.CYAN}> Installing libportaudio2...{Style.RESET_ALL}\")\n!apt-get -y install libportaudio2 -qq\nprint(f\"{Fore.CYAN}> Done! Proceed with the next steps.{Style.RESET_ALL}\")","metadata":{"_kg_hide-output":false,"cellView":"form","execution":{"iopub.execute_input":"2023-09-14T04:01:17.308682Z","iopub.status.busy":"2023-09-14T04:01:17.308284Z","iopub.status.idle":"2023-09-14T04:08:08.475375Z","shell.execute_reply":"2023-09-14T04:08:08.473827Z","shell.execute_reply.started":"2023-09-14T04:01:17.308652Z"},"id":"86wTFmqsNMnD","trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Migrate the data\n\nThis cell will migrate your models from old version to new version (if present).","metadata":{}},{"cell_type":"code","source":"# Migrate old data to new version and delete old version\nif os.path.exists(\"/kaggle/working/Hmod\"):\n !mv /kaggle/working/Hmod/server/model_dir /kaggle/working/MMVCServerSIO/model_dir\n !mv /kaggle/working/Hmod/server/pretrain /kaggle/working/MMVCServerSIO/pretrain\n !rm -rf /kaggle/working/Hmod","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Configure the server\n\nThis cell will apply necessary configuration to the server.","metadata":{}},{"cell_type":"code","source":"%cd /kaggle/working/MMVCServerSIO\n\nfrom dotenv import set_key\n\nset_key('.env', \"SAMPLE_MODE\", \"\")\n\nReady = True","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Start Server **using ngrok**\nThis 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\n---\nYou'll need a ngrok account, but <font color=green>**it's free**</font> and easy to create!\n---\n**1** - Create a **free** account at [ngrok](https://dashboard.ngrok.com/signup)\\\n**2** - If you didn't logged in with Google or Github, you will need to **verify your e-mail**!\\\n**3** - Click [this link](https://dashboard.ngrok.com/get-started/your-authtoken) to get your auth token, and replace **TOKEN_HERE** with your token.\\\n**4** - *(optional)* Change to a region near to you","metadata":{}},{"cell_type":"code","source":"Token = 'TOKEN_HERE'\nRegion = \"eu\" # Read the instructions below\nClearConsole = True\n\n# You can change the region for a better latency, use only the abbreviation\n# Choose between this options:\n# us -> United States (Ohio)\n# ap -> Asia/Pacific (Singapore)\n# au -> Australia (Sydney)\n# eu -> Europe (Frankfurt)\n# in -> India (Mumbai)\n# jp -> Japan (Tokyo)\n# sa -> South America (Sao Paulo)\n\n# ---------------------------------\n# DO NOT TOUCH ANYTHING DOWN BELOW!\n\n%cd /kaggle/working/MMVCServerSIO\n\nif not globals().get('Ready', False):\n print(\"Go back and run first and second cells.\")\nelse:\n from pyngrok import conf, ngrok\n MyConfig = conf.PyngrokConfig()\n MyConfig.auth_token = Token\n MyConfig.region = Region[0:2]\n conf.get_default().authtoken = Token\n conf.get_default().region = Region\n conf.set_default(MyConfig);\n\n import threading, time, socket\n PORT = 18888\n\n import json\n from pyngrok import ngrok\n from IPython.display import clear_output\n\n ngrokConnection = ngrok.connect(PORT)\n public_url = ngrokConnection.public_url\n set_key('.env', \"ALLOWED_ORIGINS\", json.dumps([public_url]))\n\n def wait_for_server():\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 if ClearConsole:\n clear_output()\n print(\"--------- SERVER READY! ---------\")\n print(\"Your server is available at:\")\n print(public_url)\n print(\"---------------------------------\")\n\n threading.Thread(target=wait_for_server, daemon=True).start()\n\n !./VoiceChanger\n\n ngrok.disconnect(ngrokConnection.public_url)","metadata":{"_kg_hide-input":false,"cellView":"form","id":"lLWQuUd7WW9U","scrolled":true,"trusted":true},"execution_count":null,"outputs":[]}]} | ||
{"metadata":{"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.12"},"kaggle":{"accelerator":"none","dataSources":[],"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"source":"<a href=\"https://www.kaggle.com/code/suneku/voice-changer-public?scriptVersionId=192894928\" target=\"_blank\"><img align=\"left\" alt=\"Kaggle\" title=\"Open in Kaggle\" src=\"https://kaggle.com/static/images/open-in-kaggle.svg\"></a>","metadata":{},"cell_type":"markdown"},{"cell_type":"markdown","source":"### [w-okada's Voice Changer](https://github.com/deiteris/voice-changer) | **Kaggle**\n\n---\n\n## **⬇ VERY IMPORTANT ⬇**\n\nYou can use the following settings for optimal results:\n\nBest performance: `f0: fcpe | Chunk: 56.0ms or higher | Extra: 2.7s`<br>\nBest quality: `f0: rmvpe | Chunk: 64.0ms or higher | Extra: 5s`<br>\n**Don't forget to select a GPU in the GPU field, <b>NEVER</b> use CPU!\n\nYou can tune `Chunk` for lower/higher delay and `Extra` for better quality.\n\n---\n**Credits**<br>\nRealtime Voice Changer by [w-okada](https://github.com/w-okada)<br>\nOriginal instructions by [Hina](https://github.com/HinaBl)<br>\n\n**Need help?** [AI Hub Discord](https://discord.gg/aihub) » ***#help-realtime-vc***\n\n---","metadata":{"id":"Lbbmx_Vjl0zo"}},{"cell_type":"markdown","source":"# Kaggle Tutorial\nRunning this notebook can be a bit complicated.\\\nAfter created your Kaggle account, you'll need to **verify your phone number** to be able to use Internet Connection and GPUs.\n\nFollow the instructions on the image below and don't forget to set **PERSISTENCE** to **Files only**.\n\n![instructions.png](https://i.imgur.com/0NutkD8.png)","metadata":{}},{"cell_type":"markdown","source":"# Clone repository and install dependencies\nThis first step will download the latest version of Voice Changer and install the dependencies. **It will take some time to complete.**","metadata":{}},{"cell_type":"code","source":"# This will make that we're on the right folder before installing\n%cd /kaggle/working/\n\n# To workaround an issue with METADATA not found for aiohttp\n# !conda install -y aiohttp\n!pip install colorama python-dotenv pyngrok --quiet\n\nfrom colorama import Fore, Style\nimport requests, os\n\nprint(f\"{Fore.CYAN}> Downloading prebuilt executable...{Style.RESET_ALL}\")\n\ndef download_and_unpack(assets: list[dict]):\n for asset in assets:\n if not asset['name'].startswith('voice-changer-linux-amd64-cuda.tar.gz'):\n continue\n download_url = asset['browser_download_url']\n !wget -q --show-progress {download_url}\n\n print(f\"{Fore.GREEN}> Unpacking...{Style.RESET_ALL}\")\n !cat voice-changer-linux-amd64-cuda.tar.gz.* | tar xzf -\n print(f\"{Fore.GREEN}> Finished unpacking!{Style.RESET_ALL}\")\n !rm -rf voice-changer-linux-amd64-cuda.tar.gz.*\n\n !mv /kaggle/working/MMVCServerSIO/MMVCServerSIO /kaggle/working/MMVCServerSIO/VoiceChanger\n\ndef get_local_version(base: str) -> str:\n local_version = !cat {base}/_internal/version.txt\n return local_version[0].strip()\n\nres = requests.get('https://api.github.com/repos/deiteris/voice-changer/releases/latest')\nrelease_info = res.json()\n\nremote_version = release_info['tag_name']\n# Check and upgrade\nif os.path.exists('MMVCServerSIO'):\n local_version = get_local_version(\"/kaggle/working/MMVCServerSIO\")\n if remote_version != local_version:\n print(f\"{Fore.CYAN}> Found new version. Current version {local_version}, remote version {remote_version}. Upgrading...{Style.RESET_ALL}\")\n !rm -rf /kaggle/working/MMVCServerSIO/_internal /kaggle/working/MMVCServerSIO/VoiceChanger /kaggle/working/MMVCServerSIO/MMVCServerSIO\n download_and_unpack(release_info['assets'])\n else:\n print(f\"{Fore.CYAN}> Current version {local_version} is the latest. Skipping download.{Style.RESET_ALL}\")\nelse:\n print(f\"{Fore.CYAN}> Downloading and installing version {remote_version}.{Style.RESET_ALL}\")\n download_and_unpack(release_info['assets'])\n\n%cd MMVCServerSIO\n\nprint(f\"{Fore.CYAN}> Installing libportaudio2...{Style.RESET_ALL}\")\n!apt-get -y install libportaudio2 -qq\nprint(f\"{Fore.CYAN}> Done! Proceed with the next steps.{Style.RESET_ALL}\")","metadata":{"_kg_hide-output":false,"cellView":"form","execution":{"iopub.execute_input":"2023-09-14T04:01:17.308682Z","iopub.status.busy":"2023-09-14T04:01:17.308284Z","iopub.status.idle":"2023-09-14T04:08:08.475375Z","shell.execute_reply":"2023-09-14T04:08:08.473827Z","shell.execute_reply.started":"2023-09-14T04:01:17.308652Z"},"id":"86wTFmqsNMnD","trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Migrate the data\n\nThis cell will migrate your models from old version to new version (if present).","metadata":{}},{"cell_type":"code","source":"import os\n# Migrate old data to new version and delete old version\nif os.path.exists(\"/kaggle/working/Hmod\"):\n !mv /kaggle/working/Hmod/server/model_dir /kaggle/working/MMVCServerSIO/model_dir\n !mv /kaggle/working/Hmod/server/pretrain /kaggle/working/MMVCServerSIO/pretrain\n !rm -rf /kaggle/working/Hmod","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Configure the server\n\nThis cell will apply necessary configuration to the server.","metadata":{}},{"cell_type":"code","source":"%cd /kaggle/working/MMVCServerSIO\n\nfrom dotenv import set_key\n\nset_key('.env', \"SAMPLE_MODE\", \"\")\n\nReady = True","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Start Server **using ngrok**\nThis 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\n---\nYou'll need a ngrok account, but <font color=green>**it's free**</font> and easy to create!\n---\n**1** - Create a **free** account at [ngrok](https://dashboard.ngrok.com/signup)\\\n**2** - If you didn't logged in with Google or Github, you will need to **verify your e-mail**!\\\n**3** - Click [this link](https://dashboard.ngrok.com/get-started/your-authtoken) to get your auth token, and replace **TOKEN_HERE** with your token.\\\n**4** - *(optional)* Change to a region near to you","metadata":{}},{"cell_type":"code","source":"Token = 'TOKEN_HERE'\nRegion = \"eu\" # Read the instructions below\nClearConsole = True\n\n# You can change the region for a better latency, use only the abbreviation\n# Choose between this options:\n# us -> United States (Ohio)\n# ap -> Asia/Pacific (Singapore)\n# au -> Australia (Sydney)\n# eu -> Europe (Frankfurt)\n# in -> India (Mumbai)\n# jp -> Japan (Tokyo)\n# sa -> South America (Sao Paulo)\n\n# ---------------------------------\n# DO NOT TOUCH ANYTHING DOWN BELOW!\n\n%cd /kaggle/working/MMVCServerSIO\n\nif not globals().get('Ready', False):\n print(\"Go back and run first and second cells.\")\nelse:\n from pyngrok import conf, ngrok\n MyConfig = conf.PyngrokConfig()\n MyConfig.auth_token = Token\n MyConfig.region = Region[0:2]\n conf.get_default().authtoken = Token\n conf.get_default().region = Region\n conf.set_default(MyConfig);\n\n import threading, time, socket\n PORT = 18888\n\n import json\n from pyngrok import ngrok\n from IPython.display import clear_output\n\n ngrokConnection = ngrok.connect(PORT)\n public_url = ngrokConnection.public_url\n set_key('.env', \"ALLOWED_ORIGINS\", json.dumps([public_url]))\n\n def wait_for_server():\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 if ClearConsole:\n clear_output()\n print(\"--------- SERVER READY! ---------\")\n print(\"Your server is available at:\")\n print(public_url)\n print(\"---------------------------------\")\n\n threading.Thread(target=wait_for_server, daemon=True).start()\n\n !./VoiceChanger\n\n ngrok.disconnect(ngrokConnection.public_url)","metadata":{"_kg_hide-input":false,"cellView":"form","id":"lLWQuUd7WW9U","scrolled":true,"trusted":true},"execution_count":null,"outputs":[]}]} |