Download & lazy-loading policy
Standard ASR enforces a strict lazy‑loading policy to avoid surprise downloads and heavy startup costs. This is critical for server environments and CI.
1. Environment toggle
STANDARD_ASR_ALLOW_DOWNLOAD controls whether plugins are allowed to download
model weights at runtime. The list below is the contract
(standard_asr.runtime.downloads.allow_downloads() implements it):
-
1,true,yes→ downloads allowed -
0,false,no→ downloads disabled -
unset → allowed by default (recommended for local/dev)
-
any other value, including an empty string (for example, a
VAR=line in docker-compose) → disabled (fail-closed: an unrecognized value must not silently enable downloads). The unrecognized value is logged atWARNINGso the cause is traceable — the engine that later raisesDiscoveryErroronly sees the resolved boolean, not the offending text.(The empty-string handling here is deliberately not the same as the cache path override
STANDARD_ASR_MODEL_DIR, where an empty value is meaningless and treated as unset: for this safety toggle an empty value is an unrecognized value and fails closed to disabled.)
2. Expected engine behavior
- Constructor must be lazy: do not download or load weights in
__init__. - Guard downloads: check
standard_asr.runtime.downloads.allow_downloads()before any download. - Raise clear errors: if downloads are disabled and weights are missing,
raise
DiscoveryErrorwith a clear next action. prepare()honors the same gate: the optional warm-up hook (spec IC.11), used bystandard-asr preparebelow, materializes weights at an explicit, transcription-free call point. An engine that overrides it MUST apply the same download gate as transcription — checkallow_downloads()and raiseDiscoveryErrorwhen downloads are disabled and weights are missing — and MUST keep it synchronous and idempotent (neverasync def).
3. Cache location
Default cache directory is resolved by standard_asr.runtime.downloads.resolve_cache_dir()
in this order:
STANDARD_ASR_MODEL_DIRif set (a whitespace-only value is treated as unset; a relative value resolves against the current working directory at call time, so the result is always absolute).- macOS / Linux:
$XDG_CACHE_HOME/standard-asrwhenXDG_CACHE_HOMEis set to an absolute path (a relative value is ignored per the XDG Base Directory spec); otherwise~/.cache/standard-asr. HonoringXDG_CACHE_HOMEmatches the wider ML cache ecosystem (HuggingFace hub, pip, uv). - Windows:
%LOCALAPPDATA%/standard-asr. WhenLOCALAPPDATAis unset, its standard location~/AppData/Local/standard-asris derived directly. The roaming%APPDATA%profile is not used — multi-gigabyte weights must not land in a profile that is synced across domain logins.
Use standard_asr.runtime.downloads.ensure_cache_dir() to create it.
4. Operational guidance
- In production or CI, set
STANDARD_ASR_ALLOW_DOWNLOAD=0. - Use
standard-asr prepare <engine/model>to pre‑warm caches. - For air‑gapped environments, pre‑download weights into the cache directory.