import nest_asyncio

from .config import registry
from .data import Audio
from .pipeline import AudioPipeline
from .utils.base import get_cache_dir, set_cache_dir

nest_asyncio.apply()  # jupyter


def load(pipeline_name: str) -> AudioPipeline:
    from importlib.metadata import entry_points

    for plugin in entry_points(group="fasr.pipelines"):
        if plugin.name == pipeline_name:
            plugin.load()
            return registry.pipelines.get(pipeline_name)()
    raise ValueError(f"Pipeline {pipeline_name} not found")


__all__ = ["Audio", "AudioPipeline", "load", "set_cache_dir", "get_cache_dir"]
