2023-05-02 06:11:00 +03:00
|
|
|
from enum import Enum
|
2023-01-28 08:01:23 +03:00
|
|
|
import os
|
|
|
|
import sys
|
2023-01-15 23:22:27 +03:00
|
|
|
import tempfile
|
2023-04-10 03:05:14 +03:00
|
|
|
from typing import Literal, TypeAlias
|
|
|
|
|
|
|
|
|
2023-06-16 10:49:55 +03:00
|
|
|
VoiceChangerType: TypeAlias = Literal[
|
|
|
|
"MMVCv13",
|
|
|
|
"MMVCv15",
|
|
|
|
"so-vits-svc-40",
|
|
|
|
"DDSP-SVC",
|
|
|
|
"RVC",
|
2023-08-09 10:55:59 +03:00
|
|
|
"Diffusion-SVC",
|
|
|
|
"Beatrice",
|
2023-04-28 00:39:51 +03:00
|
|
|
]
|
2023-01-08 11:58:27 +03:00
|
|
|
|
2023-06-25 18:51:25 +03:00
|
|
|
STORED_SETTING_FILE = "stored_setting.json"
|
2023-01-15 23:31:49 +03:00
|
|
|
|
2023-07-01 08:57:57 +03:00
|
|
|
SERVER_DEVICE_SAMPLE_RATES = [16000, 32000, 44100, 48000, 96000, 192000]
|
|
|
|
|
2023-01-15 23:31:49 +03:00
|
|
|
tmpdir = tempfile.TemporaryDirectory()
|
2023-01-28 08:01:23 +03:00
|
|
|
SSL_KEY_DIR = os.path.join(tmpdir.name, "keys") if hasattr(sys, "_MEIPASS") else "keys"
|
2023-01-15 23:31:49 +03:00
|
|
|
MODEL_DIR = os.path.join(tmpdir.name, "logs") if hasattr(sys, "_MEIPASS") else "logs"
|
2023-06-16 10:49:55 +03:00
|
|
|
UPLOAD_DIR = os.path.join(tmpdir.name, "upload_dir") if hasattr(sys, "_MEIPASS") else "upload_dir"
|
|
|
|
NATIVE_CLIENT_FILE_WIN = os.path.join(sys._MEIPASS, "voice-changer-native-client.exe") if hasattr(sys, "_MEIPASS") else "voice-changer-native-client" # type: ignore
|
2023-04-28 00:39:51 +03:00
|
|
|
NATIVE_CLIENT_FILE_MAC = (
|
|
|
|
os.path.join(
|
|
|
|
sys._MEIPASS, # type: ignore
|
|
|
|
"voice-changer-native-client.app",
|
|
|
|
"Contents",
|
|
|
|
"MacOS",
|
|
|
|
"voice-changer-native-client",
|
|
|
|
)
|
|
|
|
if hasattr(sys, "_MEIPASS")
|
|
|
|
else "voice-changer-native-client"
|
|
|
|
)
|
2023-01-28 08:01:23 +03:00
|
|
|
|
2023-06-16 10:49:55 +03:00
|
|
|
HUBERT_ONNX_MODEL_PATH = os.path.join(sys._MEIPASS, "model_hubert/hubert_simple.onnx") if hasattr(sys, "_MEIPASS") else "model_hubert/hubert_simple.onnx" # type: ignore
|
2023-03-30 18:53:00 +03:00
|
|
|
|
2023-01-28 08:01:23 +03:00
|
|
|
|
2023-06-16 10:49:55 +03:00
|
|
|
TMP_DIR = os.path.join(tmpdir.name, "tmp_dir") if hasattr(sys, "_MEIPASS") else "tmp_dir"
|
2023-02-14 23:02:51 +03:00
|
|
|
os.makedirs(TMP_DIR, exist_ok=True)
|
|
|
|
|
2023-03-08 03:48:50 +03:00
|
|
|
|
|
|
|
def getFrontendPath():
|
2023-06-16 10:49:55 +03:00
|
|
|
frontend_path = os.path.join(sys._MEIPASS, "dist") if hasattr(sys, "_MEIPASS") else "../client/demo/dist"
|
2023-03-08 03:48:50 +03:00
|
|
|
return frontend_path
|
2023-05-02 06:11:00 +03:00
|
|
|
|
|
|
|
|
2023-07-06 21:56:45 +03:00
|
|
|
EmbedderType: TypeAlias = Literal[
|
|
|
|
"hubert_base",
|
|
|
|
"contentvec",
|
|
|
|
"hubert-base-japanese"
|
|
|
|
]
|
2023-05-02 14:57:12 +03:00
|
|
|
|
|
|
|
|
|
|
|
class EnumInferenceTypes(Enum):
|
|
|
|
pyTorchRVC = "pyTorchRVC"
|
|
|
|
pyTorchRVCNono = "pyTorchRVCNono"
|
2023-05-20 09:54:00 +03:00
|
|
|
pyTorchRVCv2 = "pyTorchRVCv2"
|
|
|
|
pyTorchRVCv2Nono = "pyTorchRVCv2Nono"
|
2023-05-02 14:57:12 +03:00
|
|
|
pyTorchWebUI = "pyTorchWebUI"
|
|
|
|
pyTorchWebUINono = "pyTorchWebUINono"
|
2023-06-24 04:33:57 +03:00
|
|
|
pyTorchVoRASbeta = "pyTorchVoRASbeta"
|
2023-05-02 14:57:12 +03:00
|
|
|
onnxRVC = "onnxRVC"
|
|
|
|
onnxRVCNono = "onnxRVCNono"
|
|
|
|
|
|
|
|
|
2023-07-13 21:33:04 +03:00
|
|
|
DiffusionSVCInferenceType: TypeAlias = Literal[
|
|
|
|
"combo",
|
|
|
|
]
|
|
|
|
|
|
|
|
|
2023-07-06 20:17:29 +03:00
|
|
|
PitchExtractorType: TypeAlias = Literal[
|
|
|
|
"harvest",
|
|
|
|
"dio",
|
|
|
|
"crepe",
|
|
|
|
"crepe_full",
|
|
|
|
"crepe_tiny",
|
2023-07-15 03:17:19 +03:00
|
|
|
"rmvpe",
|
2023-07-06 20:17:29 +03:00
|
|
|
]
|
2023-05-06 22:18:18 +03:00
|
|
|
|
2023-07-06 20:23:20 +03:00
|
|
|
ServerAudioDeviceType: TypeAlias = Literal[
|
|
|
|
"audioinput",
|
|
|
|
"audiooutput"
|
|
|
|
]
|
2023-05-16 04:38:23 +03:00
|
|
|
|
2023-06-16 10:49:55 +03:00
|
|
|
RVCSampleMode: TypeAlias = Literal[
|
|
|
|
"production",
|
|
|
|
"testOfficial",
|
|
|
|
"testDDPNTorch",
|
|
|
|
"testDDPNONNX",
|
|
|
|
"testONNXFull",
|
|
|
|
]
|
2023-06-04 23:00:57 +03:00
|
|
|
|
|
|
|
|
2023-06-16 10:49:55 +03:00
|
|
|
def getSampleJsonAndModelIds(mode: RVCSampleMode):
|
|
|
|
if mode == "production":
|
2023-06-04 23:00:57 +03:00
|
|
|
return [
|
|
|
|
# "https://huggingface.co/wok000/vcclient_model/raw/main/samples_0001.json",
|
|
|
|
# "https://huggingface.co/wok000/vcclient_model/raw/main/samples_0002.json",
|
2023-06-16 10:49:55 +03:00
|
|
|
"https://huggingface.co/wok000/vcclient_model/raw/main/samples_0003_t2.json",
|
|
|
|
"https://huggingface.co/wok000/vcclient_model/raw/main/samples_0003_o2.json",
|
2023-07-21 12:25:28 +03:00
|
|
|
"https://huggingface.co/wok000/vcclient_model/raw/main/samples_0003_d2.json",
|
2023-06-04 23:00:57 +03:00
|
|
|
], [
|
2023-06-16 10:49:55 +03:00
|
|
|
("Tsukuyomi-chan_o", {"useIndex": False}),
|
2023-06-17 21:51:09 +03:00
|
|
|
("Amitaro_o", {"useIndex": False}),
|
2023-06-18 03:25:23 +03:00
|
|
|
("KikotoMahiro_o", {"useIndex": False}),
|
|
|
|
("TokinaShigure_o", {"useIndex": True}),
|
2023-07-21 12:25:28 +03:00
|
|
|
("diffusion_combo_spk5_nl3_dl20_k50_500ep", {}),
|
|
|
|
("diffusion_combo_spk5_nl3_dl1_k50_500ep", {}),
|
2023-06-04 23:00:57 +03:00
|
|
|
]
|
2023-08-09 12:22:18 +03:00
|
|
|
elif mode == "testAll":
|
|
|
|
return [
|
|
|
|
"https://huggingface.co/wok000/vcclient_model/raw/main/test/test_official_v1_v2.json",
|
|
|
|
"https://huggingface.co/wok000/vcclient_model/raw/main/test/test_ddpn_v1_v2.json",
|
|
|
|
], [
|
|
|
|
("test-official-v1-f0-48k-l9-hubert_t", {"useIndex": True}),
|
|
|
|
("test-official-v1-nof0-48k-l9-hubert_t", {"useIndex": False}),
|
|
|
|
("test-official-v2-f0-40k-l12-hubert_t", {"useIndex": False}),
|
|
|
|
("test-official-v2-nof0-40k-l12-hubert_t", {"useIndex": False}),
|
|
|
|
("test-official-v1-f0-48k-l9-hubert_o", {"useIndex": True}),
|
|
|
|
("test-official-v1-nof0-48k-l9-hubert_o", {"useIndex": False}),
|
|
|
|
("test-official-v2-f0-40k-l12-hubert_o", {"useIndex": False}),
|
|
|
|
("test-official-v2-nof0-40k-l12-hubert_o", {"useIndex": False}),
|
|
|
|
("test-ddpn-v1-f0-48k-l9-hubert_t", {"useIndex": False}),
|
|
|
|
("test-ddpn-v1-nof0-48k-l9-hubert_t", {"useIndex": False}),
|
|
|
|
("test-ddpn-v2-f0-40k-l12-hubert_t", {"useIndex": False}),
|
|
|
|
("test-ddpn-v2-nof0-40k-l12-hubert_t", {"useIndex": False}),
|
|
|
|
("test-ddpn-v2-f0-40k-l12-hubert_jp_t", {"useIndex": False}),
|
|
|
|
("test-ddpn-v2-nof0-40k-l12-hubert_jp_t", {"useIndex": False}),
|
|
|
|
("test-ddpn-v1-f0-48k-l9-hubert_o", {"useIndex": False}),
|
|
|
|
("test-ddpn-v1-nof0-48k-l9-hubert_o", {"useIndex": False}),
|
|
|
|
("test-ddpn-v2-f0-40k-l12-hubert_o", {"useIndex": False}),
|
|
|
|
("test-ddpn-v2-nof0-40k-l12-hubert_o", {"useIndex": False}),
|
|
|
|
("test-ddpn-v2-f0-40k-l12-hubert_jp_o", {"useIndex": False}),
|
|
|
|
("test-ddpn-v2-nof0-40k-l12-hubert_jp_o", {"useIndex": False}),
|
|
|
|
("test-official-v1-f0-48k-l9-hubert_o_full", {"useIndex": False}),
|
|
|
|
("test-official-v1-nof0-48k-l9-hubert_o_full", {"useIndex": False}),
|
|
|
|
("test-official-v2-f0-40k-l12-hubert_o_full", {"useIndex": False}),
|
|
|
|
("test-official-v2-nof0-40k-l12-hubert_o_full", {"useIndex": False}),
|
|
|
|
("test-ddpn-v1-f0-48k-l9-hubert_o_full", {"useIndex": False}),
|
|
|
|
("test-ddpn-v1-nof0-48k-l9-hubert_o_full", {"useIndex": False}),
|
|
|
|
("test-ddpn-v2-f0-40k-l12-hubert_o_full", {"useIndex": False}),
|
|
|
|
("test-ddpn-v2-nof0-40k-l12-hubert_o_full", {"useIndex": False}),
|
|
|
|
("test-ddpn-v2-f0-40k-l12-hubert_jp_o_full", {"useIndex": False}),
|
|
|
|
("test-ddpn-v2-nof0-40k-l12-hubert_jp_o_full", {"useIndex": False}),
|
|
|
|
|
|
|
|
]
|
2023-06-16 10:49:55 +03:00
|
|
|
elif mode == "testOfficial":
|
2023-06-04 23:00:57 +03:00
|
|
|
return [
|
|
|
|
"https://huggingface.co/wok000/vcclient_model/raw/main/test/test_official_v1_v2.json",
|
|
|
|
"https://huggingface.co/wok000/vcclient_model/raw/main/test/test_ddpn_v1_v2.json",
|
|
|
|
], [
|
2023-06-16 10:49:55 +03:00
|
|
|
("test-official-v1-f0-48k-l9-hubert_t", {"useIndex": True}),
|
|
|
|
("test-official-v1-nof0-48k-l9-hubert_t", {"useIndex": False}),
|
|
|
|
("test-official-v2-f0-40k-l12-hubert_t", {"useIndex": False}),
|
|
|
|
("test-official-v2-nof0-40k-l12-hubert_t", {"useIndex": False}),
|
|
|
|
("test-official-v1-f0-48k-l9-hubert_o", {"useIndex": True}),
|
|
|
|
("test-official-v1-nof0-48k-l9-hubert_o", {"useIndex": False}),
|
|
|
|
("test-official-v2-f0-40k-l12-hubert_o", {"useIndex": False}),
|
|
|
|
("test-official-v2-nof0-40k-l12-hubert_o", {"useIndex": False}),
|
2023-06-04 23:00:57 +03:00
|
|
|
]
|
2023-06-16 10:49:55 +03:00
|
|
|
elif mode == "testDDPNTorch":
|
2023-06-04 23:00:57 +03:00
|
|
|
return [
|
|
|
|
"https://huggingface.co/wok000/vcclient_model/raw/main/test/test_official_v1_v2.json",
|
|
|
|
"https://huggingface.co/wok000/vcclient_model/raw/main/test/test_ddpn_v1_v2.json",
|
|
|
|
], [
|
2023-06-16 10:49:55 +03:00
|
|
|
("test-ddpn-v1-f0-48k-l9-hubert_t", {"useIndex": False}),
|
|
|
|
("test-ddpn-v1-nof0-48k-l9-hubert_t", {"useIndex": False}),
|
|
|
|
("test-ddpn-v2-f0-40k-l12-hubert_t", {"useIndex": False}),
|
|
|
|
("test-ddpn-v2-nof0-40k-l12-hubert_t", {"useIndex": False}),
|
|
|
|
("test-ddpn-v2-f0-40k-l12-hubert_jp_t", {"useIndex": False}),
|
|
|
|
("test-ddpn-v2-nof0-40k-l12-hubert_jp_t", {"useIndex": False}),
|
2023-06-04 23:00:57 +03:00
|
|
|
]
|
2023-06-16 10:49:55 +03:00
|
|
|
elif mode == "testDDPNONNX":
|
2023-06-04 23:00:57 +03:00
|
|
|
return [
|
|
|
|
"https://huggingface.co/wok000/vcclient_model/raw/main/test/test_official_v1_v2.json",
|
|
|
|
"https://huggingface.co/wok000/vcclient_model/raw/main/test/test_ddpn_v1_v2.json",
|
|
|
|
], [
|
2023-06-16 10:49:55 +03:00
|
|
|
("test-ddpn-v1-f0-48k-l9-hubert_o", {"useIndex": False}),
|
|
|
|
("test-ddpn-v1-nof0-48k-l9-hubert_o", {"useIndex": False}),
|
|
|
|
("test-ddpn-v2-f0-40k-l12-hubert_o", {"useIndex": False}),
|
|
|
|
("test-ddpn-v2-nof0-40k-l12-hubert_o", {"useIndex": False}),
|
|
|
|
("test-ddpn-v2-f0-40k-l12-hubert_jp_o", {"useIndex": False}),
|
|
|
|
("test-ddpn-v2-nof0-40k-l12-hubert_jp_o", {"useIndex": False}),
|
2023-06-04 23:00:57 +03:00
|
|
|
]
|
2023-06-16 10:49:55 +03:00
|
|
|
elif mode == "testONNXFull":
|
2023-06-04 23:00:57 +03:00
|
|
|
return [
|
|
|
|
"https://huggingface.co/wok000/vcclient_model/raw/main/test/test_official_v1_v2.json",
|
|
|
|
"https://huggingface.co/wok000/vcclient_model/raw/main/test/test_ddpn_v1_v2.json",
|
|
|
|
], [
|
2023-06-16 10:49:55 +03:00
|
|
|
("test-official-v1-f0-48k-l9-hubert_o_full", {"useIndex": False}),
|
|
|
|
("test-official-v1-nof0-48k-l9-hubert_o_full", {"useIndex": False}),
|
|
|
|
("test-official-v2-f0-40k-l12-hubert_o_full", {"useIndex": False}),
|
|
|
|
("test-official-v2-nof0-40k-l12-hubert_o_full", {"useIndex": False}),
|
|
|
|
("test-ddpn-v1-f0-48k-l9-hubert_o_full", {"useIndex": False}),
|
|
|
|
("test-ddpn-v1-nof0-48k-l9-hubert_o_full", {"useIndex": False}),
|
|
|
|
("test-ddpn-v2-f0-40k-l12-hubert_o_full", {"useIndex": False}),
|
|
|
|
("test-ddpn-v2-nof0-40k-l12-hubert_o_full", {"useIndex": False}),
|
|
|
|
("test-ddpn-v2-f0-40k-l12-hubert_jp_o_full", {"useIndex": False}),
|
|
|
|
("test-ddpn-v2-nof0-40k-l12-hubert_jp_o_full", {"useIndex": False}),
|
2023-06-04 23:00:57 +03:00
|
|
|
]
|
|
|
|
else:
|
|
|
|
return [], []
|
2023-05-31 08:30:35 +03:00
|
|
|
|
|
|
|
|
2023-05-17 20:51:40 +03:00
|
|
|
RVC_MODEL_DIRNAME = "rvc"
|
2023-07-27 19:05:54 +03:00
|
|
|
MAX_SLOT_NUM = 200
|