[![Build Status](https://travis-ci.com/timsainb/noisereduce.svg?branch=master)](https://travis-ci.com/timsainb/noisereduce)
[![Coverage Status](https://coveralls.io/repos/github/timsainb/noisereduce/badge.svg?branch=master)](https://coveralls.io/github/timsainb/noisereduce?branch=master)
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/timsainb/noisereduce/master?filepath=notebooks%2F1.0-test-noise-reduction.ipynb)
[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/timsainb/noisereduce/blob/master/notebooks/1.0-test-noise-reduction.ipynb)
[![PyPI version](https://badge.fury.io/py/noisereduce.svg)](https://badge.fury.io/py/noisereduce)
<div style="text-align:center">
<p align="center">
<img src="assets/noisereduce.png", width="100%">
</p>
</div>
# Noise reduction in python using spectral gating
Noisereduce is a noise reduction algorithm in python that reduces noise in time-domain signals like speech, bioacoustics, and physiological signals. It relies on a method called "spectral gating" which is a form of [Noise Gate](https://en.wikipedia.org/wiki/Noise_gate). It works by computing a spectrogram of a signal (and optionally a noise signal) and estimating a noise threshold (or gate) for each frequency band of that signal/noise. That threshold is used to compute a mask, which gates noise below the frequency-varying threshold.
The most recent version of noisereduce comprises two algorithms:
1. **Stationary Noise Reduction**: Keeps the estimated noise threshold at the same level across the whole signal
2. **Non-stationary Noise Reduction**: Continuously updates the estimated noise threshold over time
### Version 2 Updates:
- Added two forms of spectral gating noise reduction: stationary noise reduction, and non-stationary noise reduction.
- Added multiprocessing so you can perform noise reduction on bigger data.
- The new version breaks the API of the old version.
- The previous version is still available at `from noisereduce.noisereducev1 import reduce_noise`
- You can now create a noisereduce object which allows you to reduce noise on subsets of longer recordings
# Stationary Noise Reduction
- The basic intuition is that statistics are calculated on each frequency channel to determine a noise gate. Then the gate is applied to the signal.
- This algorithm is based (but not completely reproducing) on the one [outlined by Audacity](https://wiki.audacityteam.org/wiki/How_Audacity_Noise_Reduction_Works) for the **noise reduction effect** ([Link to C++ code](https://github.com/audacity/audacity/blob/master/src/effects/NoiseReduction.cpp))
- The algorithm takes two inputs:
1. A *noise* clip containing prototypical noise of clip (optional)
2. A *signal* clip containing the signal and the noise intended to be removed
### Steps of the Stationary Noise Reduction algorithm
1. A spectrogram is calculated over the noise audio clip
2. Statistics are calculated over spectrogram 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. A spectrogram is calculated over the signal
5. A mask is determined by comparing the signal spectrogram to the threshold
6. The mask is smoothed with a filter over frequency and time
7. The mask is appled to the spectrogram of the signal, and is inverted
*If the noise signal is not provided, the algorithm will treat the signal as the noise clip, which tends to work pretty well*
# Non-stationary Noise Reduction
- The non-stationary noise reduction algorithm is an extension of the stationary noise reduction algorithm, but allowing the noise gate to change over time.
- When you know the timescale that your signal occurs on (e.g. a bird call can be a few hundred milliseconds), you can set your noise threshold based on the assumption that events occuring on longer timescales are noise.
- This algorithm was motivated by a recent method in bioacoustics called Per-Channel Energy Normalization.
### Steps of the Non-stationary Noise Reduction algorithm
1. A spectrogram is calculated over the signal
2. A time-smoothed version of the spectrogram is computed using an IIR filter aplied forward and backward on each frequency channel.
3. A mask is computed based on that time-smoothed spectrogram
4. The mask is smoothed with a filter over frequency and time
5. The mask is appled to the spectrogram of the signal, and is inverted
# Installation
`pip install noisereduce`
# Usage
See example notebook: [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/timsainb/noisereduce/blob/master/notebooks/1.0-test-noise-reduction.ipynb)
### Simplest usage
```
from scipy.io import wavfile
import noisereduce as nr
# load data
rate, data = wavfile.read("mywav.wav")
# perform noise reduction
reduced_noise = nr.reduce_noise(y=data, sr=rate)
wavfile.write("mywav_reduced_noise.wav", rate, reduced_noise)
```
### Arguments to `reduce_noise`
```
y : np.ndarray [shape=(# frames,) or (# channels, # frames)], real-valued
input signal
sr : int
sample rate of input signal / noise signal
y_noise : np.ndarray [shape=(# frames,) or (# channels, # frames)], real-valued
noise signal to compute statistics over (only for non-stationary noise reduction).
stationary : bool, optional
Whether to perform stationary, or non-stationary noise reduction, by default False
prop_decrease : float, optional
The proportion to reduce the noise by (1.0 = 100%), by default 1.0
time_constant_s : float, optional
The time constant, in seconds, to compute the noise floor in the non-stationary
algorithm, by default 2.0
freq_mask_smooth_hz : int, optional
The frequency range to smooth the mask over in Hz, by default 500
time_mask_smooth_ms : int, optional
The time range to smooth the mask over in milliseconds, by default 50
thresh_n_mult_nonstationary : int, optional
Only used in nonstationary noise reduction., by default 1
sigmoid_slope_nonstationary : int, optional
Only used in nonstationary noise reduction., by default 10
n_std_thresh_stationary : int, optional
Number of standard deviations above mean to place the threshold between
signal and noise., by default 1.5
tmp_folder : [type], optional
Temp folder to write waveform to during parallel processing. Defaults to
default temp folder for python., by default None
chunk_size : int, optional
Size of signal chunks to reduce noise over. Larger sizes
will take more space in memory, smaller sizes can take longer to compute.
, by default 60000
padding : int, optional
How much to pad each chunk of signal by. Larger pads are
needed for larger time constants., by default 30000
n_fft : int, optional
length of the windowed signal after padding with zeros.
The number of rows in the STFT matrix ``D`` is ``(1 + n_fft/2)``.
The default value, ``n_fft=2048`` samples, corresponds to a physical
duration of 93 milliseconds at a sample rate of 22050 Hz, i.e. the
default sample rate in librosa. This value is well adapted for music
signals. However, in speech processing, the recommended value is 512,
corresponding to 23 milliseconds at a sample rate of 22050 Hz.
In any case, we recommend setting ``n_fft`` to a power of two for
optimizing the speed of the fast Fourier transform (FFT) algorithm., by default 1024
win_length : [type], optional
Each frame of audio is windowed by ``window`` of length ``win_length``
and then padded with zeros to match ``n_fft``.
Smaller values improve the temporal resolution of the STFT (i.e. the
ability to discriminate impulses that are closely spaced in time)
at the expense of frequency resolution (i.e. the ability to discriminate
pure
没有合适的资源?快使用搜索试试~ 我知道了~
使用频谱门控(语音、生物声学、音频、时域信号) 在 python 中降噪_python_Jupyter_代码_下载
共39个文件
py:13个
gitkeep:5个
rst:3个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
5星 · 超过95%的资源 2 下载量 118 浏览量
2022-07-03
23:24:47
上传
评论
收藏 5.9MB ZIP 举报
温馨提示
使用光谱门控在 python 中降噪 Noisereduce 是 Python 中的一种降噪算法,可降低语音、生物声学和生理信号等时域信号中的噪声。它依赖于一种称为“光谱选通”的方法,这是一种噪声门。它通过计算信号(以及可选的噪声信号)的频谱图并估计该信号/噪声的每个频带的噪声阈值(或门)来工作。该阈值用于计算掩码,该掩码将噪声门控到频率变化阈值以下。 最新版本的降噪包括两种算法: 平稳降噪:将估计的噪声阈值保持在整个信号的相同水平 非平稳降噪:随着时间的推移不断更新估计的噪声阈值 更多详情、使用方法,请下载后阅读README.md文件
资源推荐
资源详情
资源评论
收起资源包目录
noisereduce-master.zip (39个子文件)
noisereduce-master
.travis.yml 201B
models
.gitkeep 0B
test-requirements.txt 15B
docs
conf.py 8KB
commands.rst 489B
make.bat 5KB
getting-started.rst 256B
Makefile 5KB
index.rst 441B
environment.yml 188B
.github
workflows
python-publish.yml 1KB
assets
fish.wav 392KB
cafe_short.wav 392KB
noisereduce.png 361KB
test_environment.py 632B
noisereduce
._noisereduce.py 4KB
._plotting.py 4KB
utils.py 392B
generate_noise.py 671B
noisereducev1.py 9KB
._generate_noise.py 4KB
noisereduce.py 21KB
plotting.py 2KB
__init__.py 48B
tox.ini 50B
LICENSE 1KB
references
.gitkeep 0B
requirements.txt 138B
setup.py 887B
.gitignore 1003B
test_reduction.py 4KB
Makefile 5KB
README.md 9KB
notebooks
1.0-test-noise-reduction.ipynb 6.56MB
.gitkeep 0B
noisereduce.png 604KB
reports
figures
.gitkeep 0B
.gitkeep 0B
requirements-test.txt 23B
共 39 条
- 1
资源评论
- wx647__et032024-02-21这个资源内容超赞,对我来说很有价值,很实用,感谢大佬分享~
- m0_748125812023-04-22这个资源值得下载,资源内容详细全面,与描述一致,受益匪浅。
快撑死的鱼
- 粉丝: 1w+
- 资源: 9150
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功