Spaces:
Sleeping
Sleeping
File size: 4,055 Bytes
61cc64e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | """Configuration and constants for RVC Voice Conversion."""
from __future__ import annotations
import logging
import os
import sys
from pathlib import Path
import torch
# ββ Path bootstrap ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
BASE_DIR = Path(__file__).parent.parent
sys.path.insert(0, str(BASE_DIR))
MODELS_DIR = BASE_DIR / "rvc_models"
OUTPUT_DIR = BASE_DIR / "outputs"
MODELS_DIR.mkdir(exist_ok=True)
OUTPUT_DIR.mkdir(exist_ok=True)
os.environ.setdefault("URVC_MODELS_DIR", str(MODELS_DIR / "urvc"))
# ββ Logging βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s [%(levelname)s] %(name)s: %(message)s",
datefmt="%H:%M:%S",
)
for _noisy in ("httpx", "httpcore", "faiss", "faiss.loader", "transformers", "torch"):
logging.getLogger(_noisy).setLevel(logging.WARNING)
logger = logging.getLogger("rvc_space")
# ββ CPU threading βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
try:
NUM_CORES = len(os.sched_getaffinity(0))
except AttributeError:
NUM_CORES = os.cpu_count() or 1
torch.set_num_threads(NUM_CORES)
torch.set_num_interop_threads(NUM_CORES)
os.environ["OMP_NUM_THREADS"] = str(NUM_CORES)
os.environ["MKL_NUM_THREADS"] = str(NUM_CORES)
os.environ["NUMEXPR_NUM_THREADS"] = str(NUM_CORES)
os.environ["OPENBLAS_NUM_THREADS"] = str(NUM_CORES)
torch.set_float32_matmul_precision("high")
torch.backends.mkldnn.enabled = True
logger.info("CPU threads: %d | matmul: high | oneDNN: enabled", NUM_CORES)
# ββ Device ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
if torch.cuda.is_available():
DEVICE = "cuda"
DEVICE_LABEL = f"π’ GPU Β· {torch.cuda.get_device_name(0)}"
else:
DEVICE = "cpu"
DEVICE_LABEL = f"π΅ CPU Β· {NUM_CORES} cores"
logger.info("Device: %s", DEVICE_LABEL)
# ββ Constants βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
MAX_INPUT_DURATION = 300 # 5 minutes
OUTPUT_TTL_SECONDS = 3600 # 1 hour
MAX_JOBS = 100
# ββ Built-in models βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
BUILTIN_MODELS = [
{
"name": "Vestia Zeta v1",
"url": "https://huggingface.co/megaaziib/my-rvc-models-collection/resolve/main/zeta.zip",
},
{
"name": "Vestia Zeta v2",
"url": "https://huggingface.co/megaaziib/my-rvc-models-collection/resolve/main/zetaTest.zip",
},
{
"name": "Ayunda Risu",
"url": "https://huggingface.co/megaaziib/my-rvc-models-collection/resolve/main/risu.zip",
},
{
"name": "Gawr Gura",
"url": "https://huggingface.co/Gigrig/GigrigRVC/resolve/41d46f087b9c7d70b93acf100f1cb9f7d25f3831/GawrGura_RVC_v2_Ov2Super_e275_s64075.zip",
},
]
# ββ CSS βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
CSS = """
#header { text-align: center; padding: 20px 0 8px; }
#header h1 { font-size: 2rem; margin: 0; }
#header p { opacity: .65; margin: 4px 0 0; }
#status { text-align: center; font-size: .82rem; opacity: .7; margin-bottom: 8px; }
footer { display: none !important; }
"""
|