Skip to content
An extensible data augmentation package for creating complex transformation pipelines to apply to audio signals.
Python
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs
lib
notebooks
.gitattributes
.gitignore
.travis.yml
CHANGELOG.md
CODE_OF_CONDUCT.md
CONTRIBUTING.md
LICENSE
README.md
setup.py

README.md

Sigment

An extensible data augmentation package for creating complex transformation pipelines for audio signals.

Disclaimer: Although the core functionality of this package is fully implemented, it still requires proper unit testing.

What is data augmentation?

Data augmentation is the creation of artificial data from original data by typically applying a transformation, or multiple transformations, to the original data. It is a common method for improving the versatility of machine learning models, in addition to providing more training examples for datasets of limited size.

In image data for example, it is common to use horizontal and vertical flipping, random cropping, zooming and additive noise for augmentation. In audio, we can use other transformations such as pitch shifting and fading the signal in or out, but some image augmentation methods such as additive noise can also be used on audio data.

Supported augmentation methods

Sigment provides the following augmentation methods for both mono and stereo signals. More information about each can be found in the documentation:

  • White Noise (Uniform, Gaussian and Laplacian)
  • Time Stretching
  • Pitch Shifting
  • Edge Cropping
  • Fading

Soon: Normalization, Random Cropping and Median Filtering

It is also possible to design your own augmentation methods using a simple Transform base class provided by Sigment.

Example

Suppose we have the following stereo signal F:

Original

We can apply a pipeline of transformations to F to produce multiple augmented copies of it:

Augmented

Click here to see the code for the augmentation pipeline produces these signals!

import sigment as sig

# Create a complex augmentation pipeline
transform = sig.Pipeline([
    sig.Sometimes([
        sig.OneOf([
            sig.UniformWhiteNoise(upper=(0.1, 0.4)),
            sig.GaussianWhiteNoise(scale=(0.01, 0.075)),
            sig.LaplacianWhiteNoise(scale=(0.01, 0.075))
        ])
    ], p=0.65),
    sig.SomeOf([
        sig.EdgeCrop('start', crop_size=(0.05, 0.15)),
        sig.EdgeCrop('end', crop_size=(0.05, 0.15))
    ], n=(1, 2)),
    sig.Sometimes([
        sig.SomeOf([
            sig.Fade('in', fade_size=(0.1, 0.2)),
            sig.Fade('out', fade_size=(0.1, 0.2))
        ], n=(1, 2))
    ], p=0.5),
    sig.TimeStretch(rate=(0.7, 1.3)),
    sig.PitchShift(n_steps=(-0.25, 0.25)),
])

# Generate 25 augmentations of the signal F
Fs = transform.generate(F, n=25, sr=50)

Note: The full code for this example can be found in the notebook here.

Installation

To install Sigment from PyPI, you can use pip:

pip install sigment

Components

Sigment provides two main components that can be used to construct augmentation pipelines:

  • Transforms (sigment.transforms): Used to apply a specific type of transformation to the audio data.

  • Quantifiers (sigment.quantifiers): Used to specify rules for how a sequence of transformations or nested quantifiers should be applied to augment the audio data.

Read the documentation and example notebooks for more information about the usage of both.

Acknowledgements

Sigment offers a familiar interface for transformations, taking inspiration from some other well-written augmentation libraries. Without the following libraries, the capabilities of Sigment would be very limited:

Contributors

All contributions to this repository are greatly appreciated. Contribution guidelines can be found here.

Edwin Onuonga
Edwin Onuonga

✉️ 🌍

Sigment © 2019-2020, Edwin Onuonga - Released under the MIT License.
Authored and maintained by Edwin Onuonga.

You can’t perform that action at this time.