istft#

diffsptk.ISTFT#

alias of InverseShortTimeFourierTransform

class diffsptk.InverseShortTimeFourierTransform(frame_length: int, frame_period: int, fft_length: int, *, center: bool = True, window: str = 'blackman', norm: str = 'power')[source]#

This is the opposite module to ShortTimeFourierTransform().

Parameters:
frame_lengthint >= 1

The frame length in samples, \(L\).

frame_periodint >= 1

The frame period in samples, \(P\).

fft_lengthint >= L

The number of FFT bins, \(N\).

centerbool

If True, pad the input on both sides so that the frame is centered.

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

The window type.

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

The normalization type of the window.

forward(y: Tensor, out_length: int | None = None) Tensor[source]#

Compute inverse short-time Fourier transform.

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

The complex spectrogram.

out_lengthint > 0 or None

The length of the output waveform.

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

The reconstructed 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.])
diffsptk.functional.istft(y: Tensor, *, out_length: int | None = None, frame_length: int = 400, frame_period: int = 80, fft_length: int = 512, center: bool = True, window: str = 'blackman', norm: str = 'power') Tensor[source]#

Compute inverse short-time Fourier transform.

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

The complex spectrogram.

out_lengthint >= 1 or None

The length of the output waveform.

frame_lengthint >= 1

The frame length in samples, \(L\).

frame_periodint >= 1

The frame period in samples, \(P\).

fft_lengthint >= L

The number of FFT bins, \(N\).

centerbool

If True, pad the input on both sides so that the frame is centered.

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

The window type.

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

The normalization type of the window.

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

The reconstructed waveform.

See also

unframe window spec stft