SpectralCentroid¶
- class torchaudio.transforms.SpectralCentroid(sample_rate: int, 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>, wkwargs: ~typing.Optional[dict] = None)[source]¶
- 計算沿時間軸的每個通道的頻譜質心。 - 頻譜質心被定義為頻率值的加權平均值,權重為其幅度。 - 引數:
- sample_rate (int) – 音訊訊號的取樣率。 
- n_fft (int, 可選) – FFT 大小,建立 - n_fft // 2 + 1個 bin。(預設值:- 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)
- wkwargs (dict 或 None, 可選) – 視窗函式的引數。(預設值: - None)
 
 - 示例
- >>> waveform, sample_rate = torchaudio.load("test.wav", normalize=True) >>> transform = transforms.SpectralCentroid(sample_rate) >>> spectral_centroid = transform(waveform) # (channel, time)