Noise reduction using Spectral Gating in python
Project description
Noise reduction in python using spectral gating
- 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:
- A noise audio clip comtaining prototypical noise of the audio clip
- A signal audio clip containing the signal and the noise intended to be removed
Steps of algorithm
- An FFT is calculated over the noise audio clip
- Statistics are calculated over FFT of the the noise (in frequency)
- A threshold is calculated based upon the statistics of the noise (and the desired sensitivity of the algorithm)
- An FFT is calculated over the signal
- A mask is determined by comparing the signal FFT to the threshold
- The mask is smoothed with a filter over frequency and time
- The mask is appled to the FFT of the signal, and is inverted
Installation
pip install noisereduce
noisereduce optionally uses Tensorflow as a backend to speed up FFT and gaussian convolution. It is not listed in the requirements.txt so because (1) it is optional and (2) tensorflow-gpu and tensorflow (cpu) are both compatible with this package. The package requires Tensorflow 2+ for all tensorflow operations.
Usage
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)
pad_clipping (bool): Pad the signals with zeros to ensure that the reconstructed data is equal length to the data
use_tensorflow (bool): Use tensorflow as a backend for convolution and fft to speed up computation
verbose (bool): Whether to plot the steps of the algorithm
Project based on the cookiecutter data science project template. #cookiecutterdatascience
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file noisereduce-1.1.0.tar.gz.
File metadata
- Download URL: noisereduce-1.1.0.tar.gz
- Upload date:
- Size: 6.3 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.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
07a79ffb3806cb0c5b36a8d557713778154c73ca8743e54ec2106bc466b5351c
|
|
| MD5 |
dbae78fbede251568d248189549cd4cd
|
|
| BLAKE2b-256 |
04d04e50cac3daaa1522a3730ec22750ca86f6c221a480e65c8d6b0ab18a21ed
|
File details
Details for the file noisereduce-1.1.0-py3.7.egg.
File metadata
- Download URL: noisereduce-1.1.0-py3.7.egg
- Upload date:
- Size: 22.9 kB
- Tags: Egg
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.7.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4c0f425256d0e6ffbbd5d8668fc4939fb87ef61986b79575821f14a414fb7358
|
|
| MD5 |
83c3af9b93c7f84610f8ae08c3005c24
|
|
| BLAKE2b-256 |
5e95055c41ec3943ce306536263b9d41c61229ea1c5aeb27ffa68452e394bec9
|