SquimObjectiveBundle¶
- class torchaudio.pipelines.SquimObjectiveBundle[原始碼]¶
資料類別,捆綁了相關資訊,以使用預訓練的
SquimObjective
模型。此類別提供介面,用於實例化預訓練模型,以及檢索預訓練權重和與模型一起使用的其他資料所需的資訊。
Torchaudio 函式庫實例化此類別的物件,每個物件代表一個不同的預訓練模型。用戶端程式碼應透過這些實例存取預訓練模型。
此捆綁包可以估計語音增強的客觀指標分數,例如 STOI、PESQ、Si-SDR。典型的用例流程如 波形 -> 分數列表。請參閱下面的程式碼範例。
- 範例:估計輸入波形的客觀指標分數。
>>> import torch >>> import torchaudio >>> from torchaudio.pipelines import SQUIM_OBJECTIVE as bundle >>> >>> # Load the SquimObjective bundle >>> model = bundle.get_model() Downloading: "https://download.pytorch.org/torchaudio/models/squim_objective_dns2020.pth" 100%|████████████| 28.2M/28.2M [00:03<00:00, 9.24MB/s] >>> >>> # Resample audio to the expected sampling rate >>> waveform = torchaudio.functional.resample(waveform, sample_rate, bundle.sample_rate) >>> >>> # Estimate objective metric scores >>> scores = model(waveform) >>> print(f"STOI: {scores[0].item()}, PESQ: {scores[1].item()}, SI-SDR: {scores[2].item()}.")
屬性¶
sample_rate¶
方法¶
get_model¶
- SquimObjectiveBundle.get_model() SquimObjective [原始碼]¶
建構 SquimObjective 模型,並載入預訓練權重。
- 返回:
SquimObjective
的變體。