istft#

diffsptk.ISTFT#

alias of InverseShortTermFourierTransform

class diffsptk.InverseShortTermFourierTransform(frame_length, frame_period, fft_length, *, center=True, norm='power', window='blackman')[source]#

This is the opposite module to ShortTermFourierTransform()

Parameters:
frame_lengthint >= 1 [scalar]

Frame length, \(L\).

frame_peirodint >= 1 [scalar]

Frame period, \(P\).

fft_lengthint >= L [scalar]

Number of FFT bins, \(N\).

centerbool [scalar]

If True, assume that the center of data is the center of frame, otherwise assume that the center of data is the left edge of frame.

norm[‘none’, ‘power’, ‘magnitude’]

Normalization type of window.

window[‘blackman’, ‘hamming’, ‘hanning’, ‘bartlett’, ‘trapezoidal’, ‘rectangular’]

Window type.

forward(y, out_length=None)[source]#

Compute inverse short-term Fourier transform.

Parameters:
yTensor [shape=(…, T/P, N/2+1)]

Complex spectrum.

Returns:
xTensor [shape=(…, T)]

Waveform.

Examples

>>> x = diffsptk.ramp(1, 3)
>>> x
tensor([1., 2., 3.])
>>> stft_params = {"frame_length": 3, "frame_period": 1, "fft_length": 8}
>>> stft = diffsptk.STFT(**stft_params, out_format="complex")
>>> istft = diffsptk.ISTFT(**stft_params)
>>> y = istft(stft(x), out_length=3)
>>> y
tensor([1., 2., 3.])

See also

frame window spec stft