Shortcuts

SquimSubjectiveBundle

class torchaudio.pipelines.SquimSubjectiveBundle[source]

Data class that bundles associated information to use pretrained SquimSubjective model.

This class provides interfaces for instantiating the pretrained model along with the information necessary to retrieve pretrained weights and additional data to be used with the model.

Torchaudio library instantiates objects of this class, each of which represents a different pretrained model. Client code should access pretrained models via these instances.

This bundle can estimate subjective metric scores for speech enhancement, such as MOS. A typical use case would be a flow like waveform -> score. Please see below for the code example.

Example: Estimate the subjective metric scores for the input waveform.
>>> 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}.")

Properties

sample_rate

property SquimSubjectiveBundle.sample_rate

Sample rate of the audio that the model is trained on.

Type:

float

Methods

get_model

SquimSubjectiveBundle.get_model() SquimSubjective[source]

Construct the SquimSubjective model, and load the pretrained weight. :returns: Variation of SquimObjective.

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources