kaira.losses.audio.STFTLoss

Inheritance diagram of STFTLoss

Inheritance diagram for STFTLoss

class kaira.losses.audio.STFTLoss(fft_size=1024, hop_size=256, win_length=1024, window='hann')[source]

Bases: BaseLoss

STFT Loss Module.

This module calculates the STFT loss between the input and target audio signals, combining spectral convergence loss and log STFT magnitude loss.

Methods

__init__

Initialize the STFTLoss module.

forward

Forward pass through the STFTLoss module.

__init__(fft_size=1024, hop_size=256, win_length=1024, window='hann')[source]

Initialize the STFTLoss module.

Parameters:
  • fft_size (int) – FFT size for STFT. Default is 1024.

  • hop_size (int) – Hop size for STFT. Default is 256.

  • win_length (int) – Window length for STFT. Default is 1024.

  • window (str) – Window function type. Default is ‘hann’.

forward(x: Tensor, target: Tensor) Tensor[source]

Forward pass through the STFTLoss module.

Parameters:
Returns:

The combined STFT loss.

Return type:

torch.Tensor