window#
- class diffsptk.Window(in_length: int, out_length: int | None = None, *, window: str | int = 'blackman', norm: str | int = 'power')[source]#
See this page for details.
- Parameters:
- in_lengthint >= 1
The window length, \(L_1\).
- out_lengthint >= L1 or None
The output length, \(L_2\). If \(L_2 > L_1\), output is zero-padded. If None, \(L_2 = L_1\).
- window[‘blackman’, ‘hamming’, ‘hanning’, ‘bartlett’, ‘trapezoidal’, ‘rectangular’, ‘nuttall’]
The window type.
- norm[‘none’, ‘power’, ‘magnitude’]
The normalization type of the window.
- forward(x: Tensor) Tensor [source]#
Apply a window function to the given waveform.
- Parameters:
- xTensor [shape=(…, L1)]
The input framed waveform.
- Returns:
- outTensor [shape=(…, L2)]
The windowed waveform.
Examples
>>> x = torch.ones(5) >>> window = diffsptk.Window(5, out_length=7, window="hamming", norm="none") >>> y = window(x) >>> y tensor([0.0800, 0.5400, 1.0000, 0.5400, 0.0800, 0.0000, 0.0000])
- diffsptk.functional.window(x: Tensor, out_length: int | None = None, *, window: str = 'blackman', norm: str = 'power') Tensor [source]#
Apply a window function to the given waveform.
- Parameters:
- xTensor [shape=(…, L1)]
The input framed waveform.
- out_lengthint >= L1 or None
The output length, \(L_2\). If \(L_2 > L_1\), output is zero-padded. If None, \(L_2 = L_1\).
- window[‘blackman’, ‘hamming’, ‘hanning’, ‘bartlett’, ‘trapezoidal’, ‘rectangular’, ‘nuttall’]
The window type.
- norm[‘none’, ‘power’, ‘magnitude’]
The normalization type of the window.
- Returns:
- outTensor [shape=(…, L2)]
The windowed waveform.