---
title: Non-Intrusive Speech Quality Assessment (NISQA v2.0)
description: 'Non-Intrusive Speech Quality Assessment (NISQA v2.0) [1], [2].'
canonical: >-
  https://lightning.ai/docs/torchmetrics/stable/audio/non_intrusive_speech_quality_assessment
---
# Non-Intrusive Speech Quality Assessment (NISQA v2.0) {#non-intrusive-speech-quality-assessment-nisqa-v2-0}

## Module Interface {#module-interface}

### `class torchmetrics.audio.nisqa.NonIntrusiveSpeechQualityAssessment(fs, **kwargs)` {#torchmetrics.audio.nisqa.NonIntrusiveSpeechQualityAssessment}

[\[source\]](https://github.com/Lightning-AI/torchmetrics/blob/v1.9.0/src/torchmetrics/audio/nisqa.py#L35-L155)

[Non-Intrusive Speech Quality Assessment](https://arxiv.org/abs/2104.09494) (NISQA v2.0) \[1\], \[2\].

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

*   `nisqa` ([`Tensor`](https://docs.pytorch.org/docs/stable/tensors.html#torch.Tensor "(in PyTorch v2.15)")): float tensor reduced across the batch with shape `(5,)` corresponding to overall MOS, noisiness, discontinuity, coloration and loudness in that order
    

Hint

Using this metric requires you to have `librosa` and `requests` installed. Install as `pip install librosa requests`.

Caution

The `forward` and `compute` methods in this class return values reduced across the batch. To obtain values for each sample, you may use the functional counterpart [`non_intrusive_speech_quality_assessment()`](#torchmetrics.functional.audio.nisqa.non_intrusive_speech_quality_assessment "torchmetrics.functional.audio.nisqa.non_intrusive_speech_quality_assessment").

Parameters:

**fs** ([`int`](https://docs.python.org/3/builtins/functions.html#int "(in Python v3.15)")) – sampling frequency of input

Raises:

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

Example

```python
>>> import torch
>>> from torchmetrics.audio import NonIntrusiveSpeechQualityAssessment
>>> _ = torch.manual_seed(42)
>>> preds = torch.randn(16000)
>>> nisqa = NonIntrusiveSpeechQualityAssessment(16000)
>>> nisqa(preds)
tensor([1.0433, 1.9545, 2.6087, 1.3460, 1.7117])
```

References

*   \[1\] G. Mittag and S. Möller, “Non-intrusive speech quality assessment for super-wideband speech communication networks”, in Proc. ICASSP, 2019.
    
*   \[2\] G. Mittag, B. Naderi, A. Chehadi and S. Möller, “NISQA: A deep CNN-self-attention model for multidimensional speech quality prediction with crowdsourced datasets”, in Proc. INTERSPEECH, 2021.
    

#### `plot(val=None, ax=None)` {#torchmetrics.audio.nisqa.NonIntrusiveSpeechQualityAssessment.plot}

[\[source\]](https://github.com/Lightning-AI/torchmetrics/blob/v1.9.0/src/torchmetrics/audio/nisqa.py#L117-L155)

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 NonIntrusiveSpeechQualityAssessment
>>> metric = NonIntrusiveSpeechQualityAssessment(16000)
>>> metric.update(torch.randn(16000))
>>> fig_, ax_ = metric.plot()
```

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

## Functional Interface {#functional-interface}

### `torchmetrics.functional.audio.nisqa.non_intrusive_speech_quality_assessment(preds, fs)` {#torchmetrics.functional.audio.nisqa.non_intrusive_speech_quality_assessment}

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

[Non-Intrusive Speech Quality Assessment](https://arxiv.org/abs/2104.09494) (NISQA v2.0) \[1\], \[2\].

Hint

Usingsing this metric requires you to have `librosa` and `requests` installed. Install as `pip install librosa requests`.

Parameters:

*   **preds** ([`Tensor`](https://docs.pytorch.org/docs/stable/tensors.html#torch.Tensor "(in PyTorch v2.15)")) – float tensor with shape `(...,time)`
    
*   **fs** ([`int`](https://docs.python.org/3/builtins/functions.html#int "(in Python v3.15)")) – sampling frequency of input
    

Return type:

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

Returns:

Float tensor with shape `(...,5)` corresponding to overall MOS, noisiness, discontinuity, coloration and loudness in that order

Raises:

*   [**ModuleNotFoundError**](https://docs.python.org/3/builtins/exceptions.html#ModuleNotFoundError "(in Python v3.15)") – If `librosa` or `requests` are not installed
    
*   [**RuntimeError**](https://docs.python.org/3/builtins/exceptions.html#RuntimeError "(in Python v3.15)") – If the input is too short, causing the number of mel spectrogram windows to be zero
    
*   [**RuntimeError**](https://docs.python.org/3/builtins/exceptions.html#RuntimeError "(in Python v3.15)") – If the input is too long, causing the number of mel spectrogram windows to exceed the maximum allowed
    

Example

```python
>>> import torch
>>> from torchmetrics.functional.audio.nisqa import non_intrusive_speech_quality_assessment
>>> _ = torch.manual_seed(42)
>>> preds = torch.randn(16000)
>>> non_intrusive_speech_quality_assessment(preds, 16000)
tensor([1.0433, 1.9545, 2.6087, 1.3460, 1.7117])
```

References

*   \[1\] G. Mittag and S. Möller, “Non-intrusive speech quality assessment for super-wideband speech communication networks”, in Proc. ICASSP, 2019.
    
*   \[2\] G. Mittag, B. Naderi, A. Chehadi and S. Möller, “NISQA: A deep CNN-self-attention model for multidimensional speech quality prediction with crowdsourced datasets”, in Proc. INTERSPEECH, 2021.

---

**Navigation**

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