"""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; } """