TorchLibrosa provides a PyTorch implementation of core `librosa` audio feature extraction functions, enabling GPU acceleration for tasks such as spectrogram and mel-spectrogram computation. This is particularly beneficial for deep learning pipelines that require faster feature generation on GPUs during training and evaluation. The library aims for numerical results almost identical to CPU-based `librosa` (difference less than 1e-5). The current version is 0.1.0, with an infrequent release cadence; the latest release was in February 2023.
pip install torchlibrosaVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to extract log mel spectrograms from a batch of audio signals using `torchlibrosa`'s `Spectrogram` and `LogmelFilterBank` modules, designed to work seamlessly within a PyTorch `nn.Sequential` model.
Ensure PyTorch is installed manually via `pip install torch` (and `torchvision`, `torchaudio` if needed) or by specifying it in your project's `requirements.txt`.
Be aware of the minor numerical differences. For most deep learning applications, this level of difference is acceptable. If exact parity is critical, consider using `librosa` for CPU-based processing and carefully benchmark results.
Upgrade to the latest `torchlibrosa` (0.1.0) and ensure compatibility with your PyTorch version. Check GitHub issues for reported incompatibilities if problems persist.