快捷方式

PitchShift

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

将波形的音高移动 n_steps 步。

This feature supports the following devices: CPU, CUDA This API supports the following properties: TorchScript
参数
  • waveform (Tensor) – The input waveform of shape (…, time)

  • sample_rate (int) – waveform 的采样率。

  • n_steps (int) – 对 waveform 进行移调的(分数)步数。

  • bins_per_octave (int, optional) – 每八度音阶的步数(默认:12)。

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

  • win_length (int or None, optional) – 窗口大小。如果为 None,则使用 n_fft(默认:None)。

  • hop_length (int or None, optional) – STFT 窗口之间的跳跃长度。如果为 None,则使用 win_length // 4(默认:None)。

  • window (Tensor or None, optional) – 应用/乘以每个帧/窗口的窗口张量。如果为 None,则使用 torch.hann_window(win_length)(默认:None)。

示例
>>> waveform, sample_rate = torchaudio.load("test.wav", normalize=True)
>>> transform = transforms.PitchShift(sample_rate, 4)
>>> waveform_shift = transform(waveform)  # (channel, time)
initialize_parameters(input)[source]

根据输入批次的属性初始化参数。

这增加了一个接口,在进行参数形状推断时,将参数初始化与前向传播隔离开。

forward(waveform: Tensor) Tensor[source]
参数

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

返回

移调后的音频,形状为 (…, time)

返回类型

张量

文档

访问全面的 PyTorch 开发者文档

查看文档

教程

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

查看教程

资源

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

查看资源