Files
1038lab-ComfyUI-QwenASR/__init__.py
T
2026-01-30 10:33:10 -08:00

43 lines
1.2 KiB
Python

from pathlib import Path
import importlib.util
import os
import sys
_current_dir = Path(__file__).parent
if str(_current_dir) not in sys.path:
sys.path.insert(0, str(_current_dir))
NODE_CLASS_MAPPINGS = {}
NODE_DISPLAY_NAME_MAPPINGS = {}
WEB_DIRECTORY = "./web"
def _load_module(path: Path):
spec = importlib.util.spec_from_file_location(path.stem, path)
if not spec or not spec.loader:
return None
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
return module
def _discover_nodes():
for py in _current_dir.glob("*.py"):
if py.name == "__init__.py":
continue
try:
module = _load_module(py)
if not module:
continue
if hasattr(module, "NODE_CLASS_MAPPINGS"):
NODE_CLASS_MAPPINGS.update(module.NODE_CLASS_MAPPINGS)
if hasattr(module, "NODE_DISPLAY_NAME_MAPPINGS"):
NODE_DISPLAY_NAME_MAPPINGS.update(module.NODE_DISPLAY_NAME_MAPPINGS)
except Exception as e:
print(f"[Qwen3TTS] Failed to load {py.name}: {e}")
_discover_nodes()
__all__ = ["NODE_CLASS_MAPPINGS", "NODE_DISPLAY_NAME_MAPPINGS", "WEB_DIRECTORY"]