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 SISNR Loss

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

Overview

Concrete tool for computing the Scale-Invariant Signal-to-Noise Ratio loss between output and reference audio signals.

Description

The SISNR class computes the negative SI-SNR loss, which is invariant to the overall scale of the signals. It operates on overlapping frames for long audio and mean-centers each frame before computing the projection of the estimate onto the reference. This is a standard loss for audio source separation and compression quality evaluation.

Usage

Import this loss when training audio compression or enhancement models where scale-invariant quality measurement is needed.

Code Reference

Source Location

Signature

class SISNR(nn.Module):
    def __init__(self, sample_rate: int = 16000, segment: float = 20, overlap: float = 0.5, epsilon=...):
        """
        Args:
            sample_rate: Audio sample rate.
            segment: Duration of each evaluation segment in seconds.
            overlap: Overlap ratio between segments.
        """
    def forward(self, out_sig: torch.Tensor, ref_sig: torch.Tensor) -> torch.Tensor: ...

Import

from audiocraft.losses.sisnr import SISNR

I/O Contract

Inputs

Name Type Required Description
out_sig torch.Tensor Yes Output audio [B, C, T]
ref_sig torch.Tensor Yes Reference audio [B, C, T]

Outputs

Name Type Description
loss torch.Tensor Negative SI-SNR (scalar, lower is better)

Usage Examples

from audiocraft.losses.sisnr import SISNR
import torch

loss_fn = SISNR(sample_rate=16000)
loss = loss_fn(output_audio, reference_audio)

Related Pages

Page Connections

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