Skip to main content

A Python package for applying convolution reverb to audio files using PyTorch

Project description

Convolution Reverb

A Python package for applying convolution reverb to audio files using PyTorch. This package provides an efficient implementation of convolution reverb using FFT-based convolution.

Installation

Install the package using pip:

pip install convolution-reverb

Requirements

  • Python >= 3.8
  • PyTorch >= 2.0.0
  • torchaudio >= 2.0.0

See requirements.txt

Usage

Basic Usage

from convolution_reverb import apply_reverb
import torchaudio

# Load audio files
audio_path = "speech_recording.wav"  # "path/to/your/audio.wav"
ir_path = "IRs/Tiny-IRs/IR_Earbuds.wav"  #"path/to/your/impulse_response.wav"
output_path = "output.wav"

# Apply reverb
original, convolved, sample_rate = apply_reverb(
    audio_path=audio_path,
    ir_path=ir_path,
    output_path=output_path,
    normalize=False
)

Working with Tensors Directly

If you're already working with audio tensors in PyTorch:

import torch
import torchaudio
from convolution_reverb import apply_reverb

# Load a sample audio
audio_wav, audio_wav_sr = torchaudio.load("speech_recording.wav")

# Load impulse response
ir_tensor, ir_sr = torchaudio.load("IRs/Tiny-IRs/IR_Tiny Speaker.wav")

# Apply reverb
original, convolved, sr = apply_reverb(
    audio_wav=audio_tensor,
    audio_wav_sr=audio_wav_sr,
    ir_wav=ir_tensor,
    ir_wav_sr=ir_sr,
    normalize=False
)

API Reference

apply_reverb

apply_reverb(
    audio_path: Union[str, None] = None,
    audio_wav: Union[torch.Tensor, None] = None,
    audio_wav_sr: Union[int, None] = None,
    ir_path: Union[str, None] = None,
    ir_wav: Union[torch.Tensor, None] = None,
    ir_wav_sr: Union[int, None] = None,
    output_path: Union[str, None] = None,
    normalize: bool = False
) -> Tuple[torch.Tensor, torch.Tensor, int]

Parameters:

  • audio_path: Path to the input audio file
  • audio_wav: Input audio as a torch.Tensor (n_channels, n_samples)
  • audio_wav_sr: Sampling rate of the input audio tensor
  • ir_path: Path to the impulse response file
  • ir_wav: Impulse response as a torch.Tensor (n_channels, n_samples)
  • ir_wav_sr: Sampling rate of the impulse response tensor
  • output_path: Path where the output audio will be saved
  • normalize: Whether to normalize the output audio

Returns:

  • Tuple containing:
    • Original audio waveform (torch.Tensor)
    • Convolved audio waveform (torch.Tensor)
    • Sample rate (int)

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

convolution_reverb-0.1.0.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

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

convolution_reverb-0.1.0-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file convolution_reverb-0.1.0.tar.gz.

File metadata

  • Download URL: convolution_reverb-0.1.0.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.16

File hashes

Hashes for convolution_reverb-0.1.0.tar.gz
Algorithm Hash digest
SHA256 54c6c2c049a6b305047e897d503c1c2efb3cc54a04b73f0fcda956c7752a2f59
MD5 64dabb210a1e9677fc95220da5b57fdf
BLAKE2b-256 95221ff970b695c0d18a687584867792be253f4443794ea0e137f9d3dc5856ed

See more details on using hashes here.

File details

Details for the file convolution_reverb-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for convolution_reverb-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c4a0075ace87cfc453c629695878f732d163ec5821d8282148948f5f320052ea
MD5 df7ab1d91c849d3c09a88f576eb0c9c1
BLAKE2b-256 bbcea68a4a74404512c1520f1527c569b5dc26c3b7e254d4a17767997ace8620

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