快捷方式

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, 可选) – FFT 大小,创建 n_fft // 2 + 1 个 bin。(默认值: 400)

  • win_length (intNone, 可选) – 窗口大小。(默认值: n_fft)

  • hop_length (intNone, 可选) – STFT 窗口之间的跳跃长度。(默认值: win_length // 2)

  • pad (int, 可选) – 信号的两侧填充。(默认值: 0)

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

  • wkwargs (dictNone, 可选) – 窗口函数的参数。(默认值: 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)

返回类型:

Tensor

文档

查阅 PyTorch 的综合开发者文档

查看文档

教程

获取面向初学者和高级开发者的深度教程

查看教程

资源

查找开发资源并获得问题解答

查看资源