快捷方式

SquimSubjectiveBundle

class torchaudio.pipelines.SquimSubjectiveBundle[source]

数据类,用于捆绑使用预训练 SquimSubjective 模型的相关信息。

此类提供用于实例化预训练模型的接口,以及检索预训练权重和与模型一起使用的附加信息所需的必要信息。

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

property SquimSubjectiveBundle.sample_rate

模型训练所用音频的采样率。

类型:

float

方法

get_model

SquimSubjectiveBundle.get_model() SquimSubjective[source]

构建 SquimSubjective 模型,并加载预训练权重。 :returns: SquimObjective 的变体。

文档

访问 PyTorch 的综合开发者文档

查看文档

教程

获取面向初学者和高级开发者的深入教程

查看教程

资源

查找开发资源并获得问题解答

查看资源