nnAudio is an audio processing toolbox using PyTorch convolutional neural network as its backend. By doing so, spectrograms can be generated from audio on-the-fly during neural network training and the Fourier kernels (e.g. or CQT kernels) can be trained. Kapre has a similar concept in which they also use 1D convolutional neural network to extract spectrograms based on Keras.
Other GPU audio processing tools are torchaudio and tf.signal. But they are not using the neural network approach, and hence the Fourier basis can not be trained. As of PyTorch 1.6.0, torchaudio is still very difficult to install under the Windows environment due to sox
. nnAudio is a more compatible audio processing tool across different operating systems since it relies mostly on PyTorch convolutional neural network. The name of nnAudio comes from torch.nn
pip install git+https://github.com/KinWaiCheuk/nnAudio.git#subdirectory=Installation
or
pip install nnAudio==0.2.3
https://kinwaicheuk.github.io/nnAudio/index.html
Feature | nnAudio | torch.stft | kapre | torchaudio | tf.signal | torch-stft | librosa |
---|---|---|---|---|---|---|---|
Trainable | ✅ | ❌ | ✅ | ❌ | ❌ | ✅ | ❌ |
Differentiable | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ |
Linear frequency STFT | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
Logarithmic frequency STFT | ✅ | ❌ | ✅ | ❌ | ❌ | ❌ | ❌ |
Inverse STFT | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
Griffin-Lim | ✅ | ❌ | ❌ | ✅ | ✅ | ❌ | ✅ |
Mel | ✅ | ❌ | ✅ | ✅ | ✅ | ❌ | ✅ |
MFCC | ✅ | ❌ | ❌ | ✅ | ✅ | ❌ | ✅ |
CQT | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ✅ |
Gammatone | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
CFP1 | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
GPU support | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ |
✅: Fully support ☑️: Developing (only available in dev version) ❌: Not support
1 Combining Spectral and Temporal Representations for Multipitch Estimation of Polyphonic Music
To view the full changelog, please go to CHANGELOG.md
version 0.2.4 (11 June 2021):
- CQT2010 bug has been fixed #85.
- Provide a wider support for scipy versions using
from scipy.fftpack import fft
in utils.py - Documentation error for STFT has been fixed #90
This version can be obtained via:
pip install git+https://github.com/KinWaiCheuk/nnAudio.git#subdirectory=Installation
or
pip install nnAudio==0.2.4
The paper for nnAudio is avaliable on IEEE Access
K. W. Cheuk, H. Anderson, K. Agres and D. Herremans, "nnAudio: An on-the-Fly GPU Audio to Spectrogram Conversion Toolbox Using 1D Convolutional Neural Networks," in IEEE Access, vol. 8, pp. 161981-162003, 2020, doi: 10.1109/ACCESS.2020.3019084.
@ARTICLE{9174990, author={K. W. {Cheuk} and H. {Anderson} and K. {Agres} and D. {Herremans}}, journal={IEEE Access}, title={nnAudio: An on-the-Fly GPU Audio to Spectrogram Conversion Toolbox Using 1D Convolutional Neural Networks}, year={2020}, volume={8}, number={}, pages={161981-162003}, doi={10.1109/ACCESS.2020.3019084}}
nnAudio is a fast-growing package. With the increasing number of feature requests, we welcome anyone who is familiar with digital signal processing and neural network to contribute to nnAudio. The current list of pending features includes:
- Invertible Constant Q Transform (CQT)
- CQT with filter scale factor (see issue #54)
- Variable Q Transform (see VQT[https://www.researchgate.net/publication/274009051_A_Matlab_Toolbox_for_Efficient_Perfect_Reconstruction_Time-Frequency_Transforms_with_Log-Frequency_Resolution])
- Speed and Performance improvements for Griffin-Lim (see issue #41)
- Data Augmentation (see issue #49)
(Quick tips for unit test: cd
inside Installation folder, then type pytest
. You need at least 1931 MiB GPU memory to pass all the unit tests)
Alternatively, you may also contribute by:
- Refactoring the code structure (Now all functions are within the same file, but with the increasing number of features, I think we need to break it down into smaller modules)
- Making a better demonstration code or tutorial
Numpy >= 1.14.5
Scipy >= 1.2.0
PyTorch >= 1.6.0 (Griffin-Lim only available after 1.6.0)
Python >= 3.6
librosa = 0.7.0 (Theoretically nnAudio depends on librosa. But we only need to use a single function mel
from librosa.filters
. To save users troubles from installing librosa for this single function, I just copy the chunk of functions corresponding to mel
in my code so that nnAudio runs without the need to install librosa)