快捷方式

BarkSpectrogram

class torchaudio.prototype.transforms.BarkSpectrogram(sample_rate: int = 16000, n_fft: int = 400, win_length: ~typing.Optional[int] = None, hop_length: ~typing.Optional[int] = None, f_min: float = 0.0, f_max: ~typing.Optional[float] = None, pad: int = 0, n_barks: int = 128, window_fn: ~typing.Callable[[...], ~torch.Tensor] = <built-in method hann_window of type object>, power: float = 2.0, normalized: bool = False, wkwargs: ~typing.Optional[dict] = None, center: bool = True, pad_mode: str = 'reflect', bark_scale: str = 'traunmuller')[source]

為原始音訊訊號建立 BarkSpectrogram。

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

這是 torchaudio.transforms.Spectrogram()torchaudio.transforms.BarkScale() 的組合。

來源
引數:
  • sample_rate (int, 可選) – 音訊訊號的取樣率。(預設值: 16000)

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

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

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

  • f_min (float, 可選) – 最小頻率。(預設值: 0.)

  • f_max (floatNone, 可選) – 最大頻率。(預設值: None)

  • pad (int, 可選) – 訊號的兩側填充。(預設值: 0)

  • n_barks (int, 可選) – Bark 濾波器組的數量。(預設值: 128)

  • window_fn (Callable[..., torch.Tensor], 可選) – 用於建立視窗張量並應用於每個幀/視窗的函式。(預設值: torch.hann_window)

  • power (float, 可選) – 幅度譜的指數(必須 > 0),例如,1 表示能量,2 表示功率等。(預設值: 2)

  • normalized (bool, 可選) – 是否在 STFT 後按幅度歸一化。(預設值: False)

  • wkwargs (Dict[..., ...] 或 None, 可選) – 視窗函式的引數。(預設值: None)

  • center (bool, 可選) – 是否在 waveform 兩側進行填充,以便第 \(t\) 幀以時間 \(t \times \text{hop\_length}\) 為中心。(預設值: True)

  • pad_mode (string, 可選) – 控制當 centerTrue 時使用的填充方法。(預設值: "reflect")

  • bark_scale (str, 可選) – 要使用的 Bark 刻度:traunmullerschroederwang。(預設值: traunmuller)

示例
>>> waveform, sample_rate = torchaudio.load("test.wav", normalize=True)
>>> transform = transforms.BarkSpectrogram(sample_rate)
>>> bark_specgram = transform(waveform)  # (channel, n_barks, time)

另請參閱

torchaudio.functional.melscale_fbanks() - 用於生成濾波器組的函式。

forward(waveform: Tensor) Tensor[source]
引數:

waveform (torch.Tensor) – 維度為 (…, time) 的音訊 torch.Tensor。

返回值:

Bark 頻率譜,大小為 (…, n_barks, time)。

返回型別:

torch.Tensor

文件

訪問 PyTorch 的全面開發者文件

檢視文件

教程

獲取針對初學者和高階開發者的深度教程

檢視教程

資源

查詢開發資源並獲得問題解答

檢視資源