SquimObjectiveBundle¶
- class torchaudio.pipelines.SquimObjectiveBundle[source]¶
捆绑关联信息以使用预训练
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 [source]¶
构建 SquimObjective 模型,并加载预训练权重。
- 返回值:
SquimObjective 的变体。