ertk.preprocessing.InstanceProcessor

class ertk.preprocessing.InstanceProcessor(config: ERTKConfig)

Bases: ABC

An instance processor.

Parameters:
config: ERTKConfig

The configuration for this processor.

__init__(config: ERTKConfig) None

Methods

__init__(config)

finish()

Perform any cleanup necesasry (e.g.

friendly_name()

Get the friendly name for this processor.

get_config_type()

Get the configuration type for this processor.

get_default_config()

Get the default configuration for this processor.

get_processor_class(name)

Get the class for the named processor.

make_processor(name, config)

Create an instance of the named processor.

process_all(xs, batch_size, **kwargs)

Process all instances in batches.

process_batch(batch, **kwargs)

Process a batch of instances.

process_instance(x, **kwargs)

Process a single audio clip.

valid_processors()

Get a list of all registered processor names.

Inherited Methods

Attributes

feature_names

The names of the features produced by this processor.

config

The configuration for this processor.

logger

The logger for this processor.

config: ERTKConfig

The configuration for this processor.

abstract property feature_names: List[str]

The names of the features produced by this processor.

finish() None

Perform any cleanup necesasry (e.g. closing files, unloading models, etc.)

classmethod friendly_name() str

Get the friendly name for this processor.

classmethod get_config_type() Type[ERTKConfig]

Get the configuration type for this processor.

classmethod get_default_config() ERTKConfig

Get the default configuration for this processor.

Returns:
config: ERTKConfig

The default configuration.

classmethod get_processor_class(name: str) Type[InstanceProcessor]

Get the class for the named processor.

Parameters:
name: str

The name of the processor.

Returns:
processor: Type[InstanceProcessor]

The processor class.

logger: Logger

The logger for this processor.

classmethod make_processor(name: str, config: ERTKConfig) InstanceProcessor

Create an instance of the named processor.

Parameters:
name: str

The name of the processor to create.

config: ERTKConfig

The configuration for the processor.

Returns:
processor: InstanceProcessor

The created processor.

process_all(xs: Iterable[ndarray] | ndarray, batch_size: int, **kwargs) Iterable[ndarray]

Process all instances in batches.

Parameters:
xs: iterable of np.ndarray

The data from instances to process.

batch_size: int

Batch size.

Returns:
processed: iterable of np.ndarray

A generator that yields each processed instance in order.

process_batch(batch: Iterable[ndarray] | ndarray, **kwargs) List[ndarray]

Process a batch of instances. By default this simply calls process_instance() on each instance in the batch.

Parameters:
batch: np.ndarray or iterable of arrays

The batch of instances to process.

Returns:
processed: list of np.ndarray

A list of processed instances.

abstract process_instance(x: ndarray, **kwargs) ndarray

Process a single audio clip.

Parameters:
x: np.ndarray

The audio data to process.

Returns:
result: np.ndarray

The processed instance.

classmethod valid_processors() List[str]

Get a list of all registered processor names.

Returns:
names: list of str

The names of all registered processors.