zcross#
- class diffsptk.ZeroCrossingAnalysis(frame_length, norm=False, softness=0.001)[source]#
See this page for details.
- Parameters:
- frame_lengthint >= 1
The frame length in samples, \(L\).
- normbool
If True, divide the zero-crossing rate by the frame length.
- softnessfloat > 0
A smoothing parameter. The smaller value makes the output closer to the true zero-crossing rate, but the gradient vanishes.
- forward(x)[source]#
Compute zero-crossing rate.
- Parameters:
- xTensor [shape=(…, T)]
The input waveform.
- Returns:
- outTensor [shape=(…, T/L)]
The 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.])
- diffsptk.functional.zcross(x, frame_length, norm=False, softness=0.001)[source]#
Compute zero-crossing rate.
- Parameters:
- xTensor [shape=(…, T)]
The input waveform.
- frame_lengthint >= 1
The frame length in samples, \(L\).
- normbool
If True, divide the zero-crossing rate by the frame length.
- softnessfloat > 0
A smoothing parameter. The smaller value makes the output closer to the true zero-crossing rate, but the gradient vanishes.
- Returns:
- outTensor [shape=(…, T/L)]
The zero-crossing rate.