Skip to main content

Waveform augmentations

Project description

speechaugs

Single-channel waveforms augmentations for speech recognition models.


Augmentations:

  • Time Stretch
  • Forward Time Shift
  • Pitch Shift
  • Colored Noise (white, pink, brown, blue, violet, grey)
  • Zero Samples
  • Clipping samples
  • Inversion

Colab Example You can see examples of all augmentations and listen to resulting audios on this page with Colab notebook.


Installation

pip install speechaugs


Time Stretch

Stretch a wavefom in time with randomly chosen rate. Is implemented using librosa.effects.time_stretch.

Forward Time Shift

Shift a waveform forwards in time.

Pitch Shift

Shift a pitch by n_steps semitones. Is implemented using librosa.effects.pitch_shift.

The work of PitchShift can be better illustrated on the MelSpectrograms of waveforms.

Higher pitch (+9 semitones):

Lower pitch (-5 semitones)

Colored Noise

Add noise of different color to a waveform. Color of noise depends on the spectral density of the noise. You can go to wiki page for more information.

This class is implemented using colorednoise package. The color of noise is randomly choosen.

White Noise

Brown Noise

Zero Samples

Set some percentage of samples to zero.

Clipping Samples

Clip some percentage of samples from a waveform.

Inversion

Change sign of waveform samples.


Usage example (with default parameters)

Import:

from speechaugs import TimeStretchLibrosa, ForwardTimeShift, PitchShiftLibrosa, ColoredNoise, Inversion, ZeroSamples, ClippingSamples

Other libs:

import torch, torchaudio
import albumentations as A

Usage:

ex_waveform, sr = torchaudio.load('audio_filename')

transforms = A.Compose([
    ForwardTimeShift(p=0.5),
    Inversion(p=0.5),
    A.OneOf([ZeroSamples(p=0.5), ClippingSamples(p=0.5)], p=0.5),
    A.OneOf([TimeStretchLibrosa(p=0.5), PitchShiftLibrosa(p=0.5)], p = 0.5),
    ColoredNoise(p=0.5)
], p=1.0)

augmented = transforms(waveform=ex_waveform)['waveform']

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

speechaugs-0.0.3.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

speechaugs-0.0.3-py3-none-any.whl (17.4 kB view details)

Uploaded Python 3

File details

Details for the file speechaugs-0.0.3.tar.gz.

File metadata

  • Download URL: speechaugs-0.0.3.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.2.post20210110 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.8.5

File hashes

Hashes for speechaugs-0.0.3.tar.gz
Algorithm Hash digest
SHA256 0be1ddc2e836ab6db286f21508faf627f35555df9f3ac923b765804b00993805
MD5 7905626f6fa041e91f44b32f36c43222
BLAKE2b-256 193272b780e88c2b3dbaf23591a6bba747ff609c4a4cc225e366991915a93534

See more details on using hashes here.

File details

Details for the file speechaugs-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: speechaugs-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 17.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.2.post20210110 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.8.5

File hashes

Hashes for speechaugs-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 39e3da774a6627cea8c4afa36dbfd8016377bdfff8518207a9b4ce2c944047fb
MD5 355f36265cbc10adc1e064b9014897e6
BLAKE2b-256 ae6057b58d889283078755b1356b4c753c33c5b3abecd618c0e27b2cbd57d3be

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page