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。
這是
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, 可選) – 音訊訊號的取樣率。(預設值:
16000)n_fft (int, 可選) – FFT 大小,建立
n_fft // 2 + 1個 bin。(預設值: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_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, 可選) – 控制當
center為True時使用的填充方法。(預設值:"reflect")bark_scale (str, 可選) – 要使用的 Bark 刻度:
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[source]¶
- 引數:
waveform (torch.Tensor) – 維度為 (…, time) 的音訊 torch.Tensor。
- 返回值:
Bark 頻率譜,大小為 (…,
n_barks, time)。- 返回型別: