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.2.tar.gz (5.3 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.2-py3-none-any.whl (17.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: speechaugs-0.0.2.tar.gz
  • Upload date:
  • Size: 5.3 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.2.tar.gz
Algorithm Hash digest
SHA256 c01c68eb92885626316e6a4eb8d89f5e63ec42be681c89474c07855b9d1100ed
MD5 a0430c185af129e0ab94080f38a9d0e0
BLAKE2b-256 ae617f4dbf505f18e04b784925bc9bb4f23d2d3a116de15548ed034b1538ed28

See more details on using hashes here.

File details

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

File metadata

  • Download URL: speechaugs-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 17.3 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2a9440e33635d3b52d4c36544343c4d13d833e71943fb1d33401433616ae97cc
MD5 e536a4ee47cccb92e95fa87e1e04544b
BLAKE2b-256 e69bbfe949eb4be8d0e74ff382c9e45b776a64a945792887fcb022821aa78981

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