mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2026-04-25 06:35:18 +00:00
* allow memory flags and per service config * feat: mixdown modal services + processor pattern
33 lines
1.1 KiB
Python
33 lines
1.1 KiB
Python
import importlib
|
|
|
|
from reflector.processors.audio_mixdown import AudioMixdownProcessor
|
|
from reflector.settings import settings
|
|
|
|
|
|
class AudioMixdownAutoProcessor(AudioMixdownProcessor):
|
|
_registry = {}
|
|
|
|
@classmethod
|
|
def register(cls, name, kclass):
|
|
cls._registry[name] = kclass
|
|
|
|
def __new__(cls, name: str | None = None, **kwargs):
|
|
if name is None:
|
|
name = settings.MIXDOWN_BACKEND
|
|
if name not in cls._registry:
|
|
module_name = f"reflector.processors.audio_mixdown_{name}"
|
|
importlib.import_module(module_name)
|
|
|
|
# gather specific configuration for the processor
|
|
# search `MIXDOWN_XXX_YYY`, push to constructor as `xxx_yyy`
|
|
config = {}
|
|
name_upper = name.upper()
|
|
settings_prefix = "MIXDOWN_"
|
|
config_prefix = f"{settings_prefix}{name_upper}_"
|
|
for key, value in settings:
|
|
if key.startswith(config_prefix):
|
|
config_name = key[len(settings_prefix) :].lower()
|
|
config[config_name] = value
|
|
|
|
return cls._registry[name](**config | kwargs)
|