STFT#
Domain:
ai.onnxSince version: 17
Computes the Short-time Fourier Transform of the signal.
Inputs
signal (T1): Input tensor representing a real or complex valued signal. For real input, the following shape is expected: [batch_size][signal_length][1]. For complex input, the following shape is expected: [batch_size][signal_length][2], where [batch_size][signal_length][0] represents the real component and [batch_size][signal_length][1] represents the imaginary component of the signal.
frame_step (T2): The number of samples to step between successive DFTs.
window (T1): A tensor representing the window that will be slid over the signal.The window must have rank 1 with shape: [window_shape]. It’s an optional value.
frame_length (T2): A scalar representing the size of the DFT. It’s an optional value.
Outputs
output (T1): The Short-time Fourier Transform of the signals.If onesided is 1, the output has the shape: [batch_size][frames][dft_unique_bins][2], where dft_unique_bins is frame_length // 2 + 1 (the unique components of the DFT) If onesided is 0, the output has the shape: [batch_size][frames][frame_length][2], where frame_length is the length of the DFT.
Attributes
onesided (int): If onesided is 1, only values for w in [0, 1, 2, …, floor(n_fft/2) + 1] are returned because the real-to-complex Fourier transform satisfies the conjugate symmetry, i.e., X[m, w] = X[m,w]=X[m,n_fft-w]*. Note if the input or window tensors are complex, then onesided output is not possible. Enabling onesided with real inputs performs a Real-valued fast Fourier transform (RFFT).When invoked with real or complex valued input, the default value is 1. Values can be 0 or 1.
Type Constraints
T1: Constrain signal and output to float tensors. Allowed types: tensor(bfloat16), tensor(double), tensor(float), tensor(float16).
T2: Constrain scalar length types to int64_t. Allowed types: tensor(int32), tensor(int64).
Examples#
test_cc_stft
Node:
STFT(signal, frame_step, "", frame_length) -> (output)
Attributes:
onesided = 1
Inputs:
signal: shape=(1, 16, 1), dtype=float32
[[[1.],
[2.],
[3.],
[4.],
[5.],
[6.],
[7.],
[8.],
[8.],
[7.],
[6.],
[5.],
[4.],
[3.],
[2.],
[1.]]]
frame_step: shape=(), dtype=int64
4
frame_length: shape=(), dtype=int64
8
Outputs:
output: shape=(1, 3, 5, 2), dtype=float32
[[[[ 3.6000000e+01, 0.0000000e+00],
[-4.0000000e+00, 9.6568546e+00],
[-4.0000000e+00, 4.0000000e+00],
[-4.0000000e+00, 1.6568543e+00],
[-4.0000000e+00, -3.9188699e-15]],
[[ 5.2000000e+01, 0.0000000e+00],
[-5.8284273e+00, -2.4142137e+00],
[-2.1431318e-15, -8.8817842e-16],
[-1.7157288e-01, -4.1421357e-01],
[ 0.0000000e+00, -2.2043643e-15]],
[[ 3.6000000e+01, 0.0000000e+00],
[ 4.0000000e+00, -9.6568546e+00],
[ 4.0000000e+00, -4.0000000e+00],
[ 4.0000000e+00, -1.6568543e+00],
[ 4.0000000e+00, -4.8985874e-16]]]]
test_cc_stft_complex_batched
Node:
STFT(signal, frame_step, "", frame_length) -> (output)
Attributes:
onesided = 0
Inputs:
signal: shape=(2, 128, 2), dtype=float32
[[[ 1., 0.],
[ 1., 0.],
[ 1., 0.],
...,
[ 1., 0.],
[ 1., 0.],
[ 1., 0.]],
[[99., 0.],
[99., 0.],
[99., 0.],
...,
[99., 0.],
[99., 0.],
[99., 0.]]]
frame_step: shape=(), dtype=int64
16
frame_length: shape=(), dtype=int64
32
Outputs:
output: shape=(2, 7, 32, 2), dtype=float32
[[[[ 3.2000000e+01, 0.0000000e+00],
[-2.3314684e-15, -2.2482016e-15],
[-3.3306691e-16, 0.0000000e+00],
...,
[-3.2973624e-14, -3.2751579e-14],
[ 6.1395333e-14, -3.2418512e-14],
[ 4.9960036e-14, -2.8810287e-14]],
[[ 3.2000000e+01, 0.0000000e+00],
[-2.3314684e-15, -2.2482016e-15],
[-3.3306691e-16, 0.0000000e+00],
...,
[-3.2973624e-14, -3.2751579e-14],
[ 6.1395333e-14, -3.2418512e-14],
[ 4.9960036e-14, -2.8810287e-14]],
[[ 3.2000000e+01, 0.0000000e+00],
[-2.3314684e-15, -2.2482016e-15],
[-3.3306691e-16, 0.0000000e+00],
...,
[-3.2973624e-14, -3.2751579e-14],
[ 6.1395333e-14, -3.2418512e-14],
[ 4.9960036e-14, -2.8810287e-14]],
...,
[[ 3.2000000e+01, 0.0000000e+00],
[-2.3314684e-15, -2.2482016e-15],
[-3.3306691e-16, 0.0000000e+00],
...,
[-3.2973624e-14, -3.2751579e-14],
[ 6.1395333e-14, -3.2418512e-14],
[ 4.9960036e-14, -2.8810287e-14]],
[[ 3.2000000e+01, 0.0000000e+00],
[-2.3314684e-15, -2.2482016e-15],
[-3.3306691e-16, 0.0000000e+00],
...,
[-3.2973624e-14, -3.2751579e-14],
[ 6.1395333e-14, -3.2418512e-14],
[ 4.9960036e-14, -2.8810287e-14]],
[[ 3.2000000e+01, 0.0000000e+00],
[-2.3314684e-15, -2.2482016e-15],
[-3.3306691e-16, 0.0000000e+00],
...,
[-3.2973624e-14, -3.2751579e-14],
[ 6.1395333e-14, -3.2418512e-14],
[ 4.9960036e-14, -2.8810287e-14]]],
[[[ 3.1680000e+03, 0.0000000e+00],
[ 2.8421709e-14, -9.5923269e-14],
[-8.5265128e-14, -8.5265128e-14],
...,
[-3.2827074e-12, -3.2329694e-12],
[ 6.1533001e-12, -3.1405989e-12],
[ 5.1727511e-12, -3.0588865e-12]],
[[ 3.1680000e+03, 0.0000000e+00],
[ 2.8421709e-14, -9.5923269e-14],
[-8.5265128e-14, -8.5265128e-14],
...,
[-3.2827074e-12, -3.2329694e-12],
[ 6.1533001e-12, -3.1405989e-12],
[ 5.1727511e-12, -3.0588865e-12]],
[[ 3.1680000e+03, 0.0000000e+00],
[ 2.8421709e-14, -9.5923269e-14],
[-8.5265128e-14, -8.5265128e-14],
...,
[-3.2827074e-12, -3.2329694e-12],
[ 6.1533001e-12, -3.1405989e-12],
[ 5.1727511e-12, -3.0588865e-12]],
...,
[[ 3.1680000e+03, 0.0000000e+00],
[ 2.8421709e-14, -9.5923269e-14],
[-8.5265128e-14, -8.5265128e-14],
...,
[-3.2827074e-12, -3.2329694e-12],
[ 6.1533001e-12, -3.1405989e-12],
[ 5.1727511e-12, -3.0588865e-12]],
[[ 3.1680000e+03, 0.0000000e+00],
[ 2.8421709e-14, -9.5923269e-14],
[-8.5265128e-14, -8.5265128e-14],
...,
[-3.2827074e-12, -3.2329694e-12],
[ 6.1533001e-12, -3.1405989e-12],
[ 5.1727511e-12, -3.0588865e-12]],
[[ 3.1680000e+03, 0.0000000e+00],
[ 2.8421709e-14, -9.5923269e-14],
[-8.5265128e-14, -8.5265128e-14],
...,
[-3.2827074e-12, -3.2329694e-12],
[ 6.1533001e-12, -3.1405989e-12],
[ 5.1727511e-12, -3.0588865e-12]]]]
test_cc_stft_twosided
Node:
STFT(signal, frame_step, "", frame_length) -> (output)
Attributes:
onesided = 0
Inputs:
signal: shape=(1, 16, 1), dtype=float32
[[[1.],
[2.],
[3.],
[4.],
[5.],
[6.],
[7.],
[8.],
[8.],
[7.],
[6.],
[5.],
[4.],
[3.],
[2.],
[1.]]]
frame_step: shape=(), dtype=int64
4
frame_length: shape=(), dtype=int64
8
Outputs:
output: shape=(1, 3, 8, 2), dtype=float32
[[[[ 3.6000000e+01, 0.0000000e+00],
[-4.0000000e+00, 9.6568546e+00],
[-4.0000000e+00, 4.0000000e+00],
[-4.0000000e+00, 1.6568543e+00],
[-4.0000000e+00, -3.9188699e-15],
[-4.0000000e+00, -1.6568543e+00],
[-4.0000000e+00, -4.0000000e+00],
[-4.0000000e+00, -9.6568546e+00]],
[[ 5.2000000e+01, 0.0000000e+00],
[-5.8284273e+00, -2.4142137e+00],
[-2.1431318e-15, -8.8817842e-16],
[-1.7157288e-01, -4.1421357e-01],
[ 0.0000000e+00, -2.2043643e-15],
[-1.7157288e-01, 4.1421357e-01],
[-1.7551422e-14, -2.6645353e-15],
[-5.8284273e+00, 2.4142137e+00]],
[[ 3.6000000e+01, 0.0000000e+00],
[ 4.0000000e+00, -9.6568546e+00],
[ 4.0000000e+00, -4.0000000e+00],
[ 4.0000000e+00, -1.6568543e+00],
[ 4.0000000e+00, -4.8985874e-16],
[ 4.0000000e+00, 1.6568543e+00],
[ 4.0000000e+00, 4.0000000e+00],
[ 4.0000000e+00, 9.6568546e+00]]]]
test_cc_stft_with_window
Node:
STFT(signal, frame_step, window, frame_length) -> (output)
Attributes:
onesided = 1
Inputs:
signal: shape=(1, 16, 1), dtype=float32
[[[1.],
[2.],
[3.],
[4.],
[5.],
[6.],
[7.],
[8.],
[8.],
[7.],
[6.],
[5.],
[4.],
[3.],
[2.],
[1.]]]
frame_step: shape=(), dtype=int64
4
window: shape=(8,), dtype=float32
[1., 1., 1., 1., 1., 1., 1., 1.]
frame_length: shape=(), dtype=int64
8
Outputs:
output: shape=(1, 3, 5, 2), dtype=float32
[[[[ 3.6000000e+01, 0.0000000e+00],
[-4.0000000e+00, 9.6568546e+00],
[-4.0000000e+00, 4.0000000e+00],
[-4.0000000e+00, 1.6568543e+00],
[-4.0000000e+00, -3.9188699e-15]],
[[ 5.2000000e+01, 0.0000000e+00],
[-5.8284273e+00, -2.4142137e+00],
[-2.1431318e-15, -8.8817842e-16],
[-1.7157288e-01, -4.1421357e-01],
[ 0.0000000e+00, -2.2043643e-15]],
[[ 3.6000000e+01, 0.0000000e+00],
[ 4.0000000e+00, -9.6568546e+00],
[ 4.0000000e+00, -4.0000000e+00],
[ 4.0000000e+00, -1.6568543e+00],
[ 4.0000000e+00, -4.8985874e-16]]]]