Skip to content

Commit

Permalink
Background WEEEE
Browse files Browse the repository at this point in the history
  • Loading branch information
hinabl committed Oct 13, 2023
1 parent 22b0f83 commit c0db399
Showing 1 changed file with 42 additions and 60 deletions.
102 changes: 42 additions & 60 deletions Hina_Modified_Realtime_Voice_Changer_on_Colab.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@
"clear_output()\n",
"!rm -rf rvctimer\n",
"!git clone --depth 1 $rvctimer\n",
"!cp -f rvctimer/index.html $pathloc/client/demo/dist/\n",
"\n",
"\n",
"%cd $pathloc/server/\n",
Expand Down Expand Up @@ -357,7 +356,7 @@
"Token = 'YOUR_TOKEN_HERE' # @param {type:\"string\"}\n",
"# @markdown **4** - Still need further tests, but maybe region can help a bit on latency?\\\n",
"# @markdown `Default Region: us - United States (Ohio)`\n",
"Region = \"ap - Asia/Pacific (Singapore)\" # @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",
"Region = \"us - United States (Ohio)\" # @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",
"MyConfig = conf.PyngrokConfig()\n",
"\n",
"MyConfig.auth_token = Token\n",
Expand All @@ -372,6 +371,47 @@
"# @markdown If you want to automatically clear the output when the server loads, check this option.\n",
"Clear_Output = True # @param {type:\"boolean\"}\n",
"\n",
"#@markdown ---\n",
"#@markdown If you want to use a custom background for the voice changer\n",
"Use_Custom_BG=False #@param{type:\"boolean\"}\n",
"BG_URL=\"https://w.wallha.com/ws/14/cMmpo5vn.jpg\" #@param{type:\"string\"}\n",
"#@markdown Text colors can be hex ``#101010`` or name of color ``black`` (css)\n",
"Text_Color=\"green\" #@param{type:\"string\"}\n",
"if Use_Custom_BG==True:\n",
" if BG_URL==\"\":\n",
" !cp -f rvctimer/index.html $pathloc/client/demo/dist/\n",
" else:\n",
" html_template = f'''\n",
" <!doctype html>\n",
" <html style=\"width:100%;height:100%;overflow:hidden\">\n",
" <head>\n",
" <meta charset=\"utf-8\" />\n",
" <title>Voice Changer Client Demo</title>\n",
" <script defer=\"defer\" src=\"index.js\"></script>\n",
" <style>\n",
" #app {{\n",
" color: {Text_Color};\n",
" background-color: #101010;\n",
" background-image: url(\"{BG_URL}\");\n",
" background-size: cover;\n",
" background-attachment: fixed;\n",
" z-index: 1;\n",
" }}\n",
" </style>\n",
" </head>\n",
" <body style=\"width:100%;height:100%;margin:0\">\n",
" <div id=\"app\" style=\"width:100%;height:100vh\"></div>\n",
" </body>\n",
" </html>\n",
" '''\n",
" with open('index.html', 'w') as file:\n",
" file.write(html_template)\n",
" !mkdir ../client/demo/dist/temp/\n",
" !mv ../client/demo/dist/index.html ../client/demo/dist/temp/index.html\n",
" !mv index.html ../client/demo/dist/\n",
"else:\n",
" !cp -f ../client/demo/dist/temp/index.html ../client/demo/dist/index.html\n",
"\n",
"mainpy=codecs.decode('ZZIPFreireFVB.cl','rot_13')\n",
"\n",
"import portpicker, socket, urllib.request\n",
Expand Down Expand Up @@ -431,64 +471,6 @@
"metadata": {
"id": "2Uu1sTSwTc7q"
}
},
{
"cell_type": "code",
"source": [
"# @title **[Optional]** Start Server **using localtunnel** (ngrok alternative | no account needed)\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",
"\n",
"# @markdown ---\n",
"!npm config set update-notifier false\n",
"!npm install -g localtunnel\n",
"print(\"\\033[92mLocalTunnel installed!\")\n",
"# @markdown If you want to automatically clear the output when the server loads, check this option.\n",
"Clear_Output = True # @param {type:\"boolean\"}\n",
"\n",
"import portpicker, subprocess, threading, time, socket, urllib.request\n",
"PORT = portpicker.pick_unused_port()\n",
"\n",
"from IPython.display import clear_output, Javascript\n",
"\n",
"def iframe_thread(port):\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",
" clear_output()\n",
" print(\"Use the following endpoint to connect to localtunnel:\", urllib.request.urlopen('https://ipv4.icanhazip.com').read().decode('utf8').strip(\"\\n\"))\n",
" p = subprocess.Popen([\"lt\", \"--port\", \"{}\".format(port)], stdout=subprocess.PIPE)\n",
" for line in p.stdout:\n",
" print(line.decode(), end='')\n",
"\n",
"threading.Thread(target=iframe_thread, daemon=True, args=(PORT,)).start()\n",
"\n",
"\n",
"!python3 MMVCServerSIO.py \\\n",
" -p {PORT} \\\n",
" --https False \\\n",
" --content_vec_500 pretrain/checkpoint_best_legacy_500.pt \\\n",
" --content_vec_500_onnx pretrain/content_vec_500.onnx \\\n",
" --content_vec_500_onnx_on true \\\n",
" --hubert_base pretrain/hubert_base.pt \\\n",
" --hubert_base_jp pretrain/rinna_hubert_base_jp.pt \\\n",
" --hubert_soft pretrain/hubert/hubert-soft-0d54a1f4.pt \\\n",
" --nsf_hifigan pretrain/nsf_hifigan/model \\\n",
" --crepe_onnx_full pretrain/crepe_onnx_full.onnx \\\n",
" --crepe_onnx_tiny pretrain/crepe_onnx_tiny.onnx \\\n",
" --rmvpe pretrain/rmvpe.pt \\\n",
" --model_dir model_dir \\\n",
" --samples samples.json \\\n",
" --colab True"
],
"metadata": {
"id": "Mr7325z-TTX5"
},
"execution_count": null,
"outputs": []
}
],
"metadata": {
Expand Down

0 comments on commit c0db399

Please sign in to comment.