mindspore.ops.STFT

class mindspore.ops.STFT(n_fft, hop_length, win_length, normalized, onesided, return_complex)[source]

STFTs can be used as a way of quantifying the change of a nonstationary signal’s frequency and phase content over time.

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

  • hop_length (int) – The distance between neighboring sliding window frames.

  • win_length (int) – the size of window frame and STFT filter.

  • normalized (bool) – controls whether to return the normalized STFT results.

  • onesided (bool) – controls whether to return half of results to avoid redundancy for real inputs.

  • return_complex (bool) – If True, return a complex tensor. If False, return a real tensor with an extra last dimension for the real and imaginary components.

Inputs:
  • x (Tensor) - Time sequence of stft, must be either a 1-D time tensor or a 2-D tensor.

  • window (Tensor) - the optional window function.

Outputs:
  • y (Tensor) - A tensor containing the STFT result with shape described above.

Examples

>>> import mindspore as ms
>>> from mindspore.ops import STFT
>>> import numpy as np
>>> x = ms.Tensor(np.random.rand(2,7192), ms.float32)
>>> window = ms.Tensor(np.random.rand(64), ms.float32)
>>> stft = STFT(64, 16, 64, False, True, True)
>>> output = stft(x, window)
>>> print(output.shape)
(2, 33, 446)