deepextractor.utils.stft

STFT / iSTFT helpers for magnitude+phase representation.

Module Contents

deepextractor.utils.stft.apply_stft(array, n_fft, hop_length, win_length, window)[source]

Compute STFT and return a magnitude+phase tensor.

Parameters:
  • array (array-like, shape (N, time) or (time,)) – Input time-series. Batched (N, time) is recommended; a 1D input will produce a (F, 2, time) tensor which is not compatible with UNET2D.

  • n_fft (int) – STFT parameters.

  • hop_length (int) – STFT parameters.

  • win_length (int) – STFT parameters.

  • window (torch.Tensor) – Analysis window (e.g. Hann), length win_length.

Returns:

Channel 0 = magnitude, channel 1 = phase.

Return type:

torch.Tensor, shape (N, 2, F, frames)

deepextractor.utils.stft.apply_istft(stft_array, n_fft, hop_length, win_length, window)[source]

Reconstruct time-domain signal from a magnitude+phase tensor.

Parameters:
  • stft_array (torch.Tensor, shape (N, 2, F, frames)) – Channel 0 = magnitude, channel 1 = phase.

  • n_fft (int) – STFT parameters (must match the forward transform).

  • hop_length (int) – STFT parameters (must match the forward transform).

  • win_length (int) – STFT parameters (must match the forward transform).

  • window (torch.Tensor) – Synthesis window, moved to the correct device automatically.

Return type:

torch.Tensor, shape (N, time)