zcross#

class diffsptk.ZeroCrossingAnalysis(frame_length, norm=False)[source]#

See this page for details. Note that this module cannot compute gradient.

Parameters:
frame_lengthint >= 1 [scalar]

Frame length, \(L\).

normbool [scalar]

If True, divide zero-crossing rate by frame length.

forward(x)[source]#

Compute zero-crossing rate.

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

Waveform.

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

Zero-crossing rate.

Examples

>>> x = diffsptk.nrand(5)
>>> x
tensor([-0.2388,  0.3587, -0.6606, -0.6929,  0.5239,  0.4501])
>>> zcross = diffsptk.ZeroCrossingAnalysis(3)
>>> z = zcross(x)
>>> z
tensor([2., 1.])