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-04-28 00:39:51 +03:00
|
|
|
ModelType: TypeAlias = Literal[
|
|
|
|
"MMVCv15",
|
|
|
|
"MMVCv13",
|
|
|
|
"so-vits-svc-40v2",
|
|
|
|
"so-vits-svc-40",
|
|
|
|
"so-vits-svc-40_c",
|
|
|
|
"DDSP-SVC",
|
|
|
|
"RVC",
|
|
|
|
]
|
2023-01-08 11:58:27 +03:00
|
|
|
|
|
|
|
ERROR_NO_ONNX_SESSION = "ERROR_NO_ONNX_SESSION"
|
|
|
|
|
2023-01-15 23:31:49 +03:00
|
|
|
|
|
|
|
tmpdir = tempfile.TemporaryDirectory()
|
2023-01-16 01:26:24 +03:00
|
|
|
# print("generate tmpdir:::",tmpdir)
|
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-04-28 00:39:51 +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") # type: ignore
|
|
|
|
if hasattr(sys, "_MEIPASS")
|
|
|
|
else "voice-changer-native-client"
|
|
|
|
)
|
|
|
|
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-04-28 00:39:51 +03:00
|
|
|
HUBERT_ONNX_MODEL_PATH = (
|
|
|
|
os.path.join(sys._MEIPASS, "model_hubert/hubert_simple.onnx") # type: ignore
|
|
|
|
if hasattr(sys, "_MEIPASS")
|
|
|
|
else "model_hubert/hubert_simple.onnx"
|
|
|
|
)
|
2023-03-30 18:53:00 +03:00
|
|
|
|
2023-01-28 08:01:23 +03:00
|
|
|
|
2023-04-28 00:39:51 +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-04-28 00:39:51 +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-05-02 14:57:12 +03:00
|
|
|
# "hubert_base", "contentvec", "distilhubert"
|
2023-05-02 06:11:00 +03:00
|
|
|
class EnumEmbedderTypes(Enum):
|
2023-05-02 14:57:12 +03:00
|
|
|
hubert = "hubert_base"
|
2023-05-02 06:11:00 +03:00
|
|
|
contentvec = "contentvec"
|
2023-05-02 14:57:12 +03:00
|
|
|
hubert_jp = "hubert-base-japanese"
|
|
|
|
|
|
|
|
|
|
|
|
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"
|
|
|
|
onnxRVC = "onnxRVC"
|
|
|
|
onnxRVCNono = "onnxRVCNono"
|
|
|
|
|
|
|
|
|
2023-05-02 16:29:28 +03:00
|
|
|
class EnumPitchExtractorTypes(Enum):
|
|
|
|
harvest = "harvest"
|
|
|
|
dio = "dio"
|
2023-05-20 10:33:17 +03:00
|
|
|
crepe = "crepe"
|
2023-05-02 16:29:28 +03:00
|
|
|
|
|
|
|
|
2023-05-02 14:57:12 +03:00
|
|
|
class EnumFrameworkTypes(Enum):
|
|
|
|
pyTorch = "pyTorch"
|
|
|
|
onnx = "onnx"
|
2023-05-06 22:18:18 +03:00
|
|
|
|
|
|
|
|
|
|
|
class ServerAudioDeviceTypes(Enum):
|
|
|
|
audioinput = "audioinput"
|
|
|
|
audiooutput = "audiooutput"
|
2023-05-16 04:38:23 +03:00
|
|
|
|
|
|
|
|
2023-05-20 09:54:00 +03:00
|
|
|
SAMPLES_JSONS = [
|
2023-05-25 05:40:37 +03:00
|
|
|
# "https://huggingface.co/wok000/vcclient_model/raw/main/samples_0001.json",
|
|
|
|
# "https://huggingface.co/wok000/vcclient_model/raw/main/samples_0002.json",
|
2023-05-31 14:07:12 +03:00
|
|
|
"https://huggingface.co/wok000/vcclient_model/raw/main/samples_0003_t.json",
|
2023-05-31 08:30:35 +03:00
|
|
|
"https://huggingface.co/wok000/vcclient_model/raw/main/samples_0003_o.json",
|
|
|
|
# "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-05-20 09:54:00 +03:00
|
|
|
]
|
2023-05-31 08:30:35 +03:00
|
|
|
|
|
|
|
SAMPLE_MODEL_IDS = [
|
|
|
|
("TokinaShigure_o", True),
|
|
|
|
("KikotoMahiro_o", False),
|
|
|
|
("Amitaro_o", False),
|
|
|
|
("Tsukuyomi-chan_o", False),
|
|
|
|
# オフィシャルモデルテスト
|
|
|
|
# ("test-official-v1-f0-48k-l9-hubert_t", True),
|
|
|
|
# ("test-official-v1-nof0-48k-l9-hubert_t", False),
|
|
|
|
# ("test-official-v2-f0-40k-l12-hubert_t", False),
|
|
|
|
# ("test-official-v2-nof0-40k-l12-hubert_t", False),
|
|
|
|
# ("test-official-v1-f0-48k-l9-hubert_o", True),
|
|
|
|
# ("test-official-v1-nof0-48k-l9-hubert_o", False),
|
|
|
|
# ("test-official-v2-f0-40k-l12-hubert_o", False),
|
|
|
|
# ("test-official-v2-nof0-40k-l12-hubert_o", False),
|
|
|
|
# DDPNモデルテスト(torch)
|
|
|
|
# ("test-ddpn-v1-f0-48k-l9-hubert_t", False),
|
|
|
|
# ("test-ddpn-v1-nof0-48k-l9-hubert_t", False),
|
|
|
|
# ("test-ddpn-v2-f0-40k-l12-hubert_t", False),
|
|
|
|
# ("test-ddpn-v2-nof0-40k-l12-hubert_t", False),
|
|
|
|
# ("test-ddpn-v2-f0-40k-l12-hubert_jp_t", False),
|
|
|
|
# ("test-ddpn-v2-nof0-40k-l12-hubert_jp_t", False),
|
|
|
|
# DDPNモデルテスト(onnx)
|
|
|
|
# ("test-ddpn-v1-f0-48k-l9-hubert_o", False),
|
|
|
|
# ("test-ddpn-v1-nof0-48k-l9-hubert_o", False),
|
|
|
|
# ("test-ddpn-v2-f0-40k-l12-hubert_o", False),
|
|
|
|
# ("test-ddpn-v2-nof0-40k-l12-hubert_o", False),
|
|
|
|
# ("test-ddpn-v2-f0-40k-l12-hubert_jp_o", False),
|
|
|
|
# ("test-ddpn-v2-nof0-40k-l12-hubert_jp_o", False),
|
|
|
|
]
|
|
|
|
|
|
|
|
|
2023-05-17 20:51:40 +03:00
|
|
|
RVC_MODEL_DIRNAME = "rvc"
|
2023-05-30 20:26:16 +03:00
|
|
|
RVC_MAX_SLOT_NUM = 10
|