initial refactor of rvc studio
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
from functools import lru_cache
|
||||
import os
|
||||
|
||||
from ...lib import BASE_CACHE_DIR, PersistedDict
|
||||
|
||||
MENU_ITEMS = {
|
||||
"Get help": "https://github.com/SayanoAI/RVC-Studio/discussions",
|
||||
"Report a Bug": "https://github.com/SayanoAI/RVC-Studio/issues",
|
||||
"About": """This project provides a comprehensive platform for training RVC models and generating AI voice covers.
|
||||
Check out this github for more info: https://github.com/SayanoAI/RVC-Studio
|
||||
"""
|
||||
}
|
||||
|
||||
DEVICE_OPTIONS = ["cpu","cuda"]
|
||||
PITCH_EXTRACTION_OPTIONS = ["rmvpe","rmvpe+"]
|
||||
MERGE_OPTIONS=["median","mean","min","max"]
|
||||
TTS_MODELS = ["edge","speecht5"]
|
||||
N_THREADS_OPTIONS=[1,2,4,8,12,16]
|
||||
SR_MAP = {"32k": 32000,"40k": 40000, "48k": 48000}
|
||||
|
||||
@lru_cache
|
||||
def get_servers():
|
||||
os.makedirs(BASE_CACHE_DIR,exist_ok=True)
|
||||
fname = os.path.join(BASE_CACHE_DIR,"servers.shelve")
|
||||
servers = PersistedDict(fname)
|
||||
return servers
|
||||
|
||||
SERVERS = get_servers()
|
||||
RVC_INFERENCE_URL = SERVERS.RVC_INFERENCE_URL
|
||||
UVR_INFERENCE_URL = SERVERS.UVR_INFERENCE_URL
|
||||
@@ -0,0 +1,121 @@
|
||||
import re
|
||||
from typing import IO, List, Tuple
|
||||
import unicodedata
|
||||
import requests
|
||||
import os
|
||||
import zipfile
|
||||
|
||||
from ...lib import BASE_CACHE_DIR, BASE_MODELS_DIR
|
||||
|
||||
RVC_DOWNLOAD_LINK = 'https://huggingface.co/datasets/SayanoAI/RVC-Studio/resolve/main/'
|
||||
MDX_MODELS = ["MDXNET/UVR-MDX-NET-vocal_FT.onnx"]
|
||||
KARAFAN_MODELS = ["karafan/MDX23C-8KFFT-InstVoc_HQ.ckpt"]
|
||||
VR_MODELS = ["UVR/UVR-DeEcho-DeReverb.pth","UVR/HP5-vocals+instrumentals.pth"]
|
||||
RVC_MODELS = [
|
||||
"RVC/Claire.pth",
|
||||
"RVC/Sayano.pth",
|
||||
"RVC/Mae_v2.pth",
|
||||
"RVC/Fuji.pth",
|
||||
"RVC/Monika.pth"]
|
||||
BASE_MODELS = ["hubert_base.pt", "rmvpe.pt"]
|
||||
VITS_MODELS = ["VITS/pretrained_ljs.pth"]
|
||||
PRETRAINED_MODELS = [
|
||||
"pretrained_v2/D48k.pth",
|
||||
"pretrained_v2/G48k.pth",
|
||||
"pretrained_v2/D32k.pth",
|
||||
"pretrained_v2/G32k.pth",
|
||||
"pretrained_v2/D40k.pth",
|
||||
"pretrained_v2/G40k.pth",
|
||||
"pretrained_v2/f0D48k.pth",
|
||||
"pretrained_v2/f0G48k.pth",
|
||||
"pretrained_v2/f0D40k.pth",
|
||||
"pretrained_v2/f0G40k.pth",
|
||||
"pretrained_v2/f0D32k.pth",
|
||||
"pretrained_v2/f0G32k.pth",
|
||||
|
||||
"pretrained_v2/f0_RIN_E3_40k_D.pth",
|
||||
"pretrained_v2/f0_RIN_E3_40k_G.pth",
|
||||
"pretrained_v2/f0Ov2Super32kD.pth",
|
||||
"pretrained_v2/f0Ov2Super32kG.pth",
|
||||
"pretrained_v2/f0Ov2Super40kD.pth",
|
||||
"pretrained_v2/f0Ov2Super40kG.pth",
|
||||
]
|
||||
LLM_MODELS = [
|
||||
"https://huggingface.co/TheBloke/Airoboros-L2-7B-2.1-GGUF/resolve/main/airoboros-l2-7b-2.1.Q4_K_M.gguf",
|
||||
"https://huggingface.co/TheBloke/Pygmalion-2-7B-GGUF/resolve/main/pygmalion-2-7b.Q4_K_M.gguf",
|
||||
"https://huggingface.co/TheBloke/Zarablend-MX-L2-7B-GGUF/resolve/main/zarablend-mx-l2-7b.Q4_K_M.gguf",
|
||||
"https://huggingface.co/TheBloke/MythoMax-L2-Kimiko-v2-13B-GGUF/resolve/main/mythomax-l2-kimiko-v2-13b.Q4_K_M.gguf"
|
||||
]
|
||||
STT_MODELS = [
|
||||
"https://alphacephei.com/vosk/models/vosk-model-en-us-0.22-lgraph.zip"
|
||||
]
|
||||
|
||||
def download_file(params: Tuple[str, str]):
|
||||
model_path, download_link = params
|
||||
if os.path.isfile(model_path): raise FileExistsError(f"{model_path} already exists!")
|
||||
os.makedirs(os.path.dirname(model_path), exist_ok=True)
|
||||
|
||||
with requests.get(download_link,stream=True) as r:
|
||||
r.raise_for_status()
|
||||
with open(model_path, 'wb') as f:
|
||||
for chunk in r.iter_content(chunk_size=8192):
|
||||
f.write(chunk)
|
||||
return True
|
||||
|
||||
def download_link_generator(download_link: str,model_list: List[str]):
|
||||
for model in model_list:
|
||||
model_path = os.path.join(BASE_MODELS_DIR,model)
|
||||
yield (model_path, f"{download_link}{model}")
|
||||
|
||||
def save_file(params: Tuple[str, any]):
|
||||
(data_path, datum) = params
|
||||
if "zip" in os.path.splitext(data_path)[-1]: return save_zipped_files(params) # unzip
|
||||
else:
|
||||
try:
|
||||
with open(data_path,"wb") as f:
|
||||
f.write(datum)
|
||||
return f"Successfully saved file to: {data_path}"
|
||||
except Exception as e:
|
||||
return f"Failed to save file: {e}"
|
||||
|
||||
def save_file_generator(save_dir: str, data: List[IO]):
|
||||
for datum in data:
|
||||
data_path = os.path.join(save_dir,datum.name)
|
||||
yield (data_path, datum.read())
|
||||
|
||||
def save_zipped_files(params: Tuple[str, any]):
|
||||
(data_path, datum) = params
|
||||
|
||||
try:
|
||||
print(f"saving zip file: {data_path}")
|
||||
temp_dir = os.path.join(BASE_CACHE_DIR,"zips")
|
||||
os.makedirs(temp_dir,exist_ok=True)
|
||||
name = os.path.basename(data_path)
|
||||
zip_path = os.path.join(temp_dir,name)
|
||||
|
||||
with open(zip_path,"wb") as f:
|
||||
f.write(datum)
|
||||
|
||||
print(f"extracting zip file: {zip_path}")
|
||||
with zipfile.ZipFile(zip_path, 'r') as zip_ref:
|
||||
zip_ref.extractall(os.path.dirname(data_path))
|
||||
print(f"finished extracting zip file")
|
||||
|
||||
os.remove(zip_path) # cleanup
|
||||
return f"Successfully saved files to: {data_path}"
|
||||
except Exception as e:
|
||||
return f"Failed to save files: {e}"
|
||||
|
||||
def slugify_filepath(filepath):
|
||||
# Split the path into directory and filename
|
||||
directory, filename = os.path.split(filepath)
|
||||
# Normalize the filename
|
||||
filename = unicodedata.normalize('NFKD', filename)
|
||||
# Encode the filename as ASCII and ignore errors
|
||||
filename = filename.encode('ascii', 'ignore').decode()
|
||||
# Convert the filename to lowercase
|
||||
filename = filename.lower()
|
||||
# Replace spaces and other unwanted characters with dashes
|
||||
filename = re.sub(r'[^a-z0-9.-]+', '-', filename)
|
||||
# Join the directory and the slugified filename
|
||||
return os.path.join(directory, filename)
|
||||
Reference in New Issue
Block a user