augmentation
birdnet_stm32.audio.augmentation
¶
Data augmentation for audio and spectrograms.
Implements SpecAugment (frequency/time masking). Mixup works on whole batches in
TensorFlow ops: birdnet_stm32.data.generator.mixup_batch.
apply_spec_augment(spectrogram, freq_mask_max=8, time_mask_max=25, num_freq_masks=2, num_time_masks=2)
¶
Apply SpecAugment (frequency and time masking) to a spectrogram.
Zeroes out random contiguous bands along the frequency and time axes. Operates on a single spectrogram of shape [F, T] or [F, T, 1].
Reference: Park et al., "SpecAugment", 2019.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spectrogram
|
ndarray
|
Input spectrogram [F, T] or [F, T, 1]. |
required |
freq_mask_max
|
int
|
Maximum width of each frequency mask (bins). |
8
|
time_mask_max
|
int
|
Maximum width of each time mask (frames). |
25
|
num_freq_masks
|
int
|
Number of frequency masks to apply. |
2
|
num_time_masks
|
int
|
Number of time masks to apply. |
2
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Augmented spectrogram with same shape as input. |