Skip to main content

A module for trainable encoder/decoder filterbanks with auditory bias.

Project description

Logo

License Tests GitHub stars

HybrA-Filterbanks

HybrA-Filterbanks is a PyTorch package for auditory-inspired filterbanks in audio machine learning.

It includes:

  • ISAC: invertible and stable auditory filterbank with customizable kernels
  • HybrA: ISAC extended with learnable channel-wise filters
  • ISACSpec: ISAC-based spectrogram features with temporal averaging
  • ISACCC: cepstral coefficients built on top of ISACSpec

Related papers:

HybrA magnitude training animation

Installation

pip install hybra

Quick Start

import torch
import torchaudio
from hybra import ISAC

audio, fs = torchaudio.load("your_audio.wav")
audio = audio.to(torch.float32)
if audio.shape[0] > 1:
    audio = audio.mean(dim=0, keepdim=True)

fb = ISAC(
    fs=fs,
    L=audio.shape[-1],
    kernel_size=1024,
    num_channels=128,
    scale="mel",
)

coeff = fb(audio)
recon = fb.decoder(coeff)
print(f"coeff shape: {tuple(coeff.shape)}")
print(f"recon shape: {tuple(recon.shape)}")

Typical Usage

HybrA with learnable filters

from hybra import HybrA

hybra = HybrA(
    fs=fs,
    L=audio.shape[-1],
    kernel_size=1024,
    learned_kernel_size=23,
    num_channels=128,
    tighten=True,
)

coeff = hybra(audio)
recon = hybra.decoder(coeff)
print(f"condition number: {hybra.condition_number:.3f}")

ISAC spectrogram and cepstral coefficients

from hybra import ISACCC, ISACSpec

spec = ISACSpec(
    fs=fs,
    L=audio.shape[-1],
    num_channels=40,
    power=2.0,
    is_log=True,
)
cc = ISACCC(
    fs=fs,
    L=audio.shape[-1],
    num_channels=40,
    num_cc=13,
)

spec_coeff = spec(audio)
cc_coeff = cc(audio)
print(spec_coeff.shape, cc_coeff.shape)

Use in a neural network

import torch
import torch.nn as nn
from hybra import HybrA

class Model(nn.Module):
    def __init__(self, fs: int, L: int):
        super().__init__()
        self.fb = HybrA(fs=fs, L=L, num_channels=40)
        self.net = nn.Sequential(
            nn.Conv1d(40, 128, kernel_size=1),
            nn.ReLU(),
            nn.Conv1d(128, 40, kernel_size=1),
            nn.Sigmoid(),
        )

    def forward(self, x: torch.Tensor) -> torch.Tensor:
        coeff = self.fb(x)
        mask = self.net(torch.log10(torch.clamp(coeff.abs() ** 2, min=1e-8)))
        return self.fb.decoder(coeff * mask)

Visualizations

ISAC frequency response:

HybrA frequency response:

Documentation

API docs: https://danedane-haider.github.io/HybrA-Filterbanks/main/

Development

Run tests from the project root:

uv run pytest

Citation

@inproceedings{haider2024holdmetight,
  author = {Haider, Daniel and Perfler, Felix and Lostanlen, Vincent and Ehler, Martin and Balazs, Peter},
  title = {Hold me tight: Stable encoder/decoder design for speech enhancement},
  booktitle = {Annual Conference of the International Speech Communication Association (Interspeech)},
  year = {2024}
}

@inproceedings{haider2025isac,
  author = {Haider, Daniel and Perfler, Felix and Balazs, Peter and Hollomey, Clara and Holighaus, Nicki},
  title = {{ISAC}: An Invertible and Stable Auditory Filter Bank with Customizable Kernels for ML Integration},
  booktitle = {International Conference on Sampling Theory and Applications (SampTA)},
  year = {2025}
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hybra-2026.2.1.tar.gz (31.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hybra-2026.2.1-py3-none-any.whl (26.4 kB view details)

Uploaded Python 3

File details

Details for the file hybra-2026.2.1.tar.gz.

File metadata

  • Download URL: hybra-2026.2.1.tar.gz
  • Upload date:
  • Size: 31.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for hybra-2026.2.1.tar.gz
Algorithm Hash digest
SHA256 09b59cccfd2755ec606db5e1982899b138cbebf565e694aaf657620a20314bd7
MD5 6b86fef40e9723e6def91bcc485a53fb
BLAKE2b-256 de007df86697acbb1f742a745a53f29b6a9dc11dec0940650da38c301c8c3bbc

See more details on using hashes here.

Provenance

The following attestation bundles were made for hybra-2026.2.1.tar.gz:

Publisher: publish-to-pypi.yml on danedane-haider/HybrA-Filterbanks

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file hybra-2026.2.1-py3-none-any.whl.

File metadata

  • Download URL: hybra-2026.2.1-py3-none-any.whl
  • Upload date:
  • Size: 26.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for hybra-2026.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 09d51e7762cbccfe01756c7766f17371881aa8a376b65b291792a52797b488f7
MD5 9e6fb519d6aa0d13b75845655538eca4
BLAKE2b-256 6a2b060c4196899b3db00a9e43045bb2f24369bf98e0ed34d71e829a0de29d63

See more details on using hashes here.

Provenance

The following attestation bundles were made for hybra-2026.2.1-py3-none-any.whl:

Publisher: publish-to-pypi.yml on danedane-haider/HybrA-Filterbanks

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page