Skip to content

Padding

Added in v0.23.0

Apply padding to the audio signal by taking a fraction of the start or end and replacing that portion with padding. This can be useful for training ML models on padded inputs.

Padding API

mode: str • choices: "silence", "wrap", "reflect"
Default: "silence". Padding mode.
min_fraction: float • range: [0.0, 1.0]
Default: 0.01. Minimum fraction of the signal duration to be padded.
max_fraction: float • range: [0.0, 1.0]
Default: 0.7. Maximum fraction of the signal duration to be padded.
pad_section: str • choices: "start", "end"
Default: "end". Which part of the signal should be replaced with padding.
p: float • range: [0.0, 1.0]
Default: 0.5. The probability of applying this transform.

Source code

audiomentations/augmentations/padding.py