Compute Audio SNR (Signal-to-Noise Ratio) in Python – Python Tutorial

By | April 12, 2023

SNR is often used to process audio signal, in this tutorial, we will introduce you how to compute it using python.

What is SNR

SNR is called signal-to noise ratio, it is defined as:

what is snr

As to Px, it can be computed as:

How to compute snr in python

We can find the value of a clean singal SNR depends on the power of the noise signal. If the noise is changed, the SNR also be changed.

Often SNR is given in decibels (dB), it is:

dB in SNR

How to compute snr dB in python

It means:

If SNRdB = 0dB,  SNR = 1, Ps=Pn, the power of the clean signal is equal to the noise signal.

If SNRdB > 0dB, the power of the clean signal is larger than the noise signal.

Moreover, Pn is also an estimator of the variance of the noise σ2. Therefore, one could have also defined the signal-to-noise ratio as follows:

SNR definition

How to compute SNR in python?

In order to compute SNR, we should get a clean signal and a noise signal.

You can view here:

https://github.com/hrtlacek/SNR/blob/main/SNR.ipynb

Leave a Reply