Examples

Augmentation examples, showing you how to solve certain augmentation tasks.

Let’s start with loading an example file to augment.

import audb
import audiofile

files = audb.load_media(
    "emodb",
    "wav/03a01Fa.wav",
    version="1.4.1",
    verbose=False,
)
signal, sampling_rate = audiofile.read(files[0])
_images/examples_2_0.png

Recorded Reverb

Recorded reverb can be used to make machine learning models robust against changes of the room. In the following we use binaural impulse responses recorded with a dummy head from the air dataset. Its rir table holds recordings for four different rooms at different distances.

df = audb.load_table("air", "rir", version="1.4.2", verbose=False)
set(df.room)
{'booth', 'lecture', 'meeting', 'office'}

We load the left channel of all impulse responses stored in the rir table and resample them to 16000 Hz. We then randomly pick an impulse response during augmentation with auglib.observe.List.

auglib.seed(0)

db = audb.load(
    "air",
    version="1.4.2",
    tables="rir",
    channels=[0],
    sampling_rate=16000,
    verbose=False,
)
transform = auglib.transform.Compose(
    [
        auglib.transform.FFTConvolve(
            auglib.observe.List(db.files, draw=True),
            keep_tail=False,
        ),
        auglib.transform.NormalizeByPeak(),
    ]
)
augment = auglib.Augment(transform)
signal_augmented = augment(signal, sampling_rate)
_images/examples_6_0.png