---
title: Speech-to-Reverberation Modulation Energy Ratio (SRMR)
description: Calculate Speech-to-Reverberation Modulation Energy Ratio (SRMR).
canonical: >-
  https://lightning.ai/docs/torchmetrics/stable/audio/speech_reverberation_modulation_energy_ratio
---
# Speech-to-Reverberation Modulation Energy Ratio (SRMR) {#speech-to-reverberation-modulation-energy-ratio-srmr}

## Module Interface {#module-interface}

### `class torchmetrics.audio.srmr.SpeechReverberationModulationEnergyRatio(fs, n_cochlear_filters=23, low_freq=125, min_cf=4, max_cf=None, norm=False, fast=False, **kwargs)` {#torchmetrics.audio.srmr.SpeechReverberationModulationEnergyRatio}

[\[source\]](https://github.com/Lightning-AI/torchmetrics/blob/v1.9.0/src/torchmetrics/audio/srmr.py#L37-L187)

Calculate [Speech-to-Reverberation Modulation Energy Ratio](https://ieeexplore.ieee.org/abstract/document/5547575) (SRMR).

SRMR is a non-intrusive metric for speech quality and intelligibility based on a modulation spectral representation of the speech signal. This code is translated from SRMRToolbox and [SRMRpy](https://github.com/jfsantos/SRMRpy).

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

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

Hint

Using this metrics requires you to have `gammatone` and `torchaudio` installed. Either install as `pip install torchmetrics[audio]` or `pip install torchaudio` and `pip install git+https://github.com/detly/gammatone`.

Attention

This implementation is experimental, and might not be consistent with the matlab implementation SRMRToolbox, especially the fast implementation. The slow versions, a) `fast=False, norm=False, max_cf=128`, b) `fast=False, norm=True, max_cf=30`, have a relatively small inconsistency.

Parameters:

*   **fs** ([`int`](https://docs.python.org/3/builtins/functions.html#int "(in Python v3.15)")) – the sampling rate
    
*   **n\_cochlear\_filters** ([`int`](https://docs.python.org/3/builtins/functions.html#int "(in Python v3.15)")) – Number of filters in the acoustic filterbank
    
*   **low\_freq** ([`float`](https://docs.python.org/3/builtins/functions.html#float "(in Python v3.15)")) – determines the frequency cutoff for the corresponding gammatone filterbank.
    
*   **min\_cf** ([`float`](https://docs.python.org/3/builtins/functions.html#float "(in Python v3.15)")) – Center frequency in Hz of the first modulation filter.
    
*   **max\_cf** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional "(in Python v3.15)")\[[`float`](https://docs.python.org/3/builtins/functions.html#float "(in Python v3.15)")\]) – Center frequency in Hz of the last modulation filter. If None is given, then 30 Hz will be used for norm==False, otherwise 128 Hz will be used.
    
*   **norm** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool "(in Python v3.15)")) – Use modulation spectrum energy normalization
    
*   **fast** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool "(in Python v3.15)")) – Use the faster version based on the gammatonegram. Note: this argument is inherited from [SRMRpy](https://github.com/jfsantos/SRMRpy). As the translated code is based to pytorch, setting fast=True may slow down the speed for calculating this metric on GPU.
    

Raises:

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

Example

```python
>>> from torch import randn
>>> from torchmetrics.audio import SpeechReverberationModulationEnergyRatio
>>> preds = randn(8000)
>>> srmr = SpeechReverberationModulationEnergyRatio(8000)
>>> srmr(preds)
tensor(0.3191)
```

#### `plot(val=None, ax=None)` {#torchmetrics.audio.srmr.SpeechReverberationModulationEnergyRatio.plot}

[\[source\]](https://github.com/Lightning-AI/torchmetrics/blob/v1.9.0/src/torchmetrics/audio/srmr.py#L149-L187)

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)")\]) – An 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 SpeechReverberationModulationEnergyRatio
>>> metric = SpeechReverberationModulationEnergyRatio(8000)
>>> metric.update(torch.rand(8000))
>>> fig_, ax_ = metric.plot()
```

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

## Functional Interface {#functional-interface}

### `torchmetrics.functional.audio.srmr.speech_reverberation_modulation_energy_ratio(preds, fs, n_cochlear_filters=23, low_freq=125, min_cf=4, max_cf=None, norm=False, fast=False)` {#torchmetrics.functional.audio.srmr.speech_reverberation_modulation_energy_ratio}

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

Calculate [Speech-to-Reverberation Modulation Energy Ratio](https://ieeexplore.ieee.org/abstract/document/5547575) (SRMR).

SRMR is a non-intrusive metric for speech quality and intelligibility based on a modulation spectral representation of the speech signal. This code is translated from SRMRToolbox and [SRMRpy](https://github.com/jfsantos/SRMRpy).

Parameters:

*   **preds** ([`Tensor`](https://docs.pytorch.org/docs/stable/tensors.html#torch.Tensor "(in PyTorch v2.15)")) – shape `(..., time)`
    
*   **fs** ([`int`](https://docs.python.org/3/builtins/functions.html#int "(in Python v3.15)")) – the sampling rate
    
*   **n\_cochlear\_filters** ([`int`](https://docs.python.org/3/builtins/functions.html#int "(in Python v3.15)")) – Number of filters in the acoustic filterbank
    
*   **low\_freq** ([`float`](https://docs.python.org/3/builtins/functions.html#float "(in Python v3.15)")) – determines the frequency cutoff for the corresponding gammatone filterbank.
    
*   **min\_cf** ([`float`](https://docs.python.org/3/builtins/functions.html#float "(in Python v3.15)")) – Center frequency in Hz of the first modulation filter.
    
*   **max\_cf** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional "(in Python v3.15)")\[[`float`](https://docs.python.org/3/builtins/functions.html#float "(in Python v3.15)")\]) – Center frequency in Hz of the last modulation filter. If None is given, then 30 Hz will be used for norm==False, otherwise 128 Hz will be used.
    
*   **norm** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool "(in Python v3.15)")) – Use modulation spectrum energy normalization
    
*   **fast** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool "(in Python v3.15)")) – Use the faster version based on the gammatonegram. Note: this argument is inherited from [SRMRpy](https://github.com/jfsantos/SRMRpy). As the translated code is based to pytorch, setting fast=True may slow down the speed for calculating this metric on GPU.
    

Hint

Usingsing this metrics requires you to have `gammatone` and `torchaudio` installed. Either install as `pip install torchmetrics[audio]` or `pip install torchaudio` and `pip install git+https://github.com/detly/gammatone`.

Attention

This implementation is experimental, and might not be consistent with the matlab implementation SRMRToolbox, especially the fast implementation. The slow versions, a) `fast=False, norm=False, max_cf=128`, b) `fast=False, norm=True, max_cf=30`, have a relatively small inconsistency.

Return type:

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

Returns:

Scalar tensor with srmr value with shape `(...)`

Raises:

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

Example

```python
>>> from torch import randn
>>> from torchmetrics.functional.audio import speech_reverberation_modulation_energy_ratio
>>> preds = randn(8000)
>>> speech_reverberation_modulation_energy_ratio(preds, 8000)
tensor([0.3191], dtype=torch.float64)
```

---

**Navigation**

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