Spaces:
Configuration error
Configuration error
Commit ·
1c52b4a
1
Parent(s): 381dbe6
Delete easy_infer.py
Browse files- easy_infer.py +0 -1398
easy_infer.py
DELETED
|
@@ -1,1398 +0,0 @@
|
|
| 1 |
-
import subprocess
|
| 2 |
-
import os
|
| 3 |
-
import sys
|
| 4 |
-
import errno
|
| 5 |
-
import shutil
|
| 6 |
-
import yt_dlp
|
| 7 |
-
from mega import Mega
|
| 8 |
-
import datetime
|
| 9 |
-
import unicodedata
|
| 10 |
-
import torch
|
| 11 |
-
import glob
|
| 12 |
-
import gradio as gr
|
| 13 |
-
import gdown
|
| 14 |
-
import zipfile
|
| 15 |
-
import traceback
|
| 16 |
-
import json
|
| 17 |
-
import mdx
|
| 18 |
-
from mdx_processing_script import get_model_list,id_to_ptm,prepare_mdx,run_mdx
|
| 19 |
-
import requests
|
| 20 |
-
import wget
|
| 21 |
-
import ffmpeg
|
| 22 |
-
import hashlib
|
| 23 |
-
now_dir = os.getcwd()
|
| 24 |
-
sys.path.append(now_dir)
|
| 25 |
-
from unidecode import unidecode
|
| 26 |
-
import re
|
| 27 |
-
import time
|
| 28 |
-
from lib.infer_pack.models_onnx import SynthesizerTrnMsNSFsidM
|
| 29 |
-
from infer.modules.vc.pipeline import Pipeline
|
| 30 |
-
VC = Pipeline
|
| 31 |
-
from lib.infer_pack.models import (
|
| 32 |
-
SynthesizerTrnMs256NSFsid,
|
| 33 |
-
SynthesizerTrnMs256NSFsid_nono,
|
| 34 |
-
SynthesizerTrnMs768NSFsid,
|
| 35 |
-
SynthesizerTrnMs768NSFsid_nono,
|
| 36 |
-
)
|
| 37 |
-
from MDXNet import MDXNetDereverb
|
| 38 |
-
from configs.config import Config
|
| 39 |
-
from infer_uvr5 import _audio_pre_, _audio_pre_new
|
| 40 |
-
from huggingface_hub import HfApi, list_models
|
| 41 |
-
from huggingface_hub import login
|
| 42 |
-
from i18n import I18nAuto
|
| 43 |
-
i18n = I18nAuto()
|
| 44 |
-
from bs4 import BeautifulSoup
|
| 45 |
-
from sklearn.cluster import MiniBatchKMeans
|
| 46 |
-
from dotenv import load_dotenv
|
| 47 |
-
load_dotenv()
|
| 48 |
-
config = Config()
|
| 49 |
-
tmp = os.path.join(now_dir, "TEMP")
|
| 50 |
-
shutil.rmtree(tmp, ignore_errors=True)
|
| 51 |
-
os.environ["TEMP"] = tmp
|
| 52 |
-
weight_root = os.getenv("weight_root")
|
| 53 |
-
weight_uvr5_root = os.getenv("weight_uvr5_root")
|
| 54 |
-
index_root = os.getenv("index_root")
|
| 55 |
-
audio_root = "audios"
|
| 56 |
-
names = []
|
| 57 |
-
for name in os.listdir(weight_root):
|
| 58 |
-
if name.endswith(".pth"):
|
| 59 |
-
names.append(name)
|
| 60 |
-
index_paths = []
|
| 61 |
-
|
| 62 |
-
global indexes_list
|
| 63 |
-
indexes_list = []
|
| 64 |
-
|
| 65 |
-
audio_paths = []
|
| 66 |
-
for root, dirs, files in os.walk(index_root, topdown=False):
|
| 67 |
-
for name in files:
|
| 68 |
-
if name.endswith(".index") and "trained" not in name:
|
| 69 |
-
index_paths.append("%s\\%s" % (root, name))
|
| 70 |
-
|
| 71 |
-
for root, dirs, files in os.walk(audio_root, topdown=False):
|
| 72 |
-
for name in files:
|
| 73 |
-
audio_paths.append("%s/%s" % (root, name))
|
| 74 |
-
|
| 75 |
-
uvr5_names = []
|
| 76 |
-
for name in os.listdir(weight_uvr5_root):
|
| 77 |
-
if name.endswith(".pth") or "onnx" in name:
|
| 78 |
-
uvr5_names.append(name.replace(".pth", ""))
|
| 79 |
-
|
| 80 |
-
def calculate_md5(file_path):
|
| 81 |
-
hash_md5 = hashlib.md5()
|
| 82 |
-
with open(file_path, "rb") as f:
|
| 83 |
-
for chunk in iter(lambda: f.read(4096), b""):
|
| 84 |
-
hash_md5.update(chunk)
|
| 85 |
-
return hash_md5.hexdigest()
|
| 86 |
-
|
| 87 |
-
def format_title(title):
|
| 88 |
-
formatted_title = re.sub(r'[^\w\s-]', '', title)
|
| 89 |
-
formatted_title = formatted_title.replace(" ", "_")
|
| 90 |
-
return formatted_title
|
| 91 |
-
|
| 92 |
-
def silentremove(filename):
|
| 93 |
-
try:
|
| 94 |
-
os.remove(filename)
|
| 95 |
-
except OSError as e:
|
| 96 |
-
if e.errno != errno.ENOENT:
|
| 97 |
-
raise
|
| 98 |
-
def get_md5(temp_folder):
|
| 99 |
-
for root, subfolders, files in os.walk(temp_folder):
|
| 100 |
-
for file in files:
|
| 101 |
-
if not file.startswith("G_") and not file.startswith("D_") and file.endswith(".pth") and not "_G_" in file and not "_D_" in file:
|
| 102 |
-
md5_hash = calculate_md5(os.path.join(root, file))
|
| 103 |
-
return md5_hash
|
| 104 |
-
|
| 105 |
-
return None
|
| 106 |
-
|
| 107 |
-
def find_parent(search_dir, file_name):
|
| 108 |
-
for dirpath, dirnames, filenames in os.walk(search_dir):
|
| 109 |
-
if file_name in filenames:
|
| 110 |
-
return os.path.abspath(dirpath)
|
| 111 |
-
return None
|
| 112 |
-
|
| 113 |
-
def find_folder_parent(search_dir, folder_name):
|
| 114 |
-
for dirpath, dirnames, filenames in os.walk(search_dir):
|
| 115 |
-
if folder_name in dirnames:
|
| 116 |
-
return os.path.abspath(dirpath)
|
| 117 |
-
return None
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
def delete_large_files(directory_path, max_size_megabytes):
|
| 121 |
-
for filename in os.listdir(directory_path):
|
| 122 |
-
file_path = os.path.join(directory_path, filename)
|
| 123 |
-
if os.path.isfile(file_path):
|
| 124 |
-
size_in_bytes = os.path.getsize(file_path)
|
| 125 |
-
size_in_megabytes = size_in_bytes / (1024 * 1024) # Convert bytes to megabytes
|
| 126 |
-
|
| 127 |
-
if size_in_megabytes > max_size_megabytes:
|
| 128 |
-
print("###################################")
|
| 129 |
-
print(f"Deleting s*** {filename} (Size: {size_in_megabytes:.2f} MB)")
|
| 130 |
-
os.remove(file_path)
|
| 131 |
-
print("###################################")
|
| 132 |
-
|
| 133 |
-
def download_from_url(url):
|
| 134 |
-
parent_path = find_folder_parent(".", "pretrained_v2")
|
| 135 |
-
zips_path = os.path.join(parent_path, 'zips')
|
| 136 |
-
print(f"Limit download size in MB {os.getenv('MAX_DOWNLOAD_SIZE')}, duplicate the space for modify the limit")
|
| 137 |
-
|
| 138 |
-
if url != '':
|
| 139 |
-
print(i18n("Downloading the file: ") + f"{url}")
|
| 140 |
-
if "drive.google.com" in url:
|
| 141 |
-
if "file/d/" in url:
|
| 142 |
-
file_id = url.split("file/d/")[1].split("/")[0]
|
| 143 |
-
elif "id=" in url:
|
| 144 |
-
file_id = url.split("id=")[1].split("&")[0]
|
| 145 |
-
else:
|
| 146 |
-
return None
|
| 147 |
-
|
| 148 |
-
if file_id:
|
| 149 |
-
os.chdir('./zips')
|
| 150 |
-
result = subprocess.run(["gdown", f"https://drive.google.com/uc?id={file_id}", "--fuzzy"], capture_output=True, text=True, encoding='utf-8')
|
| 151 |
-
if "Too many users have viewed or downloaded this file recently" in str(result.stderr):
|
| 152 |
-
return "too much use"
|
| 153 |
-
if "Cannot retrieve the public link of the file." in str(result.stderr):
|
| 154 |
-
return "private link"
|
| 155 |
-
print(result.stderr)
|
| 156 |
-
|
| 157 |
-
elif "/blob/" in url:
|
| 158 |
-
os.chdir('./zips')
|
| 159 |
-
url = url.replace("blob", "resolve")
|
| 160 |
-
response = requests.get(url)
|
| 161 |
-
if response.status_code == 200:
|
| 162 |
-
file_name = url.split('/')[-1]
|
| 163 |
-
with open(os.path.join(zips_path, file_name), "wb") as newfile:
|
| 164 |
-
newfile.write(response.content)
|
| 165 |
-
else:
|
| 166 |
-
os.chdir(parent_path)
|
| 167 |
-
elif "mega.nz" in url:
|
| 168 |
-
if "#!" in url:
|
| 169 |
-
file_id = url.split("#!")[1].split("!")[0]
|
| 170 |
-
elif "file/" in url:
|
| 171 |
-
file_id = url.split("file/")[1].split("/")[0]
|
| 172 |
-
else:
|
| 173 |
-
return None
|
| 174 |
-
if file_id:
|
| 175 |
-
m = Mega()
|
| 176 |
-
m.download_url(url, zips_path)
|
| 177 |
-
elif "/tree/main" in url:
|
| 178 |
-
response = requests.get(url)
|
| 179 |
-
soup = BeautifulSoup(response.content, 'html.parser')
|
| 180 |
-
temp_url = ''
|
| 181 |
-
for link in soup.find_all('a', href=True):
|
| 182 |
-
if link['href'].endswith('.zip'):
|
| 183 |
-
temp_url = link['href']
|
| 184 |
-
break
|
| 185 |
-
if temp_url:
|
| 186 |
-
url = temp_url
|
| 187 |
-
url = url.replace("blob", "resolve")
|
| 188 |
-
if "huggingface.co" not in url:
|
| 189 |
-
url = "https://huggingface.co" + url
|
| 190 |
-
|
| 191 |
-
wget.download(url)
|
| 192 |
-
else:
|
| 193 |
-
print("No .zip file found on the page.")
|
| 194 |
-
elif "cdn.discordapp.com" in url:
|
| 195 |
-
file = requests.get(url)
|
| 196 |
-
if file.status_code == 200:
|
| 197 |
-
name = url.split('/')
|
| 198 |
-
with open(os.path.join(zips_path, name[len(name)-1]), "wb") as newfile:
|
| 199 |
-
newfile.write(file.content)
|
| 200 |
-
else:
|
| 201 |
-
return None
|
| 202 |
-
elif "pixeldrain.com" in url:
|
| 203 |
-
try:
|
| 204 |
-
file_id = url.split("pixeldrain.com/u/")[1]
|
| 205 |
-
os.chdir('./zips')
|
| 206 |
-
print(file_id)
|
| 207 |
-
response = requests.get(f"https://pixeldrain.com/api/file/{file_id}")
|
| 208 |
-
if response.status_code == 200:
|
| 209 |
-
file_name = response.headers.get("Content-Disposition").split('filename=')[-1].strip('";')
|
| 210 |
-
if not os.path.exists(zips_path):
|
| 211 |
-
os.makedirs(zips_path)
|
| 212 |
-
with open(os.path.join(zips_path, file_name), "wb") as newfile:
|
| 213 |
-
newfile.write(response.content)
|
| 214 |
-
os.chdir(parent_path)
|
| 215 |
-
return "downloaded"
|
| 216 |
-
else:
|
| 217 |
-
os.chdir(parent_path)
|
| 218 |
-
return None
|
| 219 |
-
except Exception as e:
|
| 220 |
-
print(e)
|
| 221 |
-
os.chdir(parent_path)
|
| 222 |
-
return None
|
| 223 |
-
else:
|
| 224 |
-
os.chdir('./zips')
|
| 225 |
-
wget.download(url)
|
| 226 |
-
|
| 227 |
-
#os.chdir('./zips')
|
| 228 |
-
delete_large_files(zips_path, int(os.getenv("MAX_DOWNLOAD_SIZE")))
|
| 229 |
-
os.chdir(parent_path)
|
| 230 |
-
print(i18n("Full download"))
|
| 231 |
-
return "downloaded"
|
| 232 |
-
else:
|
| 233 |
-
return None
|
| 234 |
-
|
| 235 |
-
class error_message(Exception):
|
| 236 |
-
def __init__(self, mensaje):
|
| 237 |
-
self.mensaje = mensaje
|
| 238 |
-
super().__init__(mensaje)
|
| 239 |
-
|
| 240 |
-
def get_vc(sid, to_return_protect0, to_return_protect1):
|
| 241 |
-
global n_spk, tgt_sr, net_g, vc, cpt, version
|
| 242 |
-
if sid == "" or sid == []:
|
| 243 |
-
global hubert_model
|
| 244 |
-
if hubert_model is not None:
|
| 245 |
-
print("clean_empty_cache")
|
| 246 |
-
del net_g, n_spk, vc, hubert_model, tgt_sr
|
| 247 |
-
hubert_model = net_g = n_spk = vc = hubert_model = tgt_sr = None
|
| 248 |
-
if torch.cuda.is_available():
|
| 249 |
-
torch.cuda.empty_cache()
|
| 250 |
-
if_f0 = cpt.get("f0", 1)
|
| 251 |
-
version = cpt.get("version", "v1")
|
| 252 |
-
if version == "v1":
|
| 253 |
-
if if_f0 == 1:
|
| 254 |
-
net_g = SynthesizerTrnMs256NSFsid(
|
| 255 |
-
*cpt["config"], is_half=config.is_half
|
| 256 |
-
)
|
| 257 |
-
else:
|
| 258 |
-
net_g = SynthesizerTrnMs256NSFsid_nono(*cpt["config"])
|
| 259 |
-
elif version == "v2":
|
| 260 |
-
if if_f0 == 1:
|
| 261 |
-
net_g = SynthesizerTrnMs768NSFsid(
|
| 262 |
-
*cpt["config"], is_half=config.is_half
|
| 263 |
-
)
|
| 264 |
-
else:
|
| 265 |
-
net_g = SynthesizerTrnMs768NSFsid_nono(*cpt["config"])
|
| 266 |
-
del net_g, cpt
|
| 267 |
-
if torch.cuda.is_available():
|
| 268 |
-
torch.cuda.empty_cache()
|
| 269 |
-
cpt = None
|
| 270 |
-
return (
|
| 271 |
-
{"visible": False, "__type__": "update"},
|
| 272 |
-
{"visible": False, "__type__": "update"},
|
| 273 |
-
{"visible": False, "__type__": "update"},
|
| 274 |
-
)
|
| 275 |
-
person = "%s/%s" % (weight_root, sid)
|
| 276 |
-
print("loading %s" % person)
|
| 277 |
-
cpt = torch.load(person, map_location="cpu")
|
| 278 |
-
tgt_sr = cpt["config"][-1]
|
| 279 |
-
cpt["config"][-3] = cpt["weight"]["emb_g.weight"].shape[0]
|
| 280 |
-
if_f0 = cpt.get("f0", 1)
|
| 281 |
-
if if_f0 == 0:
|
| 282 |
-
to_return_protect0 = to_return_protect1 = {
|
| 283 |
-
"visible": False,
|
| 284 |
-
"value": 0.5,
|
| 285 |
-
"__type__": "update",
|
| 286 |
-
}
|
| 287 |
-
else:
|
| 288 |
-
to_return_protect0 = {
|
| 289 |
-
"visible": True,
|
| 290 |
-
"value": to_return_protect0,
|
| 291 |
-
"__type__": "update",
|
| 292 |
-
}
|
| 293 |
-
to_return_protect1 = {
|
| 294 |
-
"visible": True,
|
| 295 |
-
"value": to_return_protect1,
|
| 296 |
-
"__type__": "update",
|
| 297 |
-
}
|
| 298 |
-
version = cpt.get("version", "v1")
|
| 299 |
-
if version == "v1":
|
| 300 |
-
if if_f0 == 1:
|
| 301 |
-
net_g = SynthesizerTrnMs256NSFsid(*cpt["config"], is_half=config.is_half)
|
| 302 |
-
else:
|
| 303 |
-
net_g = SynthesizerTrnMs256NSFsid_nono(*cpt["config"])
|
| 304 |
-
elif version == "v2":
|
| 305 |
-
if if_f0 == 1:
|
| 306 |
-
net_g = SynthesizerTrnMs768NSFsid(*cpt["config"], is_half=config.is_half)
|
| 307 |
-
else:
|
| 308 |
-
net_g = SynthesizerTrnMs768NSFsid_nono(*cpt["config"])
|
| 309 |
-
del net_g.enc_q
|
| 310 |
-
print(net_g.load_state_dict(cpt["weight"], strict=False))
|
| 311 |
-
net_g.eval().to(config.device)
|
| 312 |
-
if config.is_half:
|
| 313 |
-
net_g = net_g.half()
|
| 314 |
-
else:
|
| 315 |
-
net_g = net_g.float()
|
| 316 |
-
vc = VC(tgt_sr, config)
|
| 317 |
-
n_spk = cpt["config"][-3]
|
| 318 |
-
return (
|
| 319 |
-
{"visible": True, "maximum": n_spk, "__type__": "update"},
|
| 320 |
-
to_return_protect0,
|
| 321 |
-
to_return_protect1,
|
| 322 |
-
)
|
| 323 |
-
|
| 324 |
-
def load_downloaded_model(url):
|
| 325 |
-
parent_path = find_folder_parent(".", "pretrained_v2")
|
| 326 |
-
try:
|
| 327 |
-
infos = []
|
| 328 |
-
logs_folders = ['0_gt_wavs','1_16k_wavs','2a_f0','2b-f0nsf','3_feature256','3_feature768']
|
| 329 |
-
zips_path = os.path.join(parent_path, 'zips')
|
| 330 |
-
unzips_path = os.path.join(parent_path, 'unzips')
|
| 331 |
-
weights_path = os.path.join(parent_path, 'weights')
|
| 332 |
-
logs_dir = ""
|
| 333 |
-
|
| 334 |
-
if os.path.exists(zips_path):
|
| 335 |
-
shutil.rmtree(zips_path)
|
| 336 |
-
if os.path.exists(unzips_path):
|
| 337 |
-
shutil.rmtree(unzips_path)
|
| 338 |
-
|
| 339 |
-
os.mkdir(zips_path)
|
| 340 |
-
os.mkdir(unzips_path)
|
| 341 |
-
|
| 342 |
-
download_file = download_from_url(url)
|
| 343 |
-
if not download_file:
|
| 344 |
-
print(i18n("The file could not be downloaded."))
|
| 345 |
-
infos.append(i18n("The file could not be downloaded."))
|
| 346 |
-
yield "\n".join(infos)
|
| 347 |
-
elif download_file == "downloaded":
|
| 348 |
-
print(i18n("It has been downloaded successfully."))
|
| 349 |
-
infos.append(i18n("It has been downloaded successfully."))
|
| 350 |
-
yield "\n".join(infos)
|
| 351 |
-
elif download_file == "too much use":
|
| 352 |
-
raise Exception(i18n("Too many users have recently viewed or downloaded this file"))
|
| 353 |
-
elif download_file == "private link":
|
| 354 |
-
raise Exception(i18n("Cannot get file from this private link"))
|
| 355 |
-
|
| 356 |
-
for filename in os.listdir(zips_path):
|
| 357 |
-
if filename.endswith(".zip"):
|
| 358 |
-
zipfile_path = os.path.join(zips_path,filename)
|
| 359 |
-
print(i18n("Proceeding with the extraction..."))
|
| 360 |
-
infos.append(i18n("Proceeding with the extraction..."))
|
| 361 |
-
shutil.unpack_archive(zipfile_path, unzips_path, 'zip')
|
| 362 |
-
model_name = os.path.basename(zipfile_path)
|
| 363 |
-
logs_dir = os.path.join(parent_path,'logs', os.path.normpath(str(model_name).replace(".zip","")))
|
| 364 |
-
yield "\n".join(infos)
|
| 365 |
-
else:
|
| 366 |
-
print(i18n("Unzip error."))
|
| 367 |
-
infos.append(i18n("Unzip error."))
|
| 368 |
-
yield "\n".join(infos)
|
| 369 |
-
|
| 370 |
-
index_file = False
|
| 371 |
-
model_file = False
|
| 372 |
-
D_file = False
|
| 373 |
-
G_file = False
|
| 374 |
-
|
| 375 |
-
for path, subdirs, files in os.walk(unzips_path):
|
| 376 |
-
for item in files:
|
| 377 |
-
item_path = os.path.join(path, item)
|
| 378 |
-
if not 'G_' in item and not 'D_' in item and item.endswith('.pth'):
|
| 379 |
-
model_file = True
|
| 380 |
-
model_name = item.replace(".pth","")
|
| 381 |
-
logs_dir = os.path.join(parent_path,'logs', model_name)
|
| 382 |
-
if os.path.exists(logs_dir):
|
| 383 |
-
shutil.rmtree(logs_dir)
|
| 384 |
-
os.mkdir(logs_dir)
|
| 385 |
-
if not os.path.exists(weights_path):
|
| 386 |
-
os.mkdir(weights_path)
|
| 387 |
-
if os.path.exists(os.path.join(weights_path, item)):
|
| 388 |
-
os.remove(os.path.join(weights_path, item))
|
| 389 |
-
if os.path.exists(item_path):
|
| 390 |
-
shutil.move(item_path, weights_path)
|
| 391 |
-
|
| 392 |
-
if not model_file and not os.path.exists(logs_dir):
|
| 393 |
-
os.mkdir(logs_dir)
|
| 394 |
-
for path, subdirs, files in os.walk(unzips_path):
|
| 395 |
-
for item in files:
|
| 396 |
-
item_path = os.path.join(path, item)
|
| 397 |
-
if item.startswith('added_') and item.endswith('.index'):
|
| 398 |
-
index_file = True
|
| 399 |
-
if os.path.exists(item_path):
|
| 400 |
-
if os.path.exists(os.path.join(logs_dir, item)):
|
| 401 |
-
os.remove(os.path.join(logs_dir, item))
|
| 402 |
-
shutil.move(item_path, logs_dir)
|
| 403 |
-
if item.startswith('total_fea.npy') or item.startswith('events.'):
|
| 404 |
-
if os.path.exists(item_path):
|
| 405 |
-
if os.path.exists(os.path.join(logs_dir, item)):
|
| 406 |
-
os.remove(os.path.join(logs_dir, item))
|
| 407 |
-
shutil.move(item_path, logs_dir)
|
| 408 |
-
|
| 409 |
-
|
| 410 |
-
result = ""
|
| 411 |
-
if model_file:
|
| 412 |
-
if index_file:
|
| 413 |
-
print(i18n("The model works for inference, and has the .index file."))
|
| 414 |
-
infos.append("\n" + i18n("The model works for inference, and has the .index file."))
|
| 415 |
-
yield "\n".join(infos)
|
| 416 |
-
else:
|
| 417 |
-
print(i18n("The model works for inference, but it doesn't have the .index file."))
|
| 418 |
-
infos.append("\n" + i18n("The model works for inference, but it doesn't have the .index file."))
|
| 419 |
-
yield "\n".join(infos)
|
| 420 |
-
|
| 421 |
-
if not index_file and not model_file:
|
| 422 |
-
print(i18n("No relevant file was found to upload."))
|
| 423 |
-
infos.append(i18n("No relevant file was found to upload."))
|
| 424 |
-
yield "\n".join(infos)
|
| 425 |
-
|
| 426 |
-
if os.path.exists(zips_path):
|
| 427 |
-
shutil.rmtree(zips_path)
|
| 428 |
-
if os.path.exists(unzips_path):
|
| 429 |
-
shutil.rmtree(unzips_path)
|
| 430 |
-
os.chdir(parent_path)
|
| 431 |
-
return result
|
| 432 |
-
except Exception as e:
|
| 433 |
-
os.chdir(parent_path)
|
| 434 |
-
if "too much use" in str(e):
|
| 435 |
-
print(i18n("Too many users have recently viewed or downloaded this file"))
|
| 436 |
-
yield i18n("Too many users have recently viewed or downloaded this file")
|
| 437 |
-
elif "private link" in str(e):
|
| 438 |
-
print(i18n("Cannot get file from this private link"))
|
| 439 |
-
yield i18n("Cannot get file from this private link")
|
| 440 |
-
else:
|
| 441 |
-
print(e)
|
| 442 |
-
yield i18n("An error occurred downloading")
|
| 443 |
-
finally:
|
| 444 |
-
os.chdir(parent_path)
|
| 445 |
-
|
| 446 |
-
def load_dowloaded_dataset(url):
|
| 447 |
-
parent_path = find_folder_parent(".", "pretrained_v2")
|
| 448 |
-
infos = []
|
| 449 |
-
try:
|
| 450 |
-
zips_path = os.path.join(parent_path, 'zips')
|
| 451 |
-
unzips_path = os.path.join(parent_path, 'unzips')
|
| 452 |
-
datasets_path = os.path.join(parent_path, 'datasets')
|
| 453 |
-
audio_extenions =['wav', 'mp3', 'flac', 'ogg', 'opus',
|
| 454 |
-
'm4a', 'mp4', 'aac', 'alac', 'wma',
|
| 455 |
-
'aiff', 'webm', 'ac3']
|
| 456 |
-
|
| 457 |
-
if os.path.exists(zips_path):
|
| 458 |
-
shutil.rmtree(zips_path)
|
| 459 |
-
if os.path.exists(unzips_path):
|
| 460 |
-
shutil.rmtree(unzips_path)
|
| 461 |
-
|
| 462 |
-
if not os.path.exists(datasets_path):
|
| 463 |
-
os.mkdir(datasets_path)
|
| 464 |
-
|
| 465 |
-
os.mkdir(zips_path)
|
| 466 |
-
os.mkdir(unzips_path)
|
| 467 |
-
|
| 468 |
-
download_file = download_from_url(url)
|
| 469 |
-
|
| 470 |
-
if not download_file:
|
| 471 |
-
print(i18n("An error occurred downloading"))
|
| 472 |
-
infos.append(i18n("An error occurred downloading"))
|
| 473 |
-
yield "\n".join(infos)
|
| 474 |
-
raise Exception(i18n("An error occurred downloading"))
|
| 475 |
-
elif download_file == "downloaded":
|
| 476 |
-
print(i18n("It has been downloaded successfully."))
|
| 477 |
-
infos.append(i18n("It has been downloaded successfully."))
|
| 478 |
-
yield "\n".join(infos)
|
| 479 |
-
elif download_file == "too much use":
|
| 480 |
-
raise Exception(i18n("Too many users have recently viewed or downloaded this file"))
|
| 481 |
-
elif download_file == "private link":
|
| 482 |
-
raise Exception(i18n("Cannot get file from this private link"))
|
| 483 |
-
|
| 484 |
-
zip_path = os.listdir(zips_path)
|
| 485 |
-
foldername = ""
|
| 486 |
-
for file in zip_path:
|
| 487 |
-
if file.endswith('.zip'):
|
| 488 |
-
file_path = os.path.join(zips_path, file)
|
| 489 |
-
print("....")
|
| 490 |
-
foldername = file.replace(".zip","").replace(" ","").replace("-","_")
|
| 491 |
-
dataset_path = os.path.join(datasets_path, foldername)
|
| 492 |
-
print(i18n("Proceeding with the extraction..."))
|
| 493 |
-
infos.append(i18n("Proceeding with the extraction..."))
|
| 494 |
-
yield "\n".join(infos)
|
| 495 |
-
shutil.unpack_archive(file_path, unzips_path, 'zip')
|
| 496 |
-
if os.path.exists(dataset_path):
|
| 497 |
-
shutil.rmtree(dataset_path)
|
| 498 |
-
|
| 499 |
-
os.mkdir(dataset_path)
|
| 500 |
-
|
| 501 |
-
for root, subfolders, songs in os.walk(unzips_path):
|
| 502 |
-
for song in songs:
|
| 503 |
-
song_path = os.path.join(root, song)
|
| 504 |
-
if song.endswith(tuple(audio_extenions)):
|
| 505 |
-
formatted_song_name = format_title(os.path.splitext(song)[0])
|
| 506 |
-
extension = os.path.splitext(song)[1]
|
| 507 |
-
new_song_path = os.path.join(dataset_path, f"{formatted_song_name}{extension}")
|
| 508 |
-
shutil.move(song_path, new_song_path)
|
| 509 |
-
else:
|
| 510 |
-
print(i18n("Unzip error."))
|
| 511 |
-
infos.append(i18n("Unzip error."))
|
| 512 |
-
yield "\n".join(infos)
|
| 513 |
-
|
| 514 |
-
|
| 515 |
-
|
| 516 |
-
if os.path.exists(zips_path):
|
| 517 |
-
shutil.rmtree(zips_path)
|
| 518 |
-
if os.path.exists(unzips_path):
|
| 519 |
-
shutil.rmtree(unzips_path)
|
| 520 |
-
|
| 521 |
-
print(i18n("The Dataset has been loaded successfully."))
|
| 522 |
-
infos.append(i18n("The Dataset has been loaded successfully."))
|
| 523 |
-
yield "\n".join(infos)
|
| 524 |
-
except Exception as e:
|
| 525 |
-
os.chdir(parent_path)
|
| 526 |
-
if "too much use" in str(e):
|
| 527 |
-
print(i18n("Too many users have recently viewed or downloaded this file"))
|
| 528 |
-
yield i18n("Too many users have recently viewed or downloaded this file")
|
| 529 |
-
elif "private link" in str(e):
|
| 530 |
-
print(i18n("Cannot get file from this private link"))
|
| 531 |
-
yield i18n("Cannot get file from this private link")
|
| 532 |
-
else:
|
| 533 |
-
print(e)
|
| 534 |
-
yield i18n("An error occurred downloading")
|
| 535 |
-
finally:
|
| 536 |
-
os.chdir(parent_path)
|
| 537 |
-
|
| 538 |
-
def save_model(modelname, save_action):
|
| 539 |
-
|
| 540 |
-
parent_path = find_folder_parent(".", "pretrained_v2")
|
| 541 |
-
zips_path = os.path.join(parent_path, 'zips')
|
| 542 |
-
dst = os.path.join(zips_path,modelname)
|
| 543 |
-
logs_path = os.path.join(parent_path, 'logs', modelname)
|
| 544 |
-
weights_path = os.path.join(parent_path, 'weights', f"{modelname}.pth")
|
| 545 |
-
save_folder = parent_path
|
| 546 |
-
infos = []
|
| 547 |
-
|
| 548 |
-
try:
|
| 549 |
-
if not os.path.exists(logs_path):
|
| 550 |
-
raise Exception("No model found.")
|
| 551 |
-
|
| 552 |
-
if not 'content' in parent_path:
|
| 553 |
-
save_folder = os.path.join(parent_path, 'RVC_Backup')
|
| 554 |
-
else:
|
| 555 |
-
save_folder = '/content/drive/MyDrive/RVC_Backup'
|
| 556 |
-
|
| 557 |
-
infos.append(i18n("Save model"))
|
| 558 |
-
yield "\n".join(infos)
|
| 559 |
-
|
| 560 |
-
if not os.path.exists(save_folder):
|
| 561 |
-
os.mkdir(save_folder)
|
| 562 |
-
if not os.path.exists(os.path.join(save_folder, 'ManualTrainingBackup')):
|
| 563 |
-
os.mkdir(os.path.join(save_folder, 'ManualTrainingBackup'))
|
| 564 |
-
if not os.path.exists(os.path.join(save_folder, 'Finished')):
|
| 565 |
-
os.mkdir(os.path.join(save_folder, 'Finished'))
|
| 566 |
-
|
| 567 |
-
if os.path.exists(zips_path):
|
| 568 |
-
shutil.rmtree(zips_path)
|
| 569 |
-
|
| 570 |
-
os.mkdir(zips_path)
|
| 571 |
-
added_file = glob.glob(os.path.join(logs_path, "added_*.index"))
|
| 572 |
-
d_file = glob.glob(os.path.join(logs_path, "D_*.pth"))
|
| 573 |
-
g_file = glob.glob(os.path.join(logs_path, "G_*.pth"))
|
| 574 |
-
|
| 575 |
-
if save_action == i18n("Choose the method"):
|
| 576 |
-
raise Exception("No method choosen.")
|
| 577 |
-
|
| 578 |
-
if save_action == i18n("Save all"):
|
| 579 |
-
print(i18n("Save all"))
|
| 580 |
-
save_folder = os.path.join(save_folder, 'ManualTrainingBackup')
|
| 581 |
-
shutil.copytree(logs_path, dst)
|
| 582 |
-
else:
|
| 583 |
-
if not os.path.exists(dst):
|
| 584 |
-
os.mkdir(dst)
|
| 585 |
-
|
| 586 |
-
if save_action == i18n("Save D and G"):
|
| 587 |
-
print(i18n("Save D and G"))
|
| 588 |
-
save_folder = os.path.join(save_folder, 'ManualTrainingBackup')
|
| 589 |
-
if len(d_file) > 0:
|
| 590 |
-
shutil.copy(d_file[0], dst)
|
| 591 |
-
if len(g_file) > 0:
|
| 592 |
-
shutil.copy(g_file[0], dst)
|
| 593 |
-
|
| 594 |
-
if len(added_file) > 0:
|
| 595 |
-
shutil.copy(added_file[0], dst)
|
| 596 |
-
else:
|
| 597 |
-
infos.append(i18n("Saved without index..."))
|
| 598 |
-
|
| 599 |
-
if save_action == i18n("Save voice"):
|
| 600 |
-
print(i18n("Save voice"))
|
| 601 |
-
save_folder = os.path.join(save_folder, 'Finished')
|
| 602 |
-
if len(added_file) > 0:
|
| 603 |
-
shutil.copy(added_file[0], dst)
|
| 604 |
-
else:
|
| 605 |
-
infos.append(i18n("Saved without index..."))
|
| 606 |
-
|
| 607 |
-
yield "\n".join(infos)
|
| 608 |
-
if not os.path.exists(weights_path):
|
| 609 |
-
infos.append(i18n("Saved without inference model..."))
|
| 610 |
-
else:
|
| 611 |
-
shutil.copy(weights_path, dst)
|
| 612 |
-
|
| 613 |
-
yield "\n".join(infos)
|
| 614 |
-
infos.append("\n" + i18n("This may take a few minutes, please wait..."))
|
| 615 |
-
yield "\n".join(infos)
|
| 616 |
-
|
| 617 |
-
shutil.make_archive(os.path.join(zips_path,f"{modelname}"), 'zip', zips_path)
|
| 618 |
-
shutil.move(os.path.join(zips_path,f"{modelname}.zip"), os.path.join(save_folder, f'{modelname}.zip'))
|
| 619 |
-
|
| 620 |
-
shutil.rmtree(zips_path)
|
| 621 |
-
infos.append("\n" + i18n("Model saved successfully"))
|
| 622 |
-
yield "\n".join(infos)
|
| 623 |
-
|
| 624 |
-
except Exception as e:
|
| 625 |
-
print(e)
|
| 626 |
-
if "No model found." in str(e):
|
| 627 |
-
infos.append(i18n("The model you want to save does not exist, be sure to enter the correct name."))
|
| 628 |
-
else:
|
| 629 |
-
infos.append(i18n("An error occurred saving the model"))
|
| 630 |
-
|
| 631 |
-
yield "\n".join(infos)
|
| 632 |
-
|
| 633 |
-
def load_downloaded_backup(url):
|
| 634 |
-
parent_path = find_folder_parent(".", "pretrained_v2")
|
| 635 |
-
try:
|
| 636 |
-
infos = []
|
| 637 |
-
logs_folders = ['0_gt_wavs','1_16k_wavs','2a_f0','2b-f0nsf','3_feature256','3_feature768']
|
| 638 |
-
zips_path = os.path.join(parent_path, 'zips')
|
| 639 |
-
unzips_path = os.path.join(parent_path, 'unzips')
|
| 640 |
-
weights_path = os.path.join(parent_path, 'weights')
|
| 641 |
-
logs_dir = os.path.join(parent_path, 'logs')
|
| 642 |
-
|
| 643 |
-
if os.path.exists(zips_path):
|
| 644 |
-
shutil.rmtree(zips_path)
|
| 645 |
-
if os.path.exists(unzips_path):
|
| 646 |
-
shutil.rmtree(unzips_path)
|
| 647 |
-
|
| 648 |
-
os.mkdir(zips_path)
|
| 649 |
-
os.mkdir(unzips_path)
|
| 650 |
-
|
| 651 |
-
download_file = download_from_url(url)
|
| 652 |
-
if not download_file:
|
| 653 |
-
print(i18n("The file could not be downloaded."))
|
| 654 |
-
infos.append(i18n("The file could not be downloaded."))
|
| 655 |
-
yield "\n".join(infos)
|
| 656 |
-
elif download_file == "downloaded":
|
| 657 |
-
print(i18n("It has been downloaded successfully."))
|
| 658 |
-
infos.append(i18n("It has been downloaded successfully."))
|
| 659 |
-
yield "\n".join(infos)
|
| 660 |
-
elif download_file == "too much use":
|
| 661 |
-
raise Exception(i18n("Too many users have recently viewed or downloaded this file"))
|
| 662 |
-
elif download_file == "private link":
|
| 663 |
-
raise Exception(i18n("Cannot get file from this private link"))
|
| 664 |
-
|
| 665 |
-
for filename in os.listdir(zips_path):
|
| 666 |
-
if filename.endswith(".zip"):
|
| 667 |
-
zipfile_path = os.path.join(zips_path,filename)
|
| 668 |
-
zip_dir_name = os.path.splitext(filename)[0]
|
| 669 |
-
unzip_dir = unzips_path
|
| 670 |
-
print(i18n("Proceeding with the extraction..."))
|
| 671 |
-
infos.append(i18n("Proceeding with the extraction..."))
|
| 672 |
-
shutil.unpack_archive(zipfile_path, unzip_dir, 'zip')
|
| 673 |
-
|
| 674 |
-
if os.path.exists(os.path.join(unzip_dir, zip_dir_name)):
|
| 675 |
-
shutil.move(os.path.join(unzip_dir, zip_dir_name), logs_dir)
|
| 676 |
-
else:
|
| 677 |
-
new_folder_path = os.path.join(logs_dir, zip_dir_name)
|
| 678 |
-
os.mkdir(new_folder_path)
|
| 679 |
-
for item_name in os.listdir(unzip_dir):
|
| 680 |
-
item_path = os.path.join(unzip_dir, item_name)
|
| 681 |
-
if os.path.isfile(item_path):
|
| 682 |
-
shutil.move(item_path, new_folder_path)
|
| 683 |
-
elif os.path.isdir(item_path):
|
| 684 |
-
shutil.move(item_path, new_folder_path)
|
| 685 |
-
|
| 686 |
-
yield "\n".join(infos)
|
| 687 |
-
else:
|
| 688 |
-
print(i18n("Unzip error."))
|
| 689 |
-
infos.append(i18n("Unzip error."))
|
| 690 |
-
yield "\n".join(infos)
|
| 691 |
-
|
| 692 |
-
result = ""
|
| 693 |
-
|
| 694 |
-
for filename in os.listdir(unzips_path):
|
| 695 |
-
if filename.endswith(".zip"):
|
| 696 |
-
silentremove(filename)
|
| 697 |
-
|
| 698 |
-
if os.path.exists(zips_path):
|
| 699 |
-
shutil.rmtree(zips_path)
|
| 700 |
-
if os.path.exists(os.path.join(parent_path, 'unzips')):
|
| 701 |
-
shutil.rmtree(os.path.join(parent_path, 'unzips'))
|
| 702 |
-
print(i18n("The Backup has been uploaded successfully."))
|
| 703 |
-
infos.append("\n" + i18n("The Backup has been uploaded successfully."))
|
| 704 |
-
yield "\n".join(infos)
|
| 705 |
-
os.chdir(parent_path)
|
| 706 |
-
return result
|
| 707 |
-
except Exception as e:
|
| 708 |
-
os.chdir(parent_path)
|
| 709 |
-
if "too much use" in str(e):
|
| 710 |
-
print(i18n("Too many users have recently viewed or downloaded this file"))
|
| 711 |
-
yield i18n("Too many users have recently viewed or downloaded this file")
|
| 712 |
-
elif "private link" in str(e):
|
| 713 |
-
print(i18n("Cannot get file from this private link"))
|
| 714 |
-
yield i18n("Cannot get file from this private link")
|
| 715 |
-
else:
|
| 716 |
-
print(e)
|
| 717 |
-
yield i18n("An error occurred downloading")
|
| 718 |
-
finally:
|
| 719 |
-
os.chdir(parent_path)
|
| 720 |
-
|
| 721 |
-
def save_to_wav(record_button):
|
| 722 |
-
if record_button is None:
|
| 723 |
-
pass
|
| 724 |
-
else:
|
| 725 |
-
path_to_file=record_button
|
| 726 |
-
new_name = datetime.datetime.now().strftime("%Y-%m-%d_%H-%M-%S")+'.wav'
|
| 727 |
-
new_path='./audios/'+new_name
|
| 728 |
-
shutil.move(path_to_file,new_path)
|
| 729 |
-
return new_name
|
| 730 |
-
|
| 731 |
-
|
| 732 |
-
def change_choices2():
|
| 733 |
-
audio_paths=[]
|
| 734 |
-
for filename in os.listdir("./audios"):
|
| 735 |
-
if filename.endswith(('wav', 'mp3', 'flac', 'ogg', 'opus',
|
| 736 |
-
'm4a', 'mp4', 'aac', 'alac', 'wma',
|
| 737 |
-
'aiff', 'webm', 'ac3')):
|
| 738 |
-
audio_paths.append(os.path.join('./audios',filename).replace('\\', '/'))
|
| 739 |
-
return {"choices": sorted(audio_paths), "__type__": "update"}, {"__type__": "update"}
|
| 740 |
-
|
| 741 |
-
|
| 742 |
-
|
| 743 |
-
|
| 744 |
-
|
| 745 |
-
def uvr(input_url, output_path, model_name, inp_root, save_root_vocal, paths, save_root_ins, agg, format0, architecture):
|
| 746 |
-
carpeta_a_eliminar = "yt_downloads"
|
| 747 |
-
if os.path.exists(carpeta_a_eliminar) and os.path.isdir(carpeta_a_eliminar):
|
| 748 |
-
for archivo in os.listdir(carpeta_a_eliminar):
|
| 749 |
-
ruta_archivo = os.path.join(carpeta_a_eliminar, archivo)
|
| 750 |
-
if os.path.isfile(ruta_archivo):
|
| 751 |
-
os.remove(ruta_archivo)
|
| 752 |
-
elif os.path.isdir(ruta_archivo):
|
| 753 |
-
shutil.rmtree(ruta_archivo)
|
| 754 |
-
|
| 755 |
-
|
| 756 |
-
|
| 757 |
-
ydl_opts = {
|
| 758 |
-
'no-windows-filenames': True,
|
| 759 |
-
'restrict-filenames': True,
|
| 760 |
-
'extract_audio': True,
|
| 761 |
-
'format': 'bestaudio',
|
| 762 |
-
'quiet': True,
|
| 763 |
-
'no-warnings': True,
|
| 764 |
-
}
|
| 765 |
-
|
| 766 |
-
try:
|
| 767 |
-
print(i18n("Downloading audio from the video..."))
|
| 768 |
-
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
|
| 769 |
-
info_dict = ydl.extract_info(input_url, download=False)
|
| 770 |
-
formatted_title = format_title(info_dict.get('title', 'default_title'))
|
| 771 |
-
formatted_outtmpl = output_path + '/' + formatted_title + '.wav'
|
| 772 |
-
ydl_opts['outtmpl'] = formatted_outtmpl
|
| 773 |
-
ydl = yt_dlp.YoutubeDL(ydl_opts)
|
| 774 |
-
ydl.download([input_url])
|
| 775 |
-
print(i18n("Audio downloaded!"))
|
| 776 |
-
except Exception as error:
|
| 777 |
-
print(i18n("An error occurred:"), error)
|
| 778 |
-
|
| 779 |
-
actual_directory = os.path.dirname(__file__)
|
| 780 |
-
|
| 781 |
-
vocal_directory = os.path.join(actual_directory, save_root_vocal)
|
| 782 |
-
instrumental_directory = os.path.join(actual_directory, save_root_ins)
|
| 783 |
-
|
| 784 |
-
vocal_formatted = f"vocal_{formatted_title}.wav.reformatted.wav_10.wav"
|
| 785 |
-
instrumental_formatted = f"instrument_{formatted_title}.wav.reformatted.wav_10.wav"
|
| 786 |
-
|
| 787 |
-
vocal_audio_path = os.path.join(vocal_directory, vocal_formatted)
|
| 788 |
-
instrumental_audio_path = os.path.join(instrumental_directory, instrumental_formatted)
|
| 789 |
-
|
| 790 |
-
vocal_formatted_mdx = f"{formatted_title}_vocal_.wav"
|
| 791 |
-
instrumental_formatted_mdx = f"{formatted_title}_instrument_.wav"
|
| 792 |
-
|
| 793 |
-
vocal_audio_path_mdx = os.path.join(vocal_directory, vocal_formatted_mdx)
|
| 794 |
-
instrumental_audio_path_mdx = os.path.join(instrumental_directory, instrumental_formatted_mdx)
|
| 795 |
-
|
| 796 |
-
if architecture == "VR":
|
| 797 |
-
try:
|
| 798 |
-
print(i18n("Starting audio conversion... (This might take a moment)"))
|
| 799 |
-
inp_root, save_root_vocal, save_root_ins = [x.strip(" ").strip('"').strip("\n").strip('"').strip(" ") for x in [inp_root, save_root_vocal, save_root_ins]]
|
| 800 |
-
usable_files = [os.path.join(inp_root, file)
|
| 801 |
-
for file in os.listdir(inp_root)
|
| 802 |
-
if file.endswith(tuple(sup_audioext))]
|
| 803 |
-
|
| 804 |
-
|
| 805 |
-
pre_fun = MDXNetDereverb(15) if model_name == "onnx_dereverb_By_FoxJoy" else (_audio_pre_ if "DeEcho" not in model_name else _audio_pre_new)(
|
| 806 |
-
agg=int(agg),
|
| 807 |
-
model_path=os.path.join(weight_uvr5_root, model_name + ".pth"),
|
| 808 |
-
device=config.device,
|
| 809 |
-
is_half=config.is_half,
|
| 810 |
-
)
|
| 811 |
-
|
| 812 |
-
try:
|
| 813 |
-
if paths != None:
|
| 814 |
-
paths = [path.name for path in paths]
|
| 815 |
-
else:
|
| 816 |
-
paths = usable_files
|
| 817 |
-
|
| 818 |
-
except:
|
| 819 |
-
traceback.print_exc()
|
| 820 |
-
paths = usable_files
|
| 821 |
-
print(paths)
|
| 822 |
-
for path in paths:
|
| 823 |
-
inp_path = os.path.join(inp_root, path)
|
| 824 |
-
need_reformat, done = 1, 0
|
| 825 |
-
|
| 826 |
-
try:
|
| 827 |
-
info = ffmpeg.probe(inp_path, cmd="ffprobe")
|
| 828 |
-
if info["streams"][0]["channels"] == 2 and info["streams"][0]["sample_rate"] == "44100":
|
| 829 |
-
need_reformat = 0
|
| 830 |
-
pre_fun._path_audio_(inp_path, save_root_ins, save_root_vocal, format0)
|
| 831 |
-
done = 1
|
| 832 |
-
except:
|
| 833 |
-
traceback.print_exc()
|
| 834 |
-
|
| 835 |
-
if need_reformat:
|
| 836 |
-
tmp_path = f"{tmp}/{os.path.basename(inp_path)}.reformatted.wav"
|
| 837 |
-
os.system(f"ffmpeg -i {inp_path} -vn -acodec pcm_s16le -ac 2 -ar 44100 {tmp_path} -y")
|
| 838 |
-
inp_path = tmp_path
|
| 839 |
-
|
| 840 |
-
try:
|
| 841 |
-
if not done:
|
| 842 |
-
pre_fun._path_audio_(inp_path, save_root_ins, save_root_vocal, format0)
|
| 843 |
-
print(f"{os.path.basename(inp_path)}->Success")
|
| 844 |
-
except:
|
| 845 |
-
print(f"{os.path.basename(inp_path)}->{traceback.format_exc()}")
|
| 846 |
-
except:
|
| 847 |
-
traceback.print_exc()
|
| 848 |
-
finally:
|
| 849 |
-
try:
|
| 850 |
-
if model_name == "onnx_dereverb_By_FoxJoy":
|
| 851 |
-
del pre_fun.pred.model
|
| 852 |
-
del pre_fun.pred.model_
|
| 853 |
-
else:
|
| 854 |
-
del pre_fun.model
|
| 855 |
-
|
| 856 |
-
del pre_fun
|
| 857 |
-
return i18n("Finished"), vocal_audio_path, instrumental_audio_path
|
| 858 |
-
except: traceback.print_exc()
|
| 859 |
-
|
| 860 |
-
if torch.cuda.is_available(): torch.cuda.empty_cache()
|
| 861 |
-
|
| 862 |
-
elif architecture == "MDX":
|
| 863 |
-
try:
|
| 864 |
-
print(i18n("Starting audio conversion... (This might take a moment)"))
|
| 865 |
-
inp_root, save_root_vocal, save_root_ins = [x.strip(" ").strip('"').strip("\n").strip('"').strip(" ") for x in [inp_root, save_root_vocal, save_root_ins]]
|
| 866 |
-
|
| 867 |
-
usable_files = [os.path.join(inp_root, file)
|
| 868 |
-
for file in os.listdir(inp_root)
|
| 869 |
-
if file.endswith(tuple(sup_audioext))]
|
| 870 |
-
try:
|
| 871 |
-
if paths != None:
|
| 872 |
-
paths = [path.name for path in paths]
|
| 873 |
-
else:
|
| 874 |
-
paths = usable_files
|
| 875 |
-
|
| 876 |
-
except:
|
| 877 |
-
traceback.print_exc()
|
| 878 |
-
paths = usable_files
|
| 879 |
-
print(paths)
|
| 880 |
-
invert=True
|
| 881 |
-
denoise=True
|
| 882 |
-
use_custom_parameter=True
|
| 883 |
-
dim_f=2048
|
| 884 |
-
dim_t=256
|
| 885 |
-
n_fft=7680
|
| 886 |
-
use_custom_compensation=True
|
| 887 |
-
compensation=1.025
|
| 888 |
-
suffix = "vocal_" #@param ["Vocals", "Drums", "Bass", "Other"]{allow-input: true}
|
| 889 |
-
suffix_invert = "instrument_" #@param ["Instrumental", "Drumless", "Bassless", "Instruments"]{allow-input: true}
|
| 890 |
-
print_settings = True # @param{type:"boolean"}
|
| 891 |
-
onnx = id_to_ptm(model_name)
|
| 892 |
-
compensation = compensation if use_custom_compensation or use_custom_parameter else None
|
| 893 |
-
mdx_model = prepare_mdx(onnx,use_custom_parameter, dim_f, dim_t, n_fft, compensation=compensation)
|
| 894 |
-
|
| 895 |
-
|
| 896 |
-
for path in paths:
|
| 897 |
-
#inp_path = os.path.join(inp_root, path)
|
| 898 |
-
suffix_naming = suffix if use_custom_parameter else None
|
| 899 |
-
diff_suffix_naming = suffix_invert if use_custom_parameter else None
|
| 900 |
-
run_mdx(onnx, mdx_model, path, format0, diff=invert,suffix=suffix_naming,diff_suffix=diff_suffix_naming,denoise=denoise)
|
| 901 |
-
|
| 902 |
-
if print_settings:
|
| 903 |
-
print()
|
| 904 |
-
print('[MDX-Net_Colab settings used]')
|
| 905 |
-
print(f'Model used: {onnx}')
|
| 906 |
-
print(f'Model MD5: {mdx.MDX.get_hash(onnx)}')
|
| 907 |
-
print(f'Model parameters:')
|
| 908 |
-
print(f' -dim_f: {mdx_model.dim_f}')
|
| 909 |
-
print(f' -dim_t: {mdx_model.dim_t}')
|
| 910 |
-
print(f' -n_fft: {mdx_model.n_fft}')
|
| 911 |
-
print(f' -compensation: {mdx_model.compensation}')
|
| 912 |
-
print()
|
| 913 |
-
print('[Input file]')
|
| 914 |
-
print('filename(s): ')
|
| 915 |
-
for filename in paths:
|
| 916 |
-
print(f' -{filename}')
|
| 917 |
-
print(f"{os.path.basename(filename)}->Success")
|
| 918 |
-
except:
|
| 919 |
-
traceback.print_exc()
|
| 920 |
-
finally:
|
| 921 |
-
try:
|
| 922 |
-
del mdx_model
|
| 923 |
-
return i18n("Finished"), vocal_audio_path_mdx, instrumental_audio_path_mdx
|
| 924 |
-
except: traceback.print_exc()
|
| 925 |
-
|
| 926 |
-
print("clean_empty_cache")
|
| 927 |
-
|
| 928 |
-
if torch.cuda.is_available(): torch.cuda.empty_cache()
|
| 929 |
-
sup_audioext = {'wav', 'mp3', 'flac', 'ogg', 'opus',
|
| 930 |
-
'm4a', 'mp4', 'aac', 'alac', 'wma',
|
| 931 |
-
'aiff', 'webm', 'ac3'}
|
| 932 |
-
|
| 933 |
-
def load_downloaded_audio(url):
|
| 934 |
-
parent_path = find_folder_parent(".", "pretrained_v2")
|
| 935 |
-
try:
|
| 936 |
-
infos = []
|
| 937 |
-
audios_path = os.path.join(parent_path, 'audios')
|
| 938 |
-
zips_path = os.path.join(parent_path, 'zips')
|
| 939 |
-
|
| 940 |
-
if not os.path.exists(audios_path):
|
| 941 |
-
os.mkdir(audios_path)
|
| 942 |
-
|
| 943 |
-
download_file = download_from_url(url)
|
| 944 |
-
if not download_file:
|
| 945 |
-
print(i18n("The file could not be downloaded."))
|
| 946 |
-
infos.append(i18n("The file could not be downloaded."))
|
| 947 |
-
yield "\n".join(infos)
|
| 948 |
-
elif download_file == "downloaded":
|
| 949 |
-
print(i18n("It has been downloaded successfully."))
|
| 950 |
-
infos.append(i18n("It has been downloaded successfully."))
|
| 951 |
-
yield "\n".join(infos)
|
| 952 |
-
elif download_file == "too much use":
|
| 953 |
-
raise Exception(i18n("Too many users have recently viewed or downloaded this file"))
|
| 954 |
-
elif download_file == "private link":
|
| 955 |
-
raise Exception(i18n("Cannot get file from this private link"))
|
| 956 |
-
|
| 957 |
-
for filename in os.listdir(zips_path):
|
| 958 |
-
item_path = os.path.join(zips_path, filename)
|
| 959 |
-
if item_path.split('.')[-1] in sup_audioext:
|
| 960 |
-
if os.path.exists(item_path):
|
| 961 |
-
shutil.move(item_path, audios_path)
|
| 962 |
-
|
| 963 |
-
result = ""
|
| 964 |
-
print(i18n("Audio files have been moved to the 'audios' folder."))
|
| 965 |
-
infos.append(i18n("Audio files have been moved to the 'audios' folder."))
|
| 966 |
-
yield "\n".join(infos)
|
| 967 |
-
|
| 968 |
-
os.chdir(parent_path)
|
| 969 |
-
return result
|
| 970 |
-
except Exception as e:
|
| 971 |
-
os.chdir(parent_path)
|
| 972 |
-
if "too much use" in str(e):
|
| 973 |
-
print(i18n("Too many users have recently viewed or downloaded this file"))
|
| 974 |
-
yield i18n("Too many users have recently viewed or downloaded this file")
|
| 975 |
-
elif "private link" in str(e):
|
| 976 |
-
print(i18n("Cannot get file from this private link"))
|
| 977 |
-
yield i18n("Cannot get file from this private link")
|
| 978 |
-
else:
|
| 979 |
-
print(e)
|
| 980 |
-
yield i18n("An error occurred downloading")
|
| 981 |
-
finally:
|
| 982 |
-
os.chdir(parent_path)
|
| 983 |
-
|
| 984 |
-
|
| 985 |
-
class error_message(Exception):
|
| 986 |
-
def __init__(self, mensaje):
|
| 987 |
-
self.mensaje = mensaje
|
| 988 |
-
super().__init__(mensaje)
|
| 989 |
-
|
| 990 |
-
def get_vc(sid, to_return_protect0, to_return_protect1):
|
| 991 |
-
global n_spk, tgt_sr, net_g, vc, cpt, version
|
| 992 |
-
if sid == "" or sid == []:
|
| 993 |
-
global hubert_model
|
| 994 |
-
if hubert_model is not None:
|
| 995 |
-
print("clean_empty_cache")
|
| 996 |
-
del net_g, n_spk, vc, hubert_model, tgt_sr
|
| 997 |
-
hubert_model = net_g = n_spk = vc = hubert_model = tgt_sr = None
|
| 998 |
-
if torch.cuda.is_available():
|
| 999 |
-
torch.cuda.empty_cache()
|
| 1000 |
-
if_f0 = cpt.get("f0", 1)
|
| 1001 |
-
version = cpt.get("version", "v1")
|
| 1002 |
-
if version == "v1":
|
| 1003 |
-
if if_f0 == 1:
|
| 1004 |
-
net_g = SynthesizerTrnMs256NSFsid(
|
| 1005 |
-
*cpt["config"], is_half=config.is_half
|
| 1006 |
-
)
|
| 1007 |
-
else:
|
| 1008 |
-
net_g = SynthesizerTrnMs256NSFsid_nono(*cpt["config"])
|
| 1009 |
-
elif version == "v2":
|
| 1010 |
-
if if_f0 == 1:
|
| 1011 |
-
net_g = SynthesizerTrnMs768NSFsid(
|
| 1012 |
-
*cpt["config"], is_half=config.is_half
|
| 1013 |
-
)
|
| 1014 |
-
else:
|
| 1015 |
-
net_g = SynthesizerTrnMs768NSFsid_nono(*cpt["config"])
|
| 1016 |
-
del net_g, cpt
|
| 1017 |
-
if torch.cuda.is_available():
|
| 1018 |
-
torch.cuda.empty_cache()
|
| 1019 |
-
cpt = None
|
| 1020 |
-
return (
|
| 1021 |
-
{"visible": False, "__type__": "update"},
|
| 1022 |
-
{"visible": False, "__type__": "update"},
|
| 1023 |
-
{"visible": False, "__type__": "update"},
|
| 1024 |
-
)
|
| 1025 |
-
person = "%s/%s" % (weight_root, sid)
|
| 1026 |
-
print("loading %s" % person)
|
| 1027 |
-
cpt = torch.load(person, map_location="cpu")
|
| 1028 |
-
tgt_sr = cpt["config"][-1]
|
| 1029 |
-
cpt["config"][-3] = cpt["weight"]["emb_g.weight"].shape[0]
|
| 1030 |
-
if_f0 = cpt.get("f0", 1)
|
| 1031 |
-
if if_f0 == 0:
|
| 1032 |
-
to_return_protect0 = to_return_protect1 = {
|
| 1033 |
-
"visible": False,
|
| 1034 |
-
"value": 0.5,
|
| 1035 |
-
"__type__": "update",
|
| 1036 |
-
}
|
| 1037 |
-
else:
|
| 1038 |
-
to_return_protect0 = {
|
| 1039 |
-
"visible": True,
|
| 1040 |
-
"value": to_return_protect0,
|
| 1041 |
-
"__type__": "update",
|
| 1042 |
-
}
|
| 1043 |
-
to_return_protect1 = {
|
| 1044 |
-
"visible": True,
|
| 1045 |
-
"value": to_return_protect1,
|
| 1046 |
-
"__type__": "update",
|
| 1047 |
-
}
|
| 1048 |
-
version = cpt.get("version", "v1")
|
| 1049 |
-
if version == "v1":
|
| 1050 |
-
if if_f0 == 1:
|
| 1051 |
-
net_g = SynthesizerTrnMs256NSFsid(*cpt["config"], is_half=config.is_half)
|
| 1052 |
-
else:
|
| 1053 |
-
net_g = SynthesizerTrnMs256NSFsid_nono(*cpt["config"])
|
| 1054 |
-
elif version == "v2":
|
| 1055 |
-
if if_f0 == 1:
|
| 1056 |
-
net_g = SynthesizerTrnMs768NSFsid(*cpt["config"], is_half=config.is_half)
|
| 1057 |
-
else:
|
| 1058 |
-
net_g = SynthesizerTrnMs768NSFsid_nono(*cpt["config"])
|
| 1059 |
-
del net_g.enc_q
|
| 1060 |
-
print(net_g.load_state_dict(cpt["weight"], strict=False))
|
| 1061 |
-
net_g.eval().to(config.device)
|
| 1062 |
-
if config.is_half:
|
| 1063 |
-
net_g = net_g.half()
|
| 1064 |
-
else:
|
| 1065 |
-
net_g = net_g.float()
|
| 1066 |
-
vc = VC(tgt_sr, config)
|
| 1067 |
-
n_spk = cpt["config"][-3]
|
| 1068 |
-
return (
|
| 1069 |
-
{"visible": True, "maximum": n_spk, "__type__": "update"},
|
| 1070 |
-
to_return_protect0,
|
| 1071 |
-
to_return_protect1,
|
| 1072 |
-
)
|
| 1073 |
-
|
| 1074 |
-
def update_model_choices(select_value):
|
| 1075 |
-
model_ids = get_model_list()
|
| 1076 |
-
model_ids_list = list(model_ids)
|
| 1077 |
-
if select_value == "VR":
|
| 1078 |
-
return {"choices": uvr5_names, "__type__": "update"}
|
| 1079 |
-
elif select_value == "MDX":
|
| 1080 |
-
return {"choices": model_ids_list, "__type__": "update"}
|
| 1081 |
-
|
| 1082 |
-
def download_model():
|
| 1083 |
-
gr.Markdown(value="# " + i18n("Download Model"))
|
| 1084 |
-
gr.Markdown(value=i18n("It is used to download your inference models."))
|
| 1085 |
-
with gr.Row():
|
| 1086 |
-
model_url=gr.Textbox(label=i18n("Url:"))
|
| 1087 |
-
with gr.Row():
|
| 1088 |
-
download_model_status_bar=gr.Textbox(label=i18n("Status:"))
|
| 1089 |
-
with gr.Row():
|
| 1090 |
-
download_button=gr.Button(i18n("Download"))
|
| 1091 |
-
download_button.click(fn=load_downloaded_model, inputs=[model_url], outputs=[download_model_status_bar])
|
| 1092 |
-
|
| 1093 |
-
def download_backup():
|
| 1094 |
-
gr.Markdown(value="# " + i18n("Download Backup"))
|
| 1095 |
-
gr.Markdown(value=i18n("It is used to download your training backups."))
|
| 1096 |
-
with gr.Row():
|
| 1097 |
-
model_url=gr.Textbox(label=i18n("Url:"))
|
| 1098 |
-
with gr.Row():
|
| 1099 |
-
download_model_status_bar=gr.Textbox(label=i18n("Status:"))
|
| 1100 |
-
with gr.Row():
|
| 1101 |
-
download_button=gr.Button(i18n("Download"))
|
| 1102 |
-
download_button.click(fn=load_downloaded_backup, inputs=[model_url], outputs=[download_model_status_bar])
|
| 1103 |
-
|
| 1104 |
-
def update_dataset_list(name):
|
| 1105 |
-
new_datasets = []
|
| 1106 |
-
for foldername in os.listdir("./datasets"):
|
| 1107 |
-
if "." not in foldername:
|
| 1108 |
-
new_datasets.append(os.path.join(find_folder_parent(".","pretrained"),"datasets",foldername))
|
| 1109 |
-
return gr.Dropdown.update(choices=new_datasets)
|
| 1110 |
-
|
| 1111 |
-
def download_dataset(trainset_dir4):
|
| 1112 |
-
gr.Markdown(value="# " + i18n("Download Dataset"))
|
| 1113 |
-
gr.Markdown(value=i18n("Download the dataset with the audios in a compatible format (.wav/.flac) to train your model."))
|
| 1114 |
-
with gr.Row():
|
| 1115 |
-
dataset_url=gr.Textbox(label=i18n("Url:"))
|
| 1116 |
-
with gr.Row():
|
| 1117 |
-
load_dataset_status_bar=gr.Textbox(label=i18n("Status:"))
|
| 1118 |
-
with gr.Row():
|
| 1119 |
-
load_dataset_button=gr.Button(i18n("Download"))
|
| 1120 |
-
load_dataset_button.click(fn=load_dowloaded_dataset, inputs=[dataset_url], outputs=[load_dataset_status_bar])
|
| 1121 |
-
load_dataset_status_bar.change(update_dataset_list, dataset_url, trainset_dir4)
|
| 1122 |
-
|
| 1123 |
-
def download_audio():
|
| 1124 |
-
gr.Markdown(value="# " + i18n("Download Audio"))
|
| 1125 |
-
gr.Markdown(value=i18n("Download audios of any format for use in inference (recommended for mobile users)."))
|
| 1126 |
-
with gr.Row():
|
| 1127 |
-
audio_url=gr.Textbox(label=i18n("Url:"))
|
| 1128 |
-
with gr.Row():
|
| 1129 |
-
download_audio_status_bar=gr.Textbox(label=i18n("Status:"))
|
| 1130 |
-
with gr.Row():
|
| 1131 |
-
download_button2=gr.Button(i18n("Download"))
|
| 1132 |
-
download_button2.click(fn=load_downloaded_audio, inputs=[audio_url], outputs=[download_audio_status_bar])
|
| 1133 |
-
|
| 1134 |
-
def youtube_separator():
|
| 1135 |
-
gr.Markdown(value="# " + i18n("Separate YouTube tracks"))
|
| 1136 |
-
gr.Markdown(value=i18n("Download audio from a YouTube video and automatically separate the vocal and instrumental tracks"))
|
| 1137 |
-
with gr.Row():
|
| 1138 |
-
input_url = gr.inputs.Textbox(label=i18n("Enter the YouTube link:"))
|
| 1139 |
-
output_path = gr.Textbox(
|
| 1140 |
-
label=i18n("Enter the path of the audio folder to be processed (copy it from the address bar of the file manager):"),
|
| 1141 |
-
value=os.path.abspath(os.getcwd()).replace('\\', '/') + "/yt_downloads",
|
| 1142 |
-
visible=False,
|
| 1143 |
-
)
|
| 1144 |
-
advanced_settings_checkbox = gr.Checkbox(
|
| 1145 |
-
value=False,
|
| 1146 |
-
label=i18n("Advanced Settings"),
|
| 1147 |
-
interactive=True,
|
| 1148 |
-
)
|
| 1149 |
-
with gr.Row(label = i18n("Advanced Settings"), visible=False, variant='compact') as advanced_settings:
|
| 1150 |
-
with gr.Column():
|
| 1151 |
-
model_select = gr.Radio(
|
| 1152 |
-
label=i18n("Model Architecture:"),
|
| 1153 |
-
choices=["VR", "MDX"],
|
| 1154 |
-
value="VR",
|
| 1155 |
-
interactive=True,
|
| 1156 |
-
)
|
| 1157 |
-
model_choose = gr.Dropdown(label=i18n("Model: (Be aware that in some models the named vocal will be the instrumental)"),
|
| 1158 |
-
choices=uvr5_names,
|
| 1159 |
-
value="HP5_only_main_vocal"
|
| 1160 |
-
)
|
| 1161 |
-
with gr.Row():
|
| 1162 |
-
agg = gr.Slider(
|
| 1163 |
-
minimum=0,
|
| 1164 |
-
maximum=20,
|
| 1165 |
-
step=1,
|
| 1166 |
-
label=i18n("Vocal Extraction Aggressive"),
|
| 1167 |
-
value=10,
|
| 1168 |
-
interactive=True,
|
| 1169 |
-
)
|
| 1170 |
-
with gr.Row():
|
| 1171 |
-
opt_vocal_root = gr.Textbox(
|
| 1172 |
-
label=i18n("Specify the output folder for vocals:"), value="audios",
|
| 1173 |
-
)
|
| 1174 |
-
opt_ins_root = gr.Textbox(
|
| 1175 |
-
label=i18n("Specify the output folder for accompaniment:"), value="audio-others",
|
| 1176 |
-
)
|
| 1177 |
-
dir_wav_input = gr.Textbox(
|
| 1178 |
-
label=i18n("Enter the path of the audio folder to be processed:"),
|
| 1179 |
-
value=((os.getcwd()).replace('\\', '/') + "/yt_downloads"),
|
| 1180 |
-
visible=False,
|
| 1181 |
-
)
|
| 1182 |
-
format0 = gr.Radio(
|
| 1183 |
-
label=i18n("Export file format"),
|
| 1184 |
-
choices=["wav", "flac", "mp3", "m4a"],
|
| 1185 |
-
value="wav",
|
| 1186 |
-
visible=False,
|
| 1187 |
-
interactive=True,
|
| 1188 |
-
)
|
| 1189 |
-
wav_inputs = gr.File(
|
| 1190 |
-
file_count="multiple", label=i18n("You can also input audio files in batches. Choose one of the two options. Priority is given to reading from the folder."),
|
| 1191 |
-
visible=False,
|
| 1192 |
-
)
|
| 1193 |
-
model_select.change(
|
| 1194 |
-
fn=update_model_choices,
|
| 1195 |
-
inputs=model_select,
|
| 1196 |
-
outputs=model_choose,
|
| 1197 |
-
)
|
| 1198 |
-
with gr.Row():
|
| 1199 |
-
vc_output4 = gr.Textbox(label=i18n("Status:"))
|
| 1200 |
-
vc_output5 = gr.Audio(label=i18n("Vocal"), type='filepath')
|
| 1201 |
-
vc_output6 = gr.Audio(label=i18n("Instrumental"), type='filepath')
|
| 1202 |
-
with gr.Row():
|
| 1203 |
-
but2 = gr.Button(i18n("Download and Separate"))
|
| 1204 |
-
but2.click(
|
| 1205 |
-
uvr,
|
| 1206 |
-
[
|
| 1207 |
-
input_url,
|
| 1208 |
-
output_path,
|
| 1209 |
-
model_choose,
|
| 1210 |
-
dir_wav_input,
|
| 1211 |
-
opt_vocal_root,
|
| 1212 |
-
wav_inputs,
|
| 1213 |
-
opt_ins_root,
|
| 1214 |
-
agg,
|
| 1215 |
-
format0,
|
| 1216 |
-
model_select
|
| 1217 |
-
],
|
| 1218 |
-
[vc_output4, vc_output5, vc_output6],
|
| 1219 |
-
)
|
| 1220 |
-
def toggle_advanced_settings(checkbox):
|
| 1221 |
-
return {"visible": checkbox, "__type__": "update"}
|
| 1222 |
-
|
| 1223 |
-
advanced_settings_checkbox.change(
|
| 1224 |
-
fn=toggle_advanced_settings,
|
| 1225 |
-
inputs=[advanced_settings_checkbox],
|
| 1226 |
-
outputs=[advanced_settings]
|
| 1227 |
-
)
|
| 1228 |
-
|
| 1229 |
-
|
| 1230 |
-
def get_bark_voice():
|
| 1231 |
-
mensaje = """
|
| 1232 |
-
v2/en_speaker_0 English Male
|
| 1233 |
-
v2/en_speaker_1 English Male
|
| 1234 |
-
v2/en_speaker_2 English Male
|
| 1235 |
-
v2/en_speaker_3 English Male
|
| 1236 |
-
v2/en_speaker_4 English Male
|
| 1237 |
-
v2/en_speaker_5 English Male
|
| 1238 |
-
v2/en_speaker_6 English Male
|
| 1239 |
-
v2/en_speaker_7 English Male
|
| 1240 |
-
v2/en_speaker_8 English Male
|
| 1241 |
-
v2/en_speaker_9 English Female
|
| 1242 |
-
v2/zh_speaker_0 Chinese (Simplified) Male
|
| 1243 |
-
v2/zh_speaker_1 Chinese (Simplified) Male
|
| 1244 |
-
v2/zh_speaker_2 Chinese (Simplified) Male
|
| 1245 |
-
v2/zh_speaker_3 Chinese (Simplified) Male
|
| 1246 |
-
v2/zh_speaker_4 Chinese (Simplified) Female
|
| 1247 |
-
v2/zh_speaker_5 Chinese (Simplified) Male
|
| 1248 |
-
v2/zh_speaker_6 Chinese (Simplified) Female
|
| 1249 |
-
v2/zh_speaker_7 Chinese (Simplified) Female
|
| 1250 |
-
v2/zh_speaker_8 Chinese (Simplified) Male
|
| 1251 |
-
v2/zh_speaker_9 Chinese (Simplified) Female
|
| 1252 |
-
v2/fr_speaker_0 French Male
|
| 1253 |
-
v2/fr_speaker_1 French Female
|
| 1254 |
-
v2/fr_speaker_2 French Female
|
| 1255 |
-
v2/fr_speaker_3 French Male
|
| 1256 |
-
v2/fr_speaker_4 French Male
|
| 1257 |
-
v2/fr_speaker_5 French Female
|
| 1258 |
-
v2/fr_speaker_6 French Male
|
| 1259 |
-
v2/fr_speaker_7 French Male
|
| 1260 |
-
v2/fr_speaker_8 French Male
|
| 1261 |
-
v2/fr_speaker_9 French Male
|
| 1262 |
-
v2/de_speaker_0 German Male
|
| 1263 |
-
v2/de_speaker_1 German Male
|
| 1264 |
-
v2/de_speaker_2 German Male
|
| 1265 |
-
v2/de_speaker_3 German Female
|
| 1266 |
-
v2/de_speaker_4 German Male
|
| 1267 |
-
v2/de_speaker_5 German Male
|
| 1268 |
-
v2/de_speaker_6 German Male
|
| 1269 |
-
v2/de_speaker_7 German Male
|
| 1270 |
-
v2/de_speaker_8 German Female
|
| 1271 |
-
v2/de_speaker_9 German Male
|
| 1272 |
-
v2/hi_speaker_0 Hindi Female
|
| 1273 |
-
v2/hi_speaker_1 Hindi Female
|
| 1274 |
-
v2/hi_speaker_2 Hindi Male
|
| 1275 |
-
v2/hi_speaker_3 Hindi Female
|
| 1276 |
-
v2/hi_speaker_4 Hindi Female
|
| 1277 |
-
v2/hi_speaker_5 Hindi Male
|
| 1278 |
-
v2/hi_speaker_6 Hindi Male
|
| 1279 |
-
v2/hi_speaker_7 Hindi Male
|
| 1280 |
-
v2/hi_speaker_8 Hindi Male
|
| 1281 |
-
v2/hi_speaker_9 Hindi Female
|
| 1282 |
-
v2/it_speaker_0 Italian Male
|
| 1283 |
-
v2/it_speaker_1 Italian Male
|
| 1284 |
-
v2/it_speaker_2 Italian Female
|
| 1285 |
-
v2/it_speaker_3 Italian Male
|
| 1286 |
-
v2/it_speaker_4 Italian Male
|
| 1287 |
-
v2/it_speaker_5 Italian Male
|
| 1288 |
-
v2/it_speaker_6 Italian Male
|
| 1289 |
-
v2/it_speaker_7 Italian Female
|
| 1290 |
-
v2/it_speaker_8 Italian Male
|
| 1291 |
-
v2/it_speaker_9 Italian Female
|
| 1292 |
-
v2/ja_speaker_0 Japanese Female
|
| 1293 |
-
v2/ja_speaker_1 Japanese Female
|
| 1294 |
-
v2/ja_speaker_2 Japanese Male
|
| 1295 |
-
v2/ja_speaker_3 Japanese Female
|
| 1296 |
-
v2/ja_speaker_4 Japanese Female
|
| 1297 |
-
v2/ja_speaker_5 Japanese Female
|
| 1298 |
-
v2/ja_speaker_6 Japanese Male
|
| 1299 |
-
v2/ja_speaker_7 Japanese Female
|
| 1300 |
-
v2/ja_speaker_8 Japanese Female
|
| 1301 |
-
v2/ja_speaker_9 Japanese Female
|
| 1302 |
-
v2/ko_speaker_0 Korean Female
|
| 1303 |
-
v2/ko_speaker_1 Korean Male
|
| 1304 |
-
v2/ko_speaker_2 Korean Male
|
| 1305 |
-
v2/ko_speaker_3 Korean Male
|
| 1306 |
-
v2/ko_speaker_4 Korean Male
|
| 1307 |
-
v2/ko_speaker_5 Korean Male
|
| 1308 |
-
v2/ko_speaker_6 Korean Male
|
| 1309 |
-
v2/ko_speaker_7 Korean Male
|
| 1310 |
-
v2/ko_speaker_8 Korean Male
|
| 1311 |
-
v2/ko_speaker_9 Korean Male
|
| 1312 |
-
v2/pl_speaker_0 Polish Male
|
| 1313 |
-
v2/pl_speaker_1 Polish Male
|
| 1314 |
-
v2/pl_speaker_2 Polish Male
|
| 1315 |
-
v2/pl_speaker_3 Polish Male
|
| 1316 |
-
v2/pl_speaker_4 Polish Female
|
| 1317 |
-
v2/pl_speaker_5 Polish Male
|
| 1318 |
-
v2/pl_speaker_6 Polish Female
|
| 1319 |
-
v2/pl_speaker_7 Polish Male
|
| 1320 |
-
v2/pl_speaker_8 Polish Male
|
| 1321 |
-
v2/pl_speaker_9 Polish Female
|
| 1322 |
-
v2/pt_speaker_0 Portuguese Male
|
| 1323 |
-
v2/pt_speaker_1 Portuguese Male
|
| 1324 |
-
v2/pt_speaker_2 Portuguese Male
|
| 1325 |
-
v2/pt_speaker_3 Portuguese Male
|
| 1326 |
-
v2/pt_speaker_4 Portuguese Male
|
| 1327 |
-
v2/pt_speaker_5 Portuguese Male
|
| 1328 |
-
v2/pt_speaker_6 Portuguese Male
|
| 1329 |
-
v2/pt_speaker_7 Portuguese Male
|
| 1330 |
-
v2/pt_speaker_8 Portuguese Male
|
| 1331 |
-
v2/pt_speaker_9 Portuguese Male
|
| 1332 |
-
v2/ru_speaker_0 Russian Male
|
| 1333 |
-
v2/ru_speaker_1 Russian Male
|
| 1334 |
-
v2/ru_speaker_2 Russian Male
|
| 1335 |
-
v2/ru_speaker_3 Russian Male
|
| 1336 |
-
v2/ru_speaker_4 Russian Male
|
| 1337 |
-
v2/ru_speaker_5 Russian Female
|
| 1338 |
-
v2/ru_speaker_6 Russian Female
|
| 1339 |
-
v2/ru_speaker_7 Russian Male
|
| 1340 |
-
v2/ru_speaker_8 Russian Male
|
| 1341 |
-
v2/ru_speaker_9 Russian Female
|
| 1342 |
-
v2/es_speaker_0 Spanish Male
|
| 1343 |
-
v2/es_speaker_1 Spanish Male
|
| 1344 |
-
v2/es_speaker_2 Spanish Male
|
| 1345 |
-
v2/es_speaker_3 Spanish Male
|
| 1346 |
-
v2/es_speaker_4 Spanish Male
|
| 1347 |
-
v2/es_speaker_5 Spanish Male
|
| 1348 |
-
v2/es_speaker_6 Spanish Male
|
| 1349 |
-
v2/es_speaker_7 Spanish Male
|
| 1350 |
-
v2/es_speaker_8 Spanish Female
|
| 1351 |
-
v2/es_speaker_9 Spanish Female
|
| 1352 |
-
v2/tr_speaker_0 Turkish Male
|
| 1353 |
-
v2/tr_speaker_1 Turkish Male
|
| 1354 |
-
v2/tr_speaker_2 Turkish Male
|
| 1355 |
-
v2/tr_speaker_3 Turkish Male
|
| 1356 |
-
v2/tr_speaker_4 Turkish Female
|
| 1357 |
-
v2/tr_speaker_5 Turkish Female
|
| 1358 |
-
v2/tr_speaker_6 Turkish Male
|
| 1359 |
-
v2/tr_speaker_7 Turkish Male
|
| 1360 |
-
v2/tr_speaker_8 Turkish Male
|
| 1361 |
-
v2/tr_speaker_9 Turkish Male
|
| 1362 |
-
"""
|
| 1363 |
-
# Dividir el mensaje en líneas
|
| 1364 |
-
lineas = mensaje.split("\n")
|
| 1365 |
-
datos_deseados = []
|
| 1366 |
-
for linea in lineas:
|
| 1367 |
-
partes = linea.split("\t")
|
| 1368 |
-
if len(partes) == 3:
|
| 1369 |
-
clave, _, genero = partes
|
| 1370 |
-
datos_deseados.append(f"{clave}-{genero}")
|
| 1371 |
-
|
| 1372 |
-
return datos_deseados
|
| 1373 |
-
|
| 1374 |
-
|
| 1375 |
-
def get_edge_voice():
|
| 1376 |
-
completed_process = subprocess.run(['edge-tts',"-l"], capture_output=True, text=True)
|
| 1377 |
-
lines = completed_process.stdout.strip().split("\n")
|
| 1378 |
-
data = []
|
| 1379 |
-
current_entry = {}
|
| 1380 |
-
for line in lines:
|
| 1381 |
-
if line.startswith("Name: "):
|
| 1382 |
-
if current_entry:
|
| 1383 |
-
data.append(current_entry)
|
| 1384 |
-
current_entry = {"Name": line.split(": ")[1]}
|
| 1385 |
-
elif line.startswith("Gender: "):
|
| 1386 |
-
current_entry["Gender"] = line.split(": ")[1]
|
| 1387 |
-
if current_entry:
|
| 1388 |
-
data.append(current_entry)
|
| 1389 |
-
tts_voice = []
|
| 1390 |
-
for entry in data:
|
| 1391 |
-
name = entry["Name"]
|
| 1392 |
-
gender = entry["Gender"]
|
| 1393 |
-
formatted_entry = f'{name}-{gender}'
|
| 1394 |
-
tts_voice.append(formatted_entry)
|
| 1395 |
-
return tts_voice
|
| 1396 |
-
|
| 1397 |
-
|
| 1398 |
-
#print(set_tts_voice)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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