快捷方式

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)[源]

将波形的音高移动 n_steps 步。

This feature supports the following devices: CPU, CUDA This API supports the following properties: TorchScript
参数
  • waveform (Tensor) – 形状为 (..., time) 的输入波形。

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

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

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

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

  • win_length (intNone, 可选) – 窗口大小。如果为 None,则使用 n_fft。(默认:None)。

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

  • window (TensorNone, 可选) – 应用/乘以每个帧/窗口的窗口张量。如果为 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)[源]

Initialize parameters according to the input batch properties.

This adds an interface to isolate parameter initialization from the forward pass when doing parameter shape inference.

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

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

返回

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

返回类型

张量

文档

访问全面的 PyTorch 开发者文档

查看文档

教程

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

查看教程

资源

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

查看资源