auglib.observeΒΆ

Observable classes.

Observable objects provide a mechanism to randomize augmentation. Instead of holding a fixed value, an observable object reveals its value only when its called. E.g. in the following observed_value_1 and observed_value_2 are randomly assigned an integer in range [0, 5):

observable_value = auglib.observe.IntUni(low=0, high=5)
observed_value_1 = observable_value()  # value in [0, 5)
observed_value_2 = observable_value()  # value in [0, 5)

By deriving from auglib.observe.Base we can implement our own observable class. For instance, we can rewrite above example as follows:

class MyRandom05(auglib.observe.Base):
    def __call__(self) -> int:
        return random.randint(0, 5)


observable_value = MyRandom05()
observed_value_1 = observable_value()  # value in [0, 5)
observed_value_2 = observable_value()  # value in [0, 5)

Observable objects can be used in any place, where argument support the type auglib.observe.Base. For instance, to augment files with auglib.transform.PinkNoise at different intensities, we can do:

noise_with_random_gain = auglib.transform.PinkNoise(
    gain_db=auglib.observe.FloatUni(-30, -10),
)
augment = auglib.Augment(noise_with_random_gain)

# augment each file with a different gain in (-30, -10) db
augment.process_files(files)

Base

Interface for observable objects.

Bool

Draw booleans with a given probability for True.

FloatNorm

Draw floating point numbers from a normal (Gaussian) distribution.

FloatUni

Draw floating point numbers from a uniform distribution.

IntUni

Draw integers from a uniform distribution.

List

Iterate over a list of (observable) objects.

observe

Convenient function to observe a value.