deepextractor.utils.stft ======================== .. py:module:: deepextractor.utils.stft .. autoapi-nested-parse:: STFT / iSTFT helpers for magnitude+phase representation. Module Contents --------------- .. py:function:: apply_stft(array, n_fft, hop_length, win_length, window) Compute STFT and return a magnitude+phase tensor. :param array: Input time-series. Batched (N, time) is recommended; a 1D input will produce a (F, 2, time) tensor which is not compatible with UNET2D. :type array: array-like, shape (N, time) or (time,) :param n_fft: STFT parameters. :type n_fft: int :param hop_length: STFT parameters. :type hop_length: int :param win_length: STFT parameters. :type win_length: int :param window: Analysis window (e.g. Hann), length ``win_length``. :type window: torch.Tensor :returns: Channel 0 = magnitude, channel 1 = phase. :rtype: torch.Tensor, shape (N, 2, F, frames) .. py:function:: apply_istft(stft_array, n_fft, hop_length, win_length, window) Reconstruct time-domain signal from a magnitude+phase tensor. :param stft_array: Channel 0 = magnitude, channel 1 = phase. :type stft_array: torch.Tensor, shape (N, 2, F, frames) :param n_fft: STFT parameters (must match the forward transform). :type n_fft: int :param hop_length: STFT parameters (must match the forward transform). :type hop_length: int :param win_length: STFT parameters (must match the forward transform). :type win_length: int :param window: Synthesis window, moved to the correct device automatically. :type window: torch.Tensor :rtype: torch.Tensor, shape (N, time)