stft#
- diffsptk.STFT#
- alias of - ShortTermFourierTransform
- class diffsptk.ShortTermFourierTransform(frame_length, frame_period, fft_length, *, center=True, zmean=False, norm='power', window='blackman', out_format='power', eps=1e-09, relative_floor=None)[source]#
- This module is a simple cascade of framing, windowing, and spectrum calculation. - 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. 
- zmeanbool [scalar]
- If True, perform mean subtraction on each frame. 
- norm[‘none’, ‘power’, ‘magnitude’]
- Normalization type of window. 
- window[‘blackman’, ‘hamming’, ‘hanning’, ‘bartlett’, ‘trapezoidal’, ‘rectangular’]
- Window type. 
- out_format[‘db’, ‘log-magnitude’, ‘magnitude’, ‘power’, ‘complex’]
- Output format. 
- epsfloat >= 0 [scalar]
- A small value added to power spectrum. 
- relative_floorfloat < 0 [scalar]
- Relative floor in decibels. 
 
 - forward(x)[source]#
- Compute short-term Fourier transform. - Parameters:
- xTensor [shape=(…, T)]
- Waveform. 
 
- Returns:
- yTensor [shape=(…, T/P, N/2+1)]
- Spectrum. 
 
 - Examples - >>> x = diffsptk.ramp(1, 3) >>> x tensor([1., 2., 3.]) >>> stft = diffsptk.STFT(frame_length=3, frame_period=1, fft_length=8) >>> y = stft(x) >>> y tensor([[1.0000, 1.0000, 1.0000, 1.0000, 1.0000], [4.0000, 4.0000, 4.0000, 4.0000, 4.0000], [9.0000, 9.0000, 9.0000, 9.0000, 9.0000]])