---
title: Deep Noise Suppression Mean Opinion Score (DNSMOS)
description: >-
  Calculate Deep Noise Suppression performance evaluation based on Mean Opinion
  Score (DNSMOS).
canonical: >-
  https://lightning.ai/docs/torchmetrics/stable/audio/deep_noise_suppression_mean_opinion_score
---
# Deep Noise Suppression Mean Opinion Score (DNSMOS) {#deep-noise-suppression-mean-opinion-score-dnsmos}

## Module Interface {#module-interface}

### `class torchmetrics.audio.dnsmos.DeepNoiseSuppressionMeanOpinionScore(fs, personalized, device=None, num_threads=None, cache_sessions=True, **kwargs)` {#torchmetrics.audio.dnsmos.DeepNoiseSuppressionMeanOpinionScore}

[\[source\]](https://github.com/Lightning-AI/torchmetrics/blob/v1.9.0/src/torchmetrics/audio/dnsmos.py#L36-L186)

Calculate [Deep Noise Suppression performance evaluation based on Mean Opinion Score](https://arxiv.org/abs/2010.15258) (DNSMOS).

Human subjective evaluation is the ”gold standard” to evaluate speech quality optimized for human perception. Perceptual objective metrics serve as a proxy for subjective scores. The conventional and widely used metrics require a reference clean speech signal, which is unavailable in real recordings. The no-reference approaches correlate poorly with human ratings and are not widely adopted in the research community. One of the biggest use cases of these perceptual objective metrics is to evaluate noise suppression algorithms. DNSMOS generalizes well in challenging test conditions with a high correlation to human ratings in stack ranking noise suppression methods. More details can be found in [DNSMOS paper](https://arxiv.org/abs/2010.15258) and [DNSMOS P.835 paper](https://arxiv.org/abs/2110.01763).

As input to `forward` and `update` the metric accepts the following input

*   `preds` ([`Tensor`](https://docs.pytorch.org/docs/stable/tensors.html#torch.Tensor "(in PyTorch v2.15)")): float tensor with shape `(...,time)`
    

As output of `forward` and `compute` the metric returns the following output

*   `dnsmos` ([`Tensor`](https://docs.pytorch.org/docs/stable/tensors.html#torch.Tensor "(in PyTorch v2.15)")): float tensor of DNSMOS values reduced across the batch
    
    with shape `(...,4)` indicating \[p808\_mos, mos\_sig, mos\_bak, mos\_ovr\] in the last dim.
    

Hint

Using this metric requires you to have `librosa`, `onnxruntime` and `requests` installed. Install as `pip install torchmetrics['audio']` or alternatively pip install librosa onnxruntime-gpu requests (if you do not have GPU enabled machine install onnxruntime instead of onnxruntime-gpu)

Caution

The `forward` and `compute` methods in this class return a reduced DNSMOS value for a batch. To obtain the DNSMOS value for each sample, you may use the functional counterpart in [`deep_noise_suppression_mean_opinion_score()`](#torchmetrics.functional.audio.dnsmos.deep_noise_suppression_mean_opinion_score "torchmetrics.functional.audio.dnsmos.deep_noise_suppression_mean_opinion_score").

Parameters:

*   **fs** ([`int`](https://docs.python.org/3/builtins/functions.html#int "(in Python v3.15)")) – sampling frequency
    
*   **personalized** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool "(in Python v3.15)")) – whether interfering speaker is penalized
    
*   **device** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional "(in Python v3.15)")\[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)")\]) – the device used for calculating DNSMOS, can be cpu or cuda:n, where n is the index of gpu. If None is given, then the device of input is used.
    
*   **num\_threads** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional "(in Python v3.15)")\[[`int`](https://docs.python.org/3/builtins/functions.html#int "(in Python v3.15)")\]) – number of threads to use for onnxruntime CPU inference.
    
*   **cache\_session** – whether to cache the onnx session. By default this is true, meaning that repeated calls to this method is faster than if this was set to False, the consequence is that the session will be cached in memory until the process is terminated.
    

Raises:

[**ModuleNotFoundError**](https://docs.python.org/3/builtins/exceptions.html#ModuleNotFoundError "(in Python v3.15)") – If `librosa`, `onnxruntime` or `requests` packages are not installed

Example

```python
>>> from torch import randn
>>> from torchmetrics.audio import DeepNoiseSuppressionMeanOpinionScore
>>> preds = randn(8000)
>>> dnsmos = DeepNoiseSuppressionMeanOpinionScore(8000, False)
>>> dnsmos(preds)
tensor([2.2..., 2.0..., 1.1..., 1.2...], dtype=torch.float64)
```

#### `plot(val=None, ax=None)` {#torchmetrics.audio.dnsmos.DeepNoiseSuppressionMeanOpinionScore.plot}

[\[source\]](https://github.com/Lightning-AI/torchmetrics/blob/v1.9.0/src/torchmetrics/audio/dnsmos.py#L148-L186)

Plot a single or multiple values from the metric.

Parameters:

*   **val** (`Union`\[[`Tensor`](https://docs.pytorch.org/docs/stable/tensors.html#torch.Tensor "(in PyTorch v2.15)"), [`Sequence`](https://docs.python.org/3/library/collections.abc.html#collections.abc.Sequence "(in Python v3.15)")\[[`Tensor`](https://docs.pytorch.org/docs/stable/tensors.html#torch.Tensor "(in PyTorch v2.15)")\], [`None`](https://docs.python.org/3/builtins/constants.html#None "(in Python v3.15)")\]) – Either a single result from calling `metric.forward` or `metric.compute` or a list of these results. If no value is provided, will automatically call `metric.compute` and plot that result.
    
*   **ax** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional "(in Python v3.15)")\[[`Axes`](https://matplotlib.org/stable/api/_as_gen/matplotlib.axes.Axes.html#matplotlib.axes.Axes "(in Matplotlib v3.11.2)")\]) – A matplotlib axis object. If provided will add plot to that axis
    

Return type:

[`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple "(in Python v3.15)")\[[`Figure`](https://matplotlib.org/stable/api/_as_gen/matplotlib.figure.Figure.html#matplotlib.figure.Figure "(in Matplotlib v3.11.2)"), `Union`\[[`Axes`](https://matplotlib.org/stable/api/_as_gen/matplotlib.axes.Axes.html#matplotlib.axes.Axes "(in Matplotlib v3.11.2)"), [`ndarray`](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray "(in NumPy v2.5)")\]\]

Returns:

Figure and Axes object

Raises:

[**ModuleNotFoundError**](https://docs.python.org/3/builtins/exceptions.html#ModuleNotFoundError "(in Python v3.15)") – If `matplotlib` is not installed

```python
>>> # Example plotting a single value
>>> import torch
>>> from torchmetrics.audio import DeepNoiseSuppressionMeanOpinionScore
>>> metric = DeepNoiseSuppressionMeanOpinionScore(8000, False)
>>> metric.update(torch.rand(8000))
>>> fig_, ax_ = metric.plot()
```

```python
>>> # Example plotting multiple values
>>> import torch
>>> from torchmetrics.audio import DeepNoiseSuppressionMeanOpinionScore
>>> metric = DeepNoiseSuppressionMeanOpinionScore(8000, False)
>>> values = [ ]
>>> for _ in range(10):
...     values.append(metric(torch.rand(8000)))
>>> fig_, ax_ = metric.plot(values)
```

## Functional Interface {#functional-interface}

### `torchmetrics.functional.audio.dnsmos.deep_noise_suppression_mean_opinion_score(preds, fs, personalized, device=None, num_threads=None, cache_session=True)` {#torchmetrics.functional.audio.dnsmos.deep_noise_suppression_mean_opinion_score}

[\[source\]](https://github.com/Lightning-AI/torchmetrics/blob/v1.9.0/src/torchmetrics/functional/audio/dnsmos.py#L184-L291)

Calculate [Deep Noise Suppression performance evaluation based on Mean Opinion Score](https://arxiv.org/abs/2010.15258) (DNSMOS).

Human subjective evaluation is the ”gold standard” to evaluate speech quality optimized for human perception. Perceptual objective metrics serve as a proxy for subjective scores. The conventional and widely used metrics require a reference clean speech signal, which is unavailable in real recordings. The no-reference approaches correlate poorly with human ratings and are not widely adopted in the research community. One of the biggest use cases of these perceptual objective metrics is to evaluate noise suppression algorithms. DNSMOS generalizes well in challenging test conditions with a high correlation to human ratings in stack ranking noise suppression methods. More details can be found in [DNSMOS paper](https://arxiv.org/abs/2010.15258) and [DNSMOS P.835 paper](https://arxiv.org/abs/2110.01763).

Hint

Using this metric requires you to have `librosa`, `onnxruntime` and `requests` installed. Install as `pip install torchmetrics['audio']` or alternatively `pip install librosa onnxruntime-gpu requests` (if you do not have GPU enabled machine install `onnxruntime` instead of `onnxruntime-gpu`)

Parameters:

*   **preds** ([`Tensor`](https://docs.pytorch.org/docs/stable/tensors.html#torch.Tensor "(in PyTorch v2.15)")) – \[…, time\]
    
*   **fs** ([`int`](https://docs.python.org/3/builtins/functions.html#int "(in Python v3.15)")) – sampling frequency
    
*   **personalized** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool "(in Python v3.15)")) – whether interfering speaker is penalized
    
*   **device** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional "(in Python v3.15)")\[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)")\]) – the device used for calculating DNSMOS, can be cpu or cuda:n, where n is the index of gpu. If None is given, then the device of input is used.
    
*   **num\_threads** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional "(in Python v3.15)")\[[`int`](https://docs.python.org/3/builtins/functions.html#int "(in Python v3.15)")\]) – the number of threads to use for cpu inference. Defaults to None.
    
*   **cache\_session** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool "(in Python v3.15)")) – whether to cache the onnx session. By default this is true, meaning that repeated calls to this method is faster than if this was set to False, the consequence is that the session will be cached in memory until the process is terminated.
    

Return type:

[`Tensor`](https://docs.pytorch.org/docs/stable/tensors.html#torch.Tensor "(in PyTorch v2.15)")

Returns:

Float tensor with shape `(...,4)` of DNSMOS values per sample, i.e. \[p808\_mos, mos\_sig, mos\_bak, mos\_ovr\]

Raises:

[**ModuleNotFoundError**](https://docs.python.org/3/builtins/exceptions.html#ModuleNotFoundError "(in Python v3.15)") – If `librosa`, `onnxruntime` or `requests` packages are not installed

Example

```python
>>> from torch import randn
>>> from torchmetrics.functional.audio.dnsmos import deep_noise_suppression_mean_opinion_score
>>> preds = randn(8000)
>>> deep_noise_suppression_mean_opinion_score(preds, 8000, False)
tensor([2.2..., 2.0..., 1.1..., 1.2...], dtype=torch.float64)
```

---

**Navigation**

- Parent: [Audio](/docs/torchmetrics/1.9.0/audio.md)
