Skip to main content

A GPU accelerated library for audio DSP based on PyTorch

Project description

torchfx

License: GPL v3 arXiv PyPI version PyPI - Status

TorchFX is a Python library that provides a modern approach to audio digital signal processing (DSP) using PyTorch. It allows you to create and manipulate audio processing pipelines in a flexible and efficient way, leveraging the power of PyTorch for GPU acceleration. TorchFX is designed to be easy to use and integrate with existing PyTorch workflows, making it a great choice for researchers and developers working in the field of audio processing.

Features

  • GPU Acceleration: Leverage the power of GPUs for real-time audio processing.
  • Flexible Pipelines: Create complex audio processing pipelines using a simple and intuitive API.
  • Pytorch Integration: Seamlessly integrate with existing PyTorch workflows and models.
  • Pipe operator: Use the pipe operator (|) to create and manipulate audio processing pipelines in a more readable and concise way.

Installation

To install TorchFX, you can use pip:

pip install torchfx

or clone the repository and install it manually:

git clone https://github.com/matteospanio/torchfx
cd torchfx
pip install -e .

Usage

TorchFX provides a simple and intuitive API for creating and manipulating audio processing pipelines. Here is a basic example of how to use TorchFX:

import torch
import torchfx as fx

# Create a simple audio processing pipeline
filtered_out = (
    fx.Wave.from_file("path_to_audio.wav")
    | fx.filter.LoButterworth(8000)
    | fx.filter.HiShelving(2000)
    | fx.effect.Reverb()
)

This example demonstrates how to create a simple audio processing pipeline using the | operator. The pipeline reads an audio file, applies a low-pass Butterworth filter, and then applies a high-shelving filter. torchfx provides a Wave class that embeds the audio signal and its sampling rate in a single object. This allows you to easily manipulate the audio signal and apply various transformations using the provided filters. This class provides the bitwise or operator overloading, which allows you to chain multiple filters (and any kind of nn.Module) together in a single pipeline.

API

At the moment the API is not fully documented, but you can find the list of available filters in the filter module.

How to cite

If you use this code in your research, please cite the following paper:

@misc{spanio2025torchfxmodernapproachaudio,
      title={TorchFX: A modern approach to Audio DSP with PyTorch and GPU acceleration},
      author={Matteo Spanio and Antonio Rodà},
      year={2025},
      eprint={2504.08624},
      archivePrefix={arXiv},
      primaryClass={eess.AS},
      url={https://arxiv.org/abs/2504.08624},
}

TODO

  • add realtime input support
  • add more examples

License

This project is licensed under the terms of the GNU General Public License v3.0. See the LICENSE file for details.

Third-Party Acknowledgments

This project uses the following third-party libraries:

Their respective license texts are included in the licenses/ directory.

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

torchfx-0.2.1.tar.gz (3.5 MB view details)

Uploaded Source

Built Distribution

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

torchfx-0.2.1-py3-none-any.whl (44.9 kB view details)

Uploaded Python 3

File details

Details for the file torchfx-0.2.1.tar.gz.

File metadata

  • Download URL: torchfx-0.2.1.tar.gz
  • Upload date:
  • Size: 3.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.5

File hashes

Hashes for torchfx-0.2.1.tar.gz
Algorithm Hash digest
SHA256 5001ec5aa42c3e503a4f8a9d7a62c782982c38a7f04a7b4736b332532eaa2b36
MD5 76a6126a2909e97a065ffd531425c524
BLAKE2b-256 e28b809873b5b79be6a681f60a3b8388ef66dc97762dabcc8a1f732568a1e218

See more details on using hashes here.

File details

Details for the file torchfx-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: torchfx-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 44.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.5

File hashes

Hashes for torchfx-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 08d6149760118ff84d72d1c6d4ad6f435734552ab4252228c093d701108fe6dc
MD5 704df9b87283c512dd9dba1f286d7dc4
BLAKE2b-256 fa1083639218e6a2bc6b89023fa0316cbfa977e3a43e700bfbcbf5bda9915b25

See more details on using hashes here.

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