快捷鍵

頻譜質心

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)[原始碼]

計算沿時間軸的每個通道的頻譜質心。

This feature supports the following devices: CPU, CUDA This API supports the following properties: Autograd, TorchScript

頻譜質心定義為頻率值的加權平均值,權重為其幅度。

參數:
  • sample_rate (int) – 音訊訊號的取樣率。

  • n_fft (int, 選用) – FFT 大小,建立 n_fft // 2 + 1 個頻率箱。(預設值:400)

  • win_length (intNone, 選用) – 視窗大小。(預設值:n_fft)

  • hop_length (intNone, 選用) – STFT 視窗之間的跳躍長度。(預設值:win_length // 2)

  • pad (int, 選用) – 訊號的雙邊填充。(預設值:0)

  • window_fn (Callable[..., Tensor], 選用) – 建立視窗張量的函數,該張量會應用/乘算到每個幀/視窗。(預設值:torch.hann_window)

  • wkwargs (dictNone, 選用) – 視窗函數的引數。(預設值:None)

範例
>>> waveform, sample_rate = torchaudio.load("test.wav", normalize=True)
>>> transform = transforms.SpectralCentroid(sample_rate)
>>> spectral_centroid = transform(waveform)  # (channel, time)
forward(waveform: Tensor) Tensor[原始碼]
參數:

waveform (Tensor) – 維度為 (…, time) 的音訊張量。

傳回:

大小為 (…, time) 的頻譜質心。

傳回類型:

Tensor

文件

存取 PyTorch 的完整開發者文件

檢視文件

教學

取得適用於初學者和進階開發者的深入教學

檢視教學

資源

尋找開發資源並獲得問題解答

檢視資源