voice-changer/server/const.py

66 lines
1.6 KiB
Python
Raw Normal View History

2023-01-28 08:01:23 +03:00
import os
import sys
2023-01-15 23:22:27 +03:00
import tempfile
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