InverseSpectrogram¶
- class torchaudio.transforms.InverseSpectrogram(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>, normalized: ~typing.Union[bool, str] = False, wkwargs: ~typing.Optional[dict] = None, center: bool = True, pad_mode: str = 'reflect', onesided: bool = True)[源]¶
创建一个逆频谱图,用于从频谱图恢复音频信号。
- 参数
n_fft (int, 可选) – FFT 的大小,创建
n_fft // 2 + 1
个频带。 (默认:400
)win_length (int 或 None, 可选) – 窗口大小。 (默认:
n_fft
)hop_length (int 或 None, 可选) – STFT 窗口之间的跳跃长度。 (默认:
win_length // 2
)pad (int, 可选) – 信号的双向填充。 (默认:
0
)window_fn (Callable[..., Tensor], 可选) – 用于创建应用于/乘以每个帧/窗口的窗口张量的函数。 (默认:
torch.hann_window
)normalized (bool 或 str, 可选) – STFT 输出是否按幅度进行了归一化。如果输入为 str,则选项为
"window"
和"frame_length"
,取决于归一化模式。True
映射到"window"
。 (默认:False
)wkwargs (dict 或 None, 可选) – 窗口函数的参数。 (默认:
None
)center (bool, 可选) – 频谱图中的信号是否在两侧填充,以便 \(t\)-th 帧位于时间 \(t \times \text{hop\_length}\) 处。 (默认:
True
)pad_mode (string, 可选) – 控制
center
为True
时使用的填充方法。 (默认:"reflect"
)onesided (bool, 可选) – 控制频谱图是否用于避免冗余返回一半结果 (默认:
True
)
- 示例
>>> batch, freq, time = 2, 257, 100 >>> length = 25344 >>> spectrogram = torch.randn(batch, freq, time, dtype=torch.cdouble) >>> transform = transforms.InverseSpectrogram(n_fft=512) >>> waveform = transform(spectrogram, length)
- 使用
InverseSpectrogram
的教程