fix: surface real import error when omnivoice fails to load

The broad except ImportError was swallowing the actual failure reason
(e.g. a missing transitive dep after --no-deps install). Now captures
and re-raises the original exception in the error message so users
can diagnose what is actually missing.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-08 12:23:59 +02:00
parent aedbe2e7d9
commit 147030e2af
+11 -4
View File
@@ -1,10 +1,12 @@
import os import os
import torch import torch
_omnivoice_import_error = None
try: try:
from omnivoice import OmniVoice from omnivoice import OmniVoice
except ImportError: except Exception as e:
OmniVoice = None # deferred; will raise at runtime if package is missing OmniVoice = None
_omnivoice_import_error = e
try: try:
import folder_paths import folder_paths
@@ -55,9 +57,14 @@ class OmniVoiceModelLoader:
def load_model(self, device, dtype, compile=False): def load_model(self, device, dtype, compile=False):
if OmniVoice is None: if OmniVoice is None:
raise ImportError( msg = (
"omnivoice is not installed. Run: pip install omnivoice --no-deps" "omnivoice failed to import. "
"Install it with: pip install omnivoice --no-deps\n"
"(On Windows embedded Python: .\\python_embeded\\python.exe -m pip install omnivoice --no-deps)\n"
) )
if _omnivoice_import_error is not None:
msg += f"\nOriginal error: {_omnivoice_import_error}"
raise ImportError(msg)
model = OmniVoice.from_pretrained( model = OmniVoice.from_pretrained(
"k2-fsa/OmniVoice", "k2-fsa/OmniVoice",