frame#

class diffsptk.Frame(frame_length: int, frame_period: int, *, center: bool = True, zmean: bool = False, mode: str = 'constant')[source]#

See this page for details.

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.

zmeanbool

If True, perform mean subtraction on each frame.

mode[‘constant’, ‘reflect’, ‘replicate’, ‘circular’]

The padding method.

forward(x: Tensor) Tensor[source]#

Apply framing to the given waveform.

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

The waveform.

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

The framed 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.]])
diffsptk.functional.frame(x: Tensor, frame_length: int = 400, frame_period: int = 80, center: bool = True, zmean: bool = False, mode: str = 'constant') Tensor[source]#

Apply framing to the given waveform.

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

The waveform.

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.

zmeanbool

If True, perform mean subtraction on each frame.

mode[‘constant’, ‘reflect’, ‘replicate’, ‘circular’]

The padding method.

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

The framed waveform.

See also

unframe window spec