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')[原始碼]¶
為原始音訊訊號建立 BarkSpectrogram。
這是
torchaudio.transforms.Spectrogram()
和torchaudio.transforms.BarkScale()
的組合。- 來源
https://www.fon.hum.uva.nl/praat/manual/BarkSpectrogram.html
Traunmüller, Hartmut. “Analytical Expressions for the Tonotopic Sensory Scale.” Journal of the Acoustical
Society of America. Vol. 88, Issue 1, 1990, pp. 97–100.
https://ccrma.stanford.edu/courses/120-fall-2003/lecture-5.html
- 參數:
sample_rate (int, optional) – 音訊訊號的取樣率。(預設:
16000
)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
)f_min (float, 選用) – 最小頻率。(預設值:
0.
)f_max (float 或 None, 選用) – 最大頻率。(預設值:
None
)pad (int, 選用) – 訊號的雙邊填充。(預設值:
0
)n_mels (int, 選用) – mel濾波器的數量。(預設值:
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, 選用) – 控制當
center
為True
時使用的填充方法。(預設值:"reflect"
)bark_scale (str, 選用) – 使用的比例:
traunmuller
、schroeder
或wang
。(預設值: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 [原始碼]¶
- 參數:
waveform (torch.Tensor) – 音訊的 torch.Tensor,維度為 (…, 時間)。
- 傳回:
大小為 (…,
n_barks
, 時間) 的 Bark 頻率頻譜圖。- 傳回類型: