You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
import importlib
|
|
|
|
|
import os
|
|
|
|
|
import sys
|
|
|
|
|
from core.providers.vad.base import VADProviderBase
|
|
|
|
|
from config.logger import setup_logging
|
|
|
|
|
|
|
|
|
|
TAG = __name__
|
|
|
|
|
logger = setup_logging()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create_instance(class_name: str, *args, **kwargs) -> VADProviderBase:
|
|
|
|
|
"""工厂方法创建VAD实例"""
|
|
|
|
|
if os.path.exists(os.path.join("core", "providers", "vad", f"{class_name}.py")):
|
|
|
|
|
lib_name = f"core.providers.vad.{class_name}"
|
|
|
|
|
if lib_name not in sys.modules:
|
|
|
|
|
sys.modules[lib_name] = importlib.import_module(f"{lib_name}")
|
|
|
|
|
return sys.modules[lib_name].VADProvider(*args, **kwargs)
|
|
|
|
|
|
|
|
|
|
raise ValueError(f"不支持的VAD类型: {class_name},请检查该配置的type是否设置正确")
|