The installer refused folders whose parent is user-owned (Desktop, Documents) because a user could swap
the whole install folder and get the elevated/audiodg-run parts replaced. Instead of refusing, the parts
that run with admin rights or inside audiodg now live in {commonpf}\VoiceChanger, which only admins can
change; the chosen folder keeps the app, Python, engine, models and data.
- VoiceChanger.iss: SysDir = {commonpf}\VoiceChanger holds apo\ (VoiceChangerAPO.dll), scripts\mic-apo.ps1
and the uninstaller (UninstallFilesDir). CheckParent removed. Upgrade detection also matches the previous
install dir from the uninstall registry (PrevAppDir) since uninstall\ is no longer inside the app folder.
Stop the audio service when either the new or the v1.0.1-layout APO exists. Ask before installing into
a OneDrive-synced folder.
- secure-dir.ps1: drop CheckParent; Prepare takes -Upgrade.
- mic-apo.ps1: -From <previous app folder> migrates a v1.0.1 apo\ or 21b4278 config\ backup (validated as
before) into the Program Files apo\, removing the emptied old apo\.
- app: admin_root() finds Program Files\VoiceChanger (falls back to the app folder for the zip layout);
hooked-mic list, mic-apo log and the reconnect button use it.
Windows 11 VM (Inno 6.7.4 build, AppVersion 1.0.2): v1.0.1 at C:\VoiceChanger -> upgrade: backup moved
byte-equal, APO re-pointed to Program Files, old apo\ scripts\mic-apo.ps1 uninstall\ gone; fresh install to
C:\Users\ci\Desktop\VoiceChanger (owner WIN-CI\ci) with full engine download: exit 0, audiodg loads
C:\Program Files\VoiceChanger\apo\VoiceChangerAPO.dll, 440 Hz APO test + Communications stream PASS;
basic-user token can rename the Desktop folder but every Program Files write/rename is ERROR_ACCESS_DENIED;
reinstall over the same folder keeps user files; uninstall restores FxProperties (only the endpoint
timestamp properties differ, same as v1.0.1) and removes both folders.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
90 lines
3.6 KiB
Python
90 lines
3.6 KiB
Python
"""경로와 Applio 엔진 불러오기. 다른 모듈은 이것부터 import 한다."""
|
|
import json
|
|
import os
|
|
import re
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(os.environ.get("VC_ROOT") or Path(__file__).resolve().parent.parent)
|
|
ENGINE = Path(os.environ.get("VC_ENGINE") or ROOT / "engine")
|
|
MODELS = ROOT / "models"
|
|
TRAINING = ROOT / "training"
|
|
DATASETS = ROOT / "datasets"
|
|
CONFIG = ROOT / "config"
|
|
SETTINGS = CONFIG / "settings.json"
|
|
CACHE = ROOT / "cache"
|
|
|
|
|
|
def admin_root() -> Path:
|
|
"""마이크 모듈(apo\\)과 그것을 붙이는 scripts\\mic-apo.ps1 이 있는 폴더. 관리자 권한으로 실행되는 부분이라
|
|
설치 프로그램은 앱 폴더가 아니라 Program Files\\VoiceChanger 에 둔다. 그곳에 없으면(zip 으로 푼 경우) 앱 폴더."""
|
|
pf = os.environ.get("ProgramW6432") or os.environ.get("ProgramFiles")
|
|
if pf and (Path(pf) / "VoiceChanger" / "scripts" / "mic-apo.ps1").is_file():
|
|
return Path(pf) / "VoiceChanger"
|
|
return ROOT
|
|
|
|
|
|
def keep_files_in_root():
|
|
"""라이브러리가 사용자 폴더(%TEMP% · %USERPROFILE%\\.cache · %APPDATA%)에 쓰는 캐시와 임시 파일을
|
|
모두 설치 폴더 안 cache\\ 로 돌린다. 다른 import 보다 먼저 돌아야 해서 이 모듈을 불러올 때 바로 한다."""
|
|
dirs = {
|
|
"TEMP": "temp", "TMP": "temp", "TMPDIR": "temp",
|
|
"TORCH_HOME": "torch", "TORCHINDUCTOR_CACHE_DIR": "torch/inductor", "CUDA_CACHE_PATH": "cuda",
|
|
"HF_HOME": "huggingface", "XDG_CACHE_HOME": "xdg", "MPLCONFIGDIR": "matplotlib",
|
|
"NUMBA_CACHE_DIR": "numba", "PIP_CACHE_DIR": "pip", "UV_CACHE_DIR": "uv",
|
|
}
|
|
for var, sub in dirs.items():
|
|
p = CACHE / sub
|
|
p.mkdir(parents=True, exist_ok=True)
|
|
os.environ[var] = str(p)
|
|
os.environ["PYTHONNOUSERSITE"] = "1" # %APPDATA%\Python 의 패키지를 읽지도 쓰지도 않게
|
|
import tempfile
|
|
|
|
tempfile.tempdir = None # 위 TEMP 를 다시 읽게
|
|
|
|
|
|
keep_files_in_root()
|
|
|
|
|
|
def use_engine():
|
|
"""Applio 코드가 상대 경로(rvc/models/...)를 쓰므로 엔진 폴더로 옮겨 가서 import 한다."""
|
|
if not (ENGINE / "rvc").is_dir():
|
|
raise SystemExit(f"엔진이 없습니다: {ENGINE}\ninstall.bat 을 먼저 실행해 주세요.")
|
|
os.environ["APPLIO_LOGS_DIR"] = str(TRAINING)
|
|
os.environ["APPLIO_CONFIG_DIR"] = str(CONFIG / "applio")
|
|
# 학습·추출 하위 프로세스도 같은 엔진을 보도록
|
|
os.environ["PYTHONPATH"] = os.pathsep.join([str(ENGINE), os.environ.get("PYTHONPATH", "")]).strip(os.pathsep)
|
|
os.chdir(ENGINE)
|
|
if str(ENGINE) not in sys.path:
|
|
sys.path.insert(0, str(ENGINE))
|
|
|
|
|
|
def slug(name: str) -> str:
|
|
"""폴더·파일 이름용 영문 아이디. 한글 이름은 info.json 에만 둔다."""
|
|
s = re.sub(r"[^A-Za-z0-9_-]+", "_", name).strip("_").lower()
|
|
return s[:40]
|
|
|
|
|
|
def load_json(path: Path, default):
|
|
try:
|
|
return json.loads(path.read_text(encoding="utf-8"))
|
|
except (OSError, ValueError):
|
|
return default
|
|
|
|
|
|
def save_json(path: Path, data) -> None:
|
|
path.parent.mkdir(parents=True, exist_ok=True)
|
|
tmp = path.with_suffix(path.suffix + ".tmp")
|
|
tmp.write_text(json.dumps(data, ensure_ascii=False, indent=2), encoding="utf-8")
|
|
os.replace(tmp, path)
|
|
|
|
|
|
def ffmpeg() -> str:
|
|
"""Windows 는 엔진이 받아 둔 ffmpeg.exe, 그 밖에는 PATH 의 ffmpeg."""
|
|
exe = ENGINE / "ffmpeg.exe"
|
|
return str(exe) if exe.is_file() else "ffmpeg"
|
|
|
|
|
|
# javis_bot · 겜녹이와 같은 기준: -18 LUFS 평준화 + 리미터 (consent-recorder export 와 같은 필터)
|
|
LOUDNORM = "loudnorm=I=-18:TP=-1.5:LRA=11,alimiter=limit=0.89"
|