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
個 bins。(預設:400
)win_length (int 或 None, 選填) – 視窗大小。(預設值:
n_fft
)hop_length (int 或 None, 選填) – STFT 視窗之間的跳躍長度。(預設值:
win_length // 2
)pad (int, 選填) – 信號的雙邊填充。(預設值:
0
)window_fn (Callable[..., Tensor], 選填) – 一個建立視窗張量的函數,該張量會應用/乘到每個 frame/window。(預設值:
torch.hann_window
)normalized (bool 或 str, 選填) – STFT 輸出是否已通過幅度進行標準化。如果輸入為 str,則選項為
"window"
和"frame_length"
,取決於標準化模式。True
映射到"window"
。(預設值:False
)wkwargs (dict 或 None, 選填) – 視窗函數的參數。(預設值:
None
)center (bool, 選填) – 是否在頻譜圖中對信號進行雙邊填充,以便第 \(t\) 個 frame 以時間 \(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
的教學