Skip to main content

Noise reduction using Spectral Gating in python

Project description

Build Status Coverage Status Binder

Noise reduction in python using

  • This algorithm is based (but not completely reproducing) on the one outlined by Audacity for the noise reduction effect (Link to C++ code)
  • The algorithm requires two inputs:
    1. A noise audio clip comtaining prototypical noise of the audio clip
    2. A signal audio clip containing the signal and the noise intended to be removed

Steps of algorithm

  1. An FFT is calculated over the noise audio clip
  2. Statistics are calculated over FFT of the the noise (in frequency)
  3. A threshold is calculated based upon the statistics of the noise (and the desired sensitivity of the algorithm)
  4. An FFT is calculated over the signal
  5. A mask is determined by comparing the signal FFT to the threshold
  6. The mask is smoothed with a filter over frequency and time
  7. The mask is appled to the FFT of the signal, and is inverted

Installation

pip install noisereduce

Usage

(see notebooks)

import noisereduce as nr
# load data
rate, data = wavfile.read("mywav.wav")
# select section of data that is noise
noisy_part = data[10000:15000]
# perform noise reduction
reduced_noise = nr.reduce_noise(audio_clip=data, noise_clip=noisy_part, verbose=True)

Arguments to noise_reduce

n_grad_freq (int): how many frequency channels to smooth over with the mask.
n_grad_time (int): how many time channels to smooth over with the mask.
n_fft (int): number audio of frames between STFT columns.
win_length (int): Each frame of audio is windowed by `window()`. The window will be of length `win_length` and then padded with zeros to match `n_fft`..
hop_length (int):number audio of frames between STFT columns.
n_std_thresh (int): how many standard deviations louder than the mean dB of the noise (at each frequency level) to be considered signal
prop_decrease (float): To what extent should you decrease noise (1 = all, 0 = none)
verbose (bool): Whether to plot the steps of the algorithm


Project based on the cookiecutter data science project template. #cookiecutterdatascience

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

noisereduce-0.1.2.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

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

noisereduce-0.1.2-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file noisereduce-0.1.2.tar.gz.

File metadata

  • Download URL: noisereduce-0.1.2.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.20.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.6.8

File hashes

Hashes for noisereduce-0.1.2.tar.gz
Algorithm Hash digest
SHA256 65f0e73c720e2cb1216563e39c226ff3a3214f5dfd995a93cc3c13e27984a155
MD5 0ac70ec8ab90ad7a9cd965e7277f7002
BLAKE2b-256 7d01fae8f896ac1b29cc29d59bc4e9fde92daf4c9a2e709818754cd4d4d4eb52

See more details on using hashes here.

File details

Details for the file noisereduce-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: noisereduce-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.20.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.6.8

File hashes

Hashes for noisereduce-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 935cdf1b0d0d6dc6a6bcb792b91c866a0f65a63ee5ea7de028255c0c23ddd58d
MD5 0ff525af87909bd8e41871e6cebeac22
BLAKE2b-256 82053d8641c4495270de325cb46543fd174f2feabbd5394b77e7e3367d0b453e

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