Pipeline: env overrides for endpoints and dirs; voice health check, retries, load-on-demand; refuse speed_factor
This commit is contained in:
@@ -11,9 +11,35 @@ def load(path=None):
|
||||
with open(path, encoding="utf-8") as f:
|
||||
cfg = yaml.safe_load(f)
|
||||
cfg["_path"] = path
|
||||
apply_env(cfg)
|
||||
return cfg
|
||||
|
||||
|
||||
# Environment variables that override settings.yaml (used by the CI job; nothing is hard-coded to a host).
|
||||
ENV_OVERRIDES = [
|
||||
("AUDIOBOOK_BOOKS_DIR", ("books_dir",)),
|
||||
("AUDIOBOOK_WORK_DIR", ("work_dir",)),
|
||||
("AUDIOBOOK_ARCHIVE_DIR", ("archive_dir",)),
|
||||
("AUDIOBOOK_VOICE_ENDPOINT", ("voice", "endpoint")),
|
||||
("AUDIOBOOK_LLM_ENDPOINT", ("llm", "endpoint")),
|
||||
("AUDIOBOOK_LLM_MODEL", ("llm", "model")),
|
||||
]
|
||||
|
||||
|
||||
def apply_env(cfg, environ=None):
|
||||
environ = os.environ if environ is None else environ
|
||||
for var, keys in ENV_OVERRIDES:
|
||||
value = environ.get(var, "").strip()
|
||||
if value:
|
||||
node = cfg
|
||||
for k in keys[:-1]:
|
||||
node = node[k]
|
||||
node[keys[-1]] = value
|
||||
flag = environ.get("AUDIOBOOK_REQUIRE_OCR", "").strip().lower()
|
||||
if flag:
|
||||
cfg["ocr"]["required"] = flag in ("1", "true", "yes")
|
||||
|
||||
|
||||
def resolve(cfg, key):
|
||||
"""A path setting as an absolute path (relative values are relative to the repo root)."""
|
||||
value = cfg[key]
|
||||
|
||||
Reference in New Issue
Block a user