Skip to content

registry

birdnet_stm32.models.registry

Frontend registry: register and discover audio frontend configurations.

Each registered frontend declares its name, whether it's a precomputed (host-side) or in-model mode, and its N6 NPU compatibility constraints.

FrontendInfo dataclass

Metadata for a registered audio frontend.

Attributes:

Name Type Description
name str

Canonical frontend name.

mode str

Internal AudioFrontendLayer mode ('precomputed', 'hybrid', 'raw').

precomputed bool

Whether spectrogram is computed on the host (True) or in-model (False).

n6_compatible bool

Whether this frontend is compatible with STM32N6 NPU deployment.

description str

Short human-readable description.

Source code in birdnet_stm32/models/registry.py
@dataclass(frozen=True)
class FrontendInfo:
    """Metadata for a registered audio frontend.

    Attributes:
        name: Canonical frontend name.
        mode: Internal AudioFrontendLayer mode ('precomputed', 'hybrid', 'raw').
        precomputed: Whether spectrogram is computed on the host (True) or in-model (False).
        n6_compatible: Whether this frontend is compatible with STM32N6 NPU deployment.
        description: Short human-readable description.
    """

    name: str
    mode: str
    precomputed: bool
    n6_compatible: bool
    description: str = ""

register_frontend(info)

Register a frontend configuration.

Parameters:

Name Type Description Default
info FrontendInfo

FrontendInfo describing the frontend.

required

Raises:

Type Description
ValueError

If a frontend with the same name is already registered.

Source code in birdnet_stm32/models/registry.py
def register_frontend(info: FrontendInfo) -> None:
    """Register a frontend configuration.

    Args:
        info: FrontendInfo describing the frontend.

    Raises:
        ValueError: If a frontend with the same name is already registered.
    """
    if info.name in _REGISTRY:
        raise ValueError(f"Frontend '{info.name}' is already registered.")
    _REGISTRY[info.name] = info

get_frontend_info(name)

Look up a registered frontend by name.

Parameters:

Name Type Description Default
name str

Canonical frontend name.

required

Returns:

Type Description
FrontendInfo

FrontendInfo for the frontend.

Raises:

Type Description
KeyError

If the frontend is not registered.

Source code in birdnet_stm32/models/registry.py
def get_frontend_info(name: str) -> FrontendInfo:
    """Look up a registered frontend by name.

    Args:
        name: Canonical frontend name.

    Returns:
        FrontendInfo for the frontend.

    Raises:
        KeyError: If the frontend is not registered.
    """
    if name not in _REGISTRY:
        raise KeyError(f"Frontend '{name}' is not registered. Available: {list_frontends()}")
    return _REGISTRY[name]

list_frontends()

Return all registered frontend names.

Source code in birdnet_stm32/models/registry.py
def list_frontends() -> list[str]:
    """Return all registered frontend names."""
    return sorted(_REGISTRY.keys())

is_precomputed(name)

Check whether a frontend uses host-side precomputed spectrograms.

Parameters:

Name Type Description Default
name str

Canonical frontend name.

required

Returns:

Type Description
bool

True if the frontend computes spectrograms on the host.

Source code in birdnet_stm32/models/registry.py
def is_precomputed(name: str) -> bool:
    """Check whether a frontend uses host-side precomputed spectrograms.

    Args:
        name: Canonical frontend name.

    Returns:
        True if the frontend computes spectrograms on the host.
    """
    return get_frontend_info(name).precomputed

is_n6_compatible(name)

Check whether a frontend is compatible with the STM32N6 NPU.

Parameters:

Name Type Description Default
name str

Canonical frontend name.

required

Returns:

Type Description
bool

True if the frontend can be deployed on the N6 NPU.

Source code in birdnet_stm32/models/registry.py
def is_n6_compatible(name: str) -> bool:
    """Check whether a frontend is compatible with the STM32N6 NPU.

    Args:
        name: Canonical frontend name.

    Returns:
        True if the frontend can be deployed on the N6 NPU.
    """
    return get_frontend_info(name).n6_compatible