torchaudio.functional.phase_vocoder¶
- torchaudio.functional.phase_vocoder(complex_specgrams: Tensor, rate: float, phase_advance: Tensor) Tensor [source]¶
给定一个 STFT 张量,在不改变音高的情况下,将时间速度提高
rate
倍。- 参数:
complex_specgrams (Tensor) – 一个维度为 (…, freq, num_frame) 的张量,数据类型为复数。
rate (float) – 加速因子
phase_advance (Tensor) – 每个 bin 的预期相位增量。维度为 (freq, 1)
- 返回:
拉伸后的频谱图。生成的张量的数据类型与输入频谱图相同,但帧数更改为
ceil(num_frame / rate)
。- 返回类型:
Tensor
- 示例
>>> freq, hop_length = 1025, 512 >>> # (channel, freq, time) >>> complex_specgrams = torch.randn(2, freq, 300, dtype=torch.cfloat) >>> rate = 1.3 # Speed up by 30% >>> phase_advance = torch.linspace( >>> 0, math.pi * hop_length, freq)[..., None] >>> x = phase_vocoder(complex_specgrams, rate, phase_advance) >>> x.shape # with 231 == ceil(300 / 1.3) torch.Size([2, 1025, 231])