Add VOICE_CONFIG env var to select the voice pipeline config file.
Defaults to config/voice.json; relative paths resolve from project root. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,11 +1,30 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import os
|
||||
from dataclasses import dataclass, field
|
||||
from pathlib import Path
|
||||
|
||||
from dotenv import load_dotenv
|
||||
|
||||
load_dotenv()
|
||||
|
||||
PROJECT_ROOT = Path(__file__).resolve().parent.parent.parent
|
||||
DEFAULT_VOICE_CONFIG = PROJECT_ROOT / "config" / "voice.json"
|
||||
DEFAULT_VOICE_CONFIG_REL = "config/voice.json"
|
||||
|
||||
|
||||
def resolve_voice_config_path() -> Path:
|
||||
"""Return the voice config path from VOICE_CONFIG or the default."""
|
||||
configured = os.getenv("VOICE_CONFIG", DEFAULT_VOICE_CONFIG_REL).strip()
|
||||
if not configured:
|
||||
configured = DEFAULT_VOICE_CONFIG_REL
|
||||
path = Path(configured)
|
||||
if not path.is_absolute():
|
||||
path = PROJECT_ROOT / path
|
||||
return path
|
||||
|
||||
|
||||
DEFAULT_VOICE_CONFIG = resolve_voice_config_path()
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@@ -143,7 +162,7 @@ class EngineConfig:
|
||||
|
||||
|
||||
def load_config(path: str | Path | None = None) -> EngineConfig:
|
||||
config_path = Path(path) if path is not None else DEFAULT_VOICE_CONFIG
|
||||
config_path = Path(path) if path is not None else resolve_voice_config_path()
|
||||
if not config_path.is_absolute():
|
||||
config_path = PROJECT_ROOT / config_path
|
||||
data = json.loads(config_path.read_text(encoding="utf-8"))
|
||||
|
||||
Reference in New Issue
Block a user