快捷方式

SpectralCentroid

class torchaudio.transforms.SpectralCentroid(sample_rate: int, n_fft: int = 400, win_length: ~typing.Optional[int] = None, hop_length: ~typing.Optional[int] = None, pad: int = 0, window_fn: ~typing.Callable[[...], ~torch.Tensor] = <built-in method hann_window of type object>, wkwargs: ~typing.Optional[dict] = None)[source]

沿时间轴计算每个通道的谱质心。

This feature supports the following devices: CPU, CUDA This API supports the following properties: Autograd, TorchScript

谱质心定义为频率值按其幅度加权的平均频率值。

参数
  • sample_rate (int) – 音频信号的采样率。

  • n_fft (int, optional) – FFT的大小,创建 n_fft // 2 + 1 个 bin。 (默认: 400)

  • win_length (int or None, optional) – 窗口大小。 (默认: n_fft)

  • hop_length (int or None, optional) – STFT 窗口之间的步长。 (默认: win_length // 2)

  • pad (int, optional) – 信号的双边填充。 (默认: 0)

  • window_fn (Callable[..., Tensor], optional) – 一个用于创建应用于/乘以每个帧/窗口的窗口张量的函数。 (默认: torch.hann_window)

  • wkwargs (dict or None, optional) – 窗口函数的参数。 (默认: None)

示例
>>> waveform, sample_rate = torchaudio.load("test.wav", normalize=True)
>>> transform = transforms.SpectralCentroid(sample_rate)
>>> spectral_centroid = transform(waveform)  # (channel, time)
forward(waveform: Tensor) Tensor[source]
参数

waveform (Tensor) – 音频张量,维度为 (..., time)

返回

谱质心,维度为 (..., time)

返回类型

张量

文档

访问全面的 PyTorch 开发者文档

查看文档

教程

为初学者和高级开发者提供深入的教程

查看教程

资源

查找开发资源并让您的问题得到解答

查看资源