Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Facebookresearch Audiocraft AudioEffects

From Leeroopedia
Knowledge Sources
Domains Audio_Processing, Data_Augmentation
Last Updated 2026-02-14 01:00 GMT

Overview

Concrete tool for applying differentiable audio augmentations and effects to audio tensors provided by the AudioCraft library.

Description

AudioEffects is a static utility class providing a comprehensive library of audio effect methods including lowpass, highpass, bandpass filters, echo, reverb, speed changes, updownresample, MP3 compression, pink/white noise addition, duck, boost, compressor, smoothing, and encodec re-encoding. Each effect operates on PyTorch tensors and supports configurable parameters. Helper functions get_audio_effects, select_audio_effects, and audio_effect_return manage effect selection and application during training.

Usage

Import this class when applying audio augmentations during watermark training, or when building custom audio effect pipelines for data augmentation in AudioCraft models.

Code Reference

Source Location

Signature

class AudioEffects:
    @staticmethod
    def speed(wav: torch.Tensor, speed_range=(0.5, 1.5), sample_rate=16000, **kwargs):
        """Apply speed change to audio."""

    @staticmethod
    def lowpass_filter(wav: torch.Tensor, cutoff_freq=3000, sample_rate=16000, **kwargs):
        """Apply lowpass filter."""

    @staticmethod
    def mp3_compression(wav: torch.Tensor, sample_rate=16000, bitrate="128k", **kwargs):
        """Apply MP3 compression."""
    # ... additional effects

Import

from audiocraft.utils.audio_effects import AudioEffects, get_audio_effects, select_audio_effects

I/O Contract

Inputs

Name Type Required Description
wav torch.Tensor Yes Audio tensor [B, C, T] or [C, T]
sample_rate int No Sample rate (default 16000)
effect-specific params various No Each effect has its own parameters

Outputs

Name Type Description
wav torch.Tensor Processed audio tensor, same shape as input
mask torch.Tensor Optional mask for watermark training (returned by some effects)

Usage Examples

from audiocraft.utils.audio_effects import AudioEffects
import torch

wav = torch.randn(1, 1, 16000)  # 1s mono at 16kHz

# Apply lowpass filter
filtered = AudioEffects.lowpass_filter(wav, cutoff_freq=2000, sample_rate=16000)

# Apply MP3 compression
compressed = AudioEffects.mp3_compression(wav, sample_rate=16000, bitrate="64k")

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment