medfilt#
- class diffsptk.MedianFilter(filter_length: int, across_features: bool = False, magic_number: float | None = None)[source]#
See this page for details.
- Parameters:
- filter_lengthint > 0
The length of the median filter, \(L\).
- across_featuresbool
If True, apply the filter across the feature dimension.
- magic_numberfloat or None
The magic number representing unvoiced frames.
- forward(x: Tensor) Tensor[source]#
Apply median filtering to the input sequence.
- Parameters:
- xTensor [shape=(B, N, D) or (N, D) or (N,)]
The input sequence.
- Returns:
- outTensor [shape=(B, N, D) or (B, N) or (N, D) or (N,)]
The filtered sequence.
Examples
>>> import torch >>> import diffsptk >>> medfilt = diffsptk.MedianFilter(3) >>> x = torch.tensor([0, 2, -2, 7, 4, 8]).float() >>> y = medfilt(x) >>> y tensor([1., 0., 2., 4., 7., 6.])
- diffsptk.functional.medfilt(x: Tensor, filter_length: int = 3, across_features: bool = False, magic_number: float | None = None) Tensor[source]#
Apply median filtering to the input sequence.
- Parameters:
- xTensor [shape=(B, N, D) or (N, D) or (N,)]
The input sequence.
- filter_lengthint > 0
The length of the median filter, \(L\).
- across_featuresbool
If True, apply the filter across the feature dimension.
- magic_numberfloat or None
The magic number representing unvoiced frames.
- Returns:
- outTensor [shape=(B, N, D) or (B, N) or (N, D) or (N,)]
The filtered sequence.