SquimSubjectiveBundle¶
- class torchaudio.pipelines.SquimSubjectiveBundle[source]¶
用于捆绑信息以使用预训练的
SquimSubjective
模型的类。此类可以估算语音增强的主观指标分数,例如 MOS。典型用例是 波形 -> 分数 的流程。代码示例请参见下文。此类提供用于实例化预训练模型以及检索预训练权重和模型附加数据所需信息的接口。
Torchaudio 库会实例化此类对象,每个对象代表一个不同的预训练模型。客户端代码应通过这些实例访问预训练模型。
此捆绑包可以估算语音增强的主观指标分数,例如 MOS。典型用例是 波形 -> 分数 的流程。代码示例请参见下文。
- 示例:估算输入波形的主观指标分数。
>>> import torch >>> import torchaudio >>> from torchaudio.pipelines import SQUIM_SUBJECTIVE as bundle >>> >>> # Load the SquimSubjective bundle >>> model = bundle.get_model() Downloading: "https://download.pytorch.org/torchaudio/models/squim_subjective_bvcc_daps.pth" 100%|████████████| 360M/360M [00:09<00:00, 41.1MB/s] >>> >>> # Resample audio to the expected sampling rate >>> waveform = torchaudio.functional.resample(waveform, sample_rate, bundle.sample_rate) >>> # Use a clean reference (doesn't need to be the reference for the waveform) as the second input >>> reference = torchaudio.functional.resample(reference, sample_rate, bundle.sample_rate) >>> >>> # Estimate subjective metric scores >>> score = model(waveform, reference) >>> print(f"MOS: {score}.")
属性¶
sample_rate¶
方法¶
get_model¶
- SquimSubjectiveBundle.get_model() SquimSubjective [source]¶
构建 SquimSubjective 模型并加载预训练权重。 :returns:
SquimObjective
的变体。