Pin Applio 3.6.5 and verified basis assets, migrate private voice provenance, and coordinate conversion/live/training with Deck GPU leases. Prepare an inactive voice profile and a restricted studio container. Move CUDA and Torch caches out of the small temporary filesystem to prevent OmniVoice reference failures. Package app updates from the explicit allowlist in one Docker layer.
108 lines
3.6 KiB
Python
108 lines
3.6 KiB
Python
"""Application configuration via environment variables."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
from pydantic import Field
|
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
model_config = SettingsConfigDict(
|
|
env_file=".env",
|
|
env_file_encoding="utf-8",
|
|
extra="ignore",
|
|
)
|
|
|
|
# Applio-Pfade
|
|
applio_path: Path = Field(
|
|
default=Path("/opt/mike-ai/stack/experiments/applio-rvc"),
|
|
alias="APPLIO_PATH",
|
|
)
|
|
applio_python: Path = Field(
|
|
default=Path("/app/.venv/bin/python"),
|
|
alias="APPLIO_PYTHON",
|
|
)
|
|
applio_core_py: str = Field(default="core.py", alias="APPLIO_CORE_PY")
|
|
applio_container: str = Field(
|
|
default="mike-ai-applio-studio", alias="APPLIO_CONTAINER"
|
|
)
|
|
applio_workdir: str = Field(default="/app", alias="APPLIO_WORKDIR")
|
|
applio_models_dir: str = Field(default="/app/logs", alias="APPLIO_MODELS_DIR")
|
|
applio_datasets_dir: str = Field(
|
|
default="/app/assets/datasets", alias="APPLIO_DATASETS_DIR"
|
|
)
|
|
applio_uploads_dir: str = Field(
|
|
default="/app/assets/datasets/.mikes-applio-ui/uploads",
|
|
alias="APPLIO_UPLOADS_DIR",
|
|
)
|
|
applio_results_dir: str = Field(
|
|
default="/app/assets/datasets/.mikes-applio-ui/results",
|
|
alias="APPLIO_RESULTS_DIR",
|
|
)
|
|
applio_realtime_url: str = Field(
|
|
default="ws://applio-studio:6970/ws-audio",
|
|
alias="APPLIO_REALTIME_URL",
|
|
)
|
|
|
|
# Verzeichnisse
|
|
models_dir: Path = Field(default=Path("/data/voice/applio/models"), alias="MODELS_DIR")
|
|
datasets_dir: Path = Field(default=Path("/data/voice/applio/datasets"), alias="DATASETS_DIR")
|
|
jobs_dir: Path = Field(default=Path("/data/voice/applio/jobs"), alias="JOBS_DIR")
|
|
results_dir: Path = Field(default=Path("/data/voice/applio/results"), alias="RESULTS_DIR")
|
|
uploads_dir: Path = Field(default=Path("/data/voice/applio/uploads"), alias="UPLOADS_DIR")
|
|
|
|
# Upload-Einschränkungen
|
|
max_upload_size_mb: int = Field(default=500, alias="MAX_UPLOAD_SIZE_MB")
|
|
allowed_audio_formats: str = Field(
|
|
default="wav,mp3,flac,m4a,aac,ogg",
|
|
alias="ALLOWED_AUDIO_FORMATS",
|
|
)
|
|
|
|
# Job-Verwaltung
|
|
job_retention_days: int = Field(default=30, alias="JOB_RETENTION_DAYS")
|
|
|
|
# Logging
|
|
log_level: str = Field(default="INFO", alias="LOG_LEVEL")
|
|
|
|
# Frontend
|
|
frontend_dir: Path = Field(default=Path("frontend"), alias="FRONTEND_DIR")
|
|
|
|
# Server
|
|
host: str = Field(default="0.0.0.0", alias="HOST")
|
|
port: int = Field(default=8012, alias="PORT")
|
|
|
|
@property
|
|
def allowed_formats_set(self) -> set[str]:
|
|
return {f.strip().lower().lstrip(".") for f in self.allowed_audio_formats.split(",")}
|
|
|
|
@property
|
|
def max_upload_size_bytes(self) -> int:
|
|
return self.max_upload_size_mb * 1024 * 1024
|
|
|
|
def ensure_dirs(self) -> None:
|
|
"""Create all required directories if they don't exist.
|
|
|
|
Silently skips directories that cannot be created (e.g. when running
|
|
outside the target host where /data/voice/applio doesn't exist).
|
|
"""
|
|
import logging
|
|
log = logging.getLogger(__name__)
|
|
for d in [self.datasets_dir, self.jobs_dir, self.results_dir, self.uploads_dir]:
|
|
try:
|
|
d.mkdir(parents=True, exist_ok=True)
|
|
except (PermissionError, OSError) as e:
|
|
log.warning("Could not create directory %s: %s", d, e)
|
|
|
|
|
|
_settings: Settings | None = None
|
|
|
|
|
|
def get_settings() -> Settings:
|
|
global _settings
|
|
if _settings is None:
|
|
_settings = Settings()
|
|
_settings.ensure_dirs()
|
|
return _settings
|