`backend/api/routers/profiles.py` imports two pure-stdlib regex helpers from
`omnivoice.utils.voice_design`. That import pulled in `omnivoice/__init__`,
which eagerly imported `omnivoice.models.omnivoice` — torch, torchaudio,
transformers, flex_attention, the whole model definition — including a
top-level `from transformers import HiggsAudioV2TokenizerModel`.
transformers exposes that class through its lazy module and gates it on the
torchaudio backend, so the *attribute access* raises when torchaudio is
missing, ABI-mismatched, or installed without discoverable distribution
metadata — Colab's system Python, an interrupted `uv pip install`. It raised
during `backend/main.py`'s module import, before FastAPI existed: TTS,
dubbing, ASR and Settings all dead, the user left with a uvicorn traceback and
"Backend did not become healthy within 5 minutes".
Two changes, both structural rather than Colab-specific:
- `omnivoice/__init__` resolves its model exports lazily (PEP 562). Importing
`omnivoice.utils.*` no longer costs — or risks — the model stack.
`from omnivoice import OmniVoice` is unchanged; only the timing moves.
`backend.spec` already lists `omnivoice.models.omnivoice` as a hidden
import, so the frozen build is unaffected.
- `HiggsAudioV2TokenizerModel` resolves at its single use site in
`from_pretrained`, and a failure there raises an ImportError naming
torchaudio and the reinstall. Deferred into a request, `core.failure
.classify()` maps it to TRANSFORMERS_IMPORT and attaches a repair hint —
whose text now names torchaudio too, instead of only transformers + an ASR
workaround irrelevant to this path.
Colab notebook: cell 2's sanity check imports the model stack (and prints
torchaudio/transformers versions), so a broken env fails there with the real
error instead of as a health timeout two cells later.
Regression test: tests/test_omnivoice_lazy_model_import.py pins that the utils
import loads no heavy module, the lazy exports still resolve, and the deferred
failure is actionable and classified.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>