istft

paddle.signal. istft ( x, n_fft, hop_length=None, win_length=None, window=None, center=True, normalized=False, onesided=True, length=None, return_complex=False, name=None ) [source]

Inverse short-time Fourier transform (ISTFT).

Reconstruct time-domain signal from the giving complex input and window tensor when nonzero overlap-add (NOLA) condition is met:

\[\sum_{t = -\infty}^{\infty} \text{window}^2[n - t \times H]\ \neq \ 0, \ \text{for } all \ n\]

Where: - \(t\): The \(t\)-th input window. - \(N\): Value of n_fft. - \(H\): Value of hop_length.

Result of istft expected to be the inverse of paddle.signal.stft, but it is not guaranteed to reconstruct a exactly realizable time-domain signal from a STFT complex tensor which has been modified (via masking or otherwise). Therefore, istft gives the [Griffin-Lim optimal estimate] (optimal in a least-squares sense) for the corresponding signal.

Parameters
  • x (Tensor) – The input data which is a 2-dimensional or 3-dimensional complex Tensor with shape […, n_fft, num_frames].

  • n_fft (int) – The size of Fourier transform.

  • hop_length (int, optional) – Number of steps to advance between adjacent windows from time-domain signal and 0 < hop_length < win_length. Default: None ( treated as equal to n_fft//4)

  • win_length (int, optional) – The size of window. Default: None (treated as equal to n_fft)

  • window (Tensor, optional) – A 1-dimensional tensor of size win_length. It will be center padded to length n_fft if win_length < n_fft. It should be a real-valued tensor if return_complex is False. Default: None`(treated as a rectangle window with value equal to 1 of size `win_length).

  • center (bool, optional) – It means that whether the time-domain signal has been center padded. Default: True.

  • normalized (bool, optional) – Control whether to scale the output by \(1/sqrt(n_{fft})\). Default: False

  • onesided (bool, optional) – It means that whether the input STFT tensor is a half of the conjugate symmetry STFT tensor transformed from a real-valued signal and istft will return a real-valued tensor when it is set to True. Default: True.

  • length (int, optional) – Specify the length of time-domain signal. Default: `None`( treated as the whole length of signal).

  • return_complex (bool, optional) – It means that whether the time-domain signal is real-valued. If return_complex is set to True, onesided should be set to False cause the output is complex.

  • name (str, optional) – The default value is None. Normally there is no need for user to set this property. For more information, please refer to Name.

Returns

A tensor of least squares estimation of the reconstructed signal(s) with shape […, seq_length]

Examples

>>> import numpy as np
>>> import paddle
>>> from paddle.signal import stft, istft

>>> paddle.seed(0)

>>> # STFT
>>> x = paddle.randn([8, 48000], dtype=paddle.float64)
>>> y = stft(x, n_fft=512)
>>> print(y.shape)
[8, 257, 376]

>>> # ISTFT
>>> x_ = istft(y, n_fft=512)
>>> print(x_.shape)
[8, 48000]

>>> np.allclose(x, x_)
True