def func(tensor): sample_rate = 44100 n_fft = 400 ws = 400 hop = 200 pad = 0 window = torch.hann_window(ws, device=tensor.device, dtype=tensor.dtype) return F.spectral_centroid(tensor, sample_rate, pad, window, n_fft, hop, ws)
def forward(self, waveform: Tensor) -> Tensor: r""" Args: waveform (Tensor): Tensor of audio of dimension (..., time). Returns: Tensor: Spectral Centroid of size (..., time). """ return F.spectral_centroid(waveform, self.sample_rate, self.pad, self.window, self.n_fft, self.hop_length, self.win_length)