Registry / ai-ml / asteroid-filterbanks

asteroid-filterbanks

JSON →
library0.4.0pypypi✓ verified 24d ago

Asteroid's filterbanks is a Python library providing various filterbank implementations for audio signal processing within deep learning contexts, primarily using PyTorch. It is designed to be a modular toolkit for researchers working on audio source separation. The library is actively maintained with frequent updates, particularly concerning PyTorch compatibility, with the current version being 0.4.0.

pip install asteroid-filterbanks
INSTALL
IMPORT
SIG · ASTEROID-FILTERBAN
A
asteroid-filterbanks
ai-mlpythonv0.4.0
Install
67.6s avg
Import
6170ms
Disk
4813MB
Pass rate
4/ 10
Env Coverage4 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.4.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
✕ build_error
✓ 75.7s
py 3.11
✕ build_error
✓ 70s
py 3.12
✕ build_error
✓ 64.3s
py 3.13
✕ build_error
✓ 60.3s
py 3.9
✕ build_error
✕ timeout
4813MB installed
● package 4813MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Filterbank, Encoder, Decoder
from asteroid_filterbanks.enc_dec import Filterbank, Encoder, Decoder
Main classes for defining, encoding, and decoding with filterbanks.
FreeFB, STFTFB, ParamSincFB, MelGram
from asteroid_filterbanks import FreeFB, STFTFB, ParamSincFB, MelGram
Commonly used predefined filterbank types.
PCEN
from asteroid_filterbanks.pcen import PCEN
Per-Channel Energy Normalization module.
make_enc_dec
from asteroid_filterbanks.enc_dec import make_enc_dec
Utility function to create congruent encoder/decoder pairs.

This quickstart demonstrates how to instantiate a `FreeFB` filterbank, wrap it with an `Encoder` to transform a waveform into a time-frequency representation, and then use a `Decoder` to reconstruct the waveform. This is a common pattern for learnable front-ends in audio processing models.

import torch from asteroid_filterbanks.enc_dec import Encoder, Decoder from asteroid_filterbanks import FreeFB # Define parameters for the filterbank n_filters = 256 kernel_size = 128 stride = 64 sample_rate = 16000 # 1. Instantiate a filterbank (e.g., a fully learnable Free Filterbank) fb = FreeFB(n_filters=n_filters, kernel_size=kernel_size, stride=stride, sample_rate=sample_rate) # 2. Wrap it with an Encoder to get the time-frequency representation encoder = Encoder(fb) # 3. Create a dummy waveform (batch, channels, time) waveform = torch.randn(1, 1, sample_rate * 4) # 4 seconds of audio # 4. Encode the waveform into a spectrogram-like representation spec_like = encoder(waveform) print(f"Input waveform shape: {waveform.shape}") print(f"Encoded spectrogram-like shape: {spec_like.shape}") # 5. Instantiate a Decoder (can use the same filterbank or a different one) decoder = Decoder(fb) # For reconstruction, often use the same filterbank # 6. Decode the spectrogram-like representation back to waveform out_waveform = decoder(spec_like) print(f"Decoded waveform shape: {out_waveform.shape}")
Debug
Known issues
breakingVersion 0.4.0 drops support for PyTorch versions older than 1.8.0. Ensure your PyTorch installation is `torch>=1.8.0`.
fix
Upgrade PyTorch to version 1.8.0 or newer (e.g., `pip install torch>=1.8.0`).
affects: >=0.4.0
breakingBeginning with version 0.3.1, the library moved from `torch.rfft` (deprecated and removed in newer PyTorch versions) to `torch.fft`. This change affects the output format, which now consistently returns complex numbers, potentially breaking models trained with older versions or assumptions.
fix
Update code to handle complex number outputs from `torch.fft` (e.g., using `abs()` or `torch.view_as_real()` if magnitude/phase is needed) and retrain models if necessary to adapt to the new FFT behavior.
affects: >=0.3.1
gotchaThe `Encoder` and `Decoder` classes are wrappers designed to augment `Filterbank` instances with encoding/decoding methods. They are not intended to be subclassed directly for implementing new filterbanks; instead, subclass `Filterbank` and then wrap it.
fix
To create a custom filterbank, inherit from `asteroid_filterbanks.Filterbank` and implement its abstract methods. Then, instantiate `Encoder(my_custom_filterbank_instance)` or `Decoder(my_custom_filterbank_instance)`.
affects: All
gotchaWhen using `asteroid_filterbanks.enc_dec.make_enc_dec` or manually setting up `Encoder` and `Decoder` for reconstruction, pay close attention to the `is_pinv` and `who_is_pinv` parameters if you intend one to be the pseudo-inverse of the other.
fix
Consult the `make_enc_dec` documentation for correct usage of `who_is_pinv` (e.g., 'encoder', 'decoder') or manually set `is_pinv=True` on the appropriate wrapper if building the pair separately.
affects: All
gotchaIf performing a development installation (`pip install -e .`) or installing `asteroid` (which includes `asteroid-filterbanks`), you might need to restart your Python runtime (especially in notebooks like Jupyter or Colab) for `asteroid_filterbanks` modules to import correctly.
fix
After installation, explicitly restart the kernel or Python process if you encounter import errors.
affects: All
gotchaThe `TorchSTFTFB` filterbank aims to replicate `torch.stft` behavior for ONNX compatibility, but it may not cover all options and edge cases of `torch.stft`. Be cautious when expecting perfect equivalence for all configurations.
fix
Thoroughly test `TorchSTFTFB` with your specific `torch.stft` parameters if ONNX export or exact matching is critical, and review its documentation for current limitations.
affects: >=0.2.0
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'asteroid_filterbanks'
The 'asteroid-filterbanks' package is not installed in the Python environment.
fix
Install the package using pip: 'pip install asteroid-filterbanks'.
ImportError: cannot import name 'STFTFB' from 'asteroid.filterbanks'
The 'STFTFB' class is located in 'asteroid_filterbanks.stft_fb', not 'asteroid.filterbanks'.
fix
Use the correct import statement: 'from asteroid_filterbanks.stft_fb import STFTFB'.
AttributeError: module 'asteroid_filterbanks' has no attribute 'Encoder'
The 'Encoder' class is located in 'asteroid_filterbanks.enc_dec', not directly in 'asteroid_filterbanks'.
fix
Use the correct import statement: 'from asteroid_filterbanks.enc_dec import Encoder'.
TypeError: __init__() missing 1 required positional argument: 'n_filters'
The 'Filterbank' class requires 'n_filters' as a mandatory argument during initialization.
fix
Ensure to provide the 'n_filters' argument when initializing: 'fb = Filterbank(n_filters=64, kernel_size=16)'.
ValueError: n_filters must be a positive integer
The 'n_filters' parameter was set to a non-positive integer or a non-integer value.
fix
Set 'n_filters' to a positive integer: 'fb = Filterbank(n_filters=64, kernel_size=16)'.
Upgrade
Version history
0.4.0latest on PyPI · released Apr 9, 2021
Audit
Dependencies
torchrequiredCore deep learning framework for all operations. Version compatibility is crucial.
Agent activity
14 hits · last 30 days
node
12
OpenAI (training)
1
Resources
asteroid-filterbanks — pip install asteroid-filterbanks · libregistry