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)[source]¶
创建逆频谱图以从频谱图中恢复音频信号。
- 参数:
n_fft (int, optional) – FFT 大小,创建
n_fft // 2 + 1
个 bin。(默认值:400
)win_length (int 或 None,可选) – 窗口大小。(默认值:
n_fft
)hop_length (int 或 None,可选) – STFT 窗口之间的跳跃长度。(默认值:
win_length // 2
)pad (int, optional) – 信号的双边填充。(默认值:
0
)window_fn (Callable[..., Tensor], optional) – 用于创建窗口张量的函数,该张量应用于/乘以每个帧/窗口。(默认值:
torch.hann_window
)normalized (bool 或 str, optional) – stft 输出是否按幅度归一化。如果输入为 str,则选项为
"window"
和"frame_length"
,取决于归一化模式。True
映射到"window"
。(默认值:False
)wkwargs (dict 或 None,optional) – 窗口函数的参数。(默认值:
None
)center (bool, optional) – 频谱图中的信号是否在两侧填充,以便第 \(t\) 帧以时间 \(t \times \text{hop\_length}\) 为中心。(默认值:
True
)pad_mode (string, optional) – 控制当
center
为True
时使用的填充方法。(默认值:"reflect"
)onesided (bool, optional) – 控制频谱图是否用于返回一半结果以避免冗余(默认值:
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
的教程