unframe#

class diffsptk.Unframe(frame_length: int, frame_period: int, *, center: bool = True, window: str = 'rectangular', norm: str = 'none')[source]#

This is the opposite module to Frame().

Parameters:
frame_lengthint >= 1

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

frame_periodint >= 1

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

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]#

Revert the framed waveform to the unframed waveform.

Parameters:
yTensor [shape=(…, T/P, L)]

The framed waveform.

out_lengthint or None

The length of the original waveform, \(T\).

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

The unframed waveform.

Examples

>>> x = diffsptk.ramp(1, 9)
>>> frame = diffsptk.Frame(5, 2)
>>> y = frame(x)
>>> y
tensor([[0., 0., 1., 2., 3.],
        [1., 2., 3., 4., 5.],
        [3., 4., 5., 6., 7.],
        [5., 6., 7., 8., 9.],
        [7., 8., 9., 0., 0.]])
>>> unframe = diffsptk.Unframe(5, 2)
>>> z = unframe(y, out_length=x.size(0))
>>> z
tensor([1., 2., 3., 4., 5., 6., 7., 8., 9.])
diffsptk.functional.unframe(y: Tensor, out_length: int | None = None, *, frame_period: int = 80, center: bool = True, window: str = 'rectangular', norm: str = 'none') Tensor[source]#

Revert framed waveform.

Parameters:
yTensor [shape=(…, T/P, L)]

The framed waveform.

out_lengthint >= 1 or None

The length of the original waveform, \(T\).

frame_peirodint >= 1

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

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 unframed waveform.

See also

frame window