Spaces:
Runtime error
Runtime error
File size: 5,805 Bytes
569ab87 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 |
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"provenance": [],
"gpuType": "T4",
"authorship_tag": "ABX9TyP9xA/YzXZ1hfHjb0pJbiMF",
"include_colab_link": true
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
},
"accelerator": "GPU"
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/github/Blane187/rvc-tts/blob/main/rvc_tts.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "markdown",
"source": [
"RVC TTS BASED ON [litagin02/rvc-tts-webui](https://github.com/litagin02/rvc-tts-webui)"
],
"metadata": {
"id": "DKHM0u_hwK5d"
}
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"cellView": "form",
"id": "PXkFSrJ4R4QK"
},
"outputs": [],
"source": [
"\n",
"#@title clone\n",
"\n",
"server = \"https://github.com/Blane187/rvc-tts\"\n",
"\n",
"tts = \"rvc-tts\"\n",
"\n",
"!git clone $server\n",
"\n",
"%cd $tts"
]
},
{
"cell_type": "code",
"source": [
"\n",
"#@title install requirements\n",
"\n",
"!pip install -r requirements.txt --quiet\n",
"!pip install aria2 --quiet"
],
"metadata": {
"cellView": "form",
"id": "inqwVlPpSzqD"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"\n",
"#@title download model\n",
"\n",
"!python download.py"
],
"metadata": {
"cellView": "form",
"id": "ccAEpKyGTfzt"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"#@title Model Download Function\n",
"\n",
"import os\n",
"import zipfile\n",
"import shutil\n",
"import urllib.request\n",
"\n",
"BASE_DIR = os.getcwd()\n",
"rvc_models_dir = os.path.join(BASE_DIR, 'weights')\n",
"\n",
"def extract_zip(extraction_folder, zip_name):\n",
" os.makedirs(extraction_folder)\n",
" with zipfile.ZipFile(zip_name, 'r') as zip_ref:\n",
" zip_ref.extractall(extraction_folder)\n",
" os.remove(zip_name)\n",
"\n",
" index_filepath, model_filepath = None, None\n",
" for root, dirs, files in os.walk(extraction_folder):\n",
" for name in files:\n",
" if name.endswith('.index') and os.stat(os.path.join(root, name)).st_size > 1024 * 100:\n",
" index_filepath = os.path.join(root, name)\n",
"\n",
" if name.endswith('.pth') and os.stat(os.path.join(root, name)).st_size > 1024 * 1024 * 40:\n",
" model_filepath = os.path.join(root, name)\n",
"\n",
" if not model_filepath:\n",
" raise Exception(f'No .pth model file was found in the extracted zip. Please check {extraction_folder}.')\n",
"\n",
" # move model and index file to extraction folder\n",
" os.rename(model_filepath, os.path.join(extraction_folder, os.path.basename(model_filepath)))\n",
" if index_filepath:\n",
" os.rename(index_filepath, os.path.join(extraction_folder, os.path.basename(index_filepath)))\n",
"\n",
" # remove any unnecessary nested folders\n",
" for filepath in os.listdir(extraction_folder):\n",
" if os.path.isdir(os.path.join(extraction_folder, filepath)):\n",
" shutil.rmtree(os.path.join(extraction_folder, filepath))\n",
"\n",
"def download_online_model(url, dir_name):\n",
" try:\n",
" print(f'[~] Downloading voice model with name {dir_name}...')\n",
" zip_name = url.split('/')[-1]\n",
" extraction_folder = os.path.join(rvc_models_dir, dir_name)\n",
" if os.path.exists(extraction_folder):\n",
" raise Exception(f'Voice model directory {dir_name} already exists! Choose a different name for your voice model.')\n",
"\n",
" if 'pixeldrain.com' in url:\n",
" url = f'https://pixeldrain.com/api/file/{zip_name}'\n",
"\n",
" urllib.request.urlretrieve(url, zip_name)\n",
"\n",
" print('[~] Extracting zip...')\n",
" extract_zip(extraction_folder, zip_name)\n",
" print(f'[+] {dir_name} Model successfully downloaded 😆')\n",
"\n",
" except Exception as e:\n",
" raise Exception(str(e))\n",
"\n",
"url = \"https://pixeldrain.com/u/3tJmABXA\" # @param {type:\"string\"}\n",
"dir_name = \"Gura\" # @param {type:\"string\"}\n",
"\n",
"download_online_model(url, dir_name)"
],
"metadata": {
"cellView": "form",
"id": "8EO0QzQ5VdTQ"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"\n",
"\n",
"#@title run\n",
"!python app.py"
],
"metadata": {
"cellView": "form",
"id": "fwh0j3VJUbNp"
},
"execution_count": null,
"outputs": []
}
]
} |