DSPRelated.com
Forums

Signal to noise ratio calculation

Started by abhi5491 August 7, 2016
I have implemented RLS algorithm on TMSC6713 DSK.I am confused with
calculation of signal to noise ratio.

I have achieved snr by two different means and the results are
different.Can any one help me finding the right one.

All the samples are aligned and equalized

Method 1:

I gave speech+noise to the adaptive filter.The speech signal was having a
long pause in between.So I recorded the output with the fraction of speech
part and the pause part.Fractions of both were more than 1 second.As in
the pause part there was no speech signal present the output is nothing
but the residual noise while the speech part is the output speech+residual
noise.I calculated snr with the formula in matlab as shown below.

snr=mse((output_speech)-mse(residual_noise))/mse(residual_noise);
snr_db=10*log10(snr)


Method 2:

In this method I took the entire output sample of 2 seconds of each input
speech,input noise and the output signal;

residual_noise=mse(output_speech)-mse(input_speech);
snr_out_db=10*log10(mse(input_speech)/residual_noise);


I got different results for both.
For first i got 40dB improvement while for method 2 i got 10 dB
improvement.
So which one is correct.

Secondly how much snr can be achieved using basic RLS algorithm.?
---------------------------------------
Posted through http://www.DSPRelated.com
On Monday, August 8, 2016 at 8:35:28 AM UTC+12, abhi5491 wrote:
> I have implemented RLS algorithm on TMSC6713 DSK.I am confused with > calculation of signal to noise ratio. > > I have achieved snr by two different means and the results are > different.Can any one help me finding the right one. > > All the samples are aligned and equalized > > Method 1: > > I gave speech+noise to the adaptive filter.The speech signal was having a > long pause in between.So I recorded the output with the fraction of speech > part and the pause part.Fractions of both were more than 1 second.As in > the pause part there was no speech signal present the output is nothing > but the residual noise while the speech part is the output speech+residual > noise.I calculated snr with the formula in matlab as shown below. > > snr=mse((output_speech)-mse(residual_noise))/mse(residual_noise); > snr_db=10*log10(snr) > > > Method 2: > > In this method I took the entire output sample of 2 seconds of each input > speech,input noise and the output signal; > > residual_noise=mse(output_speech)-mse(input_speech); > snr_out_db=10*log10(mse(input_speech)/residual_noise); > > > I got different results for both. > For first i got 40dB improvement while for method 2 i got 10 dB > improvement. > So which one is correct. > > Secondly how much snr can be achieved using basic RLS algorithm.? > --------------------------------------- > Posted through http://www.DSPRelated.com
Speech is non stationary so you are liable to get different answers depending on where you are in a sentence. You can try segmental SNR across time maybe.
On Sunday, August 7, 2016 at 4:35:28 PM UTC-4, abhi5491 wrote:
> I have implemented RLS algorithm on TMSC6713 DSK.I am confused with > calculation of signal to noise ratio. > > I have achieved snr by two different means and the results are > different.Can any one help me finding the right one. > > All the samples are aligned and equalized > > Method 1: > > I gave speech+noise to the adaptive filter.The speech signal was having a > long pause in between.So I recorded the output with the fraction of speech > part and the pause part.Fractions of both were more than 1 second.As in > the pause part there was no speech signal present the output is nothing > but the residual noise while the speech part is the output speech+residual > noise.I calculated snr with the formula in matlab as shown below. > > snr=mse((output_speech)-mse(residual_noise))/mse(residual_noise); > snr_db=10*log10(snr) > > > Method 2: > > In this method I took the entire output sample of 2 seconds of each input > speech,input noise and the output signal; > > residual_noise=mse(output_speech)-mse(input_speech); > snr_out_db=10*log10(mse(input_speech)/residual_noise); > > > I got different results for both. > For first i got 40dB improvement while for method 2 i got 10 dB > improvement. > So which one is correct. > > Secondly how much snr can be achieved using basic RLS algorithm.? > --------------------------------------- > Posted through http://www.DSPRelated.com
Your first method seems to be on the right track depending on what exactly your mse() function does. Your method 1 computes: snr=mse((output_speech)-mse(residual_noise))/mse(residual_noise); If the noise process is stationary and uncorrelated with the signal then I would compute snr at the output as: snr = (Pout_s+n - Pout_n) / Pout_n where Pout_s+n = sample variance of output signal when speech and noise are present at the input (after RLS convergence) Pout_n = sample variance of output signal when noise only is present at the input (after RLS convergence)
On Tuesday, August 9, 2016 at 9:57:32 PM UTC+12, lit...@gmail.com wrote:
> On Sunday, August 7, 2016 at 4:35:28 PM UTC-4, abhi5491 wrote: > > I have implemented RLS algorithm on TMSC6713 DSK.I am confused with > > calculation of signal to noise ratio. > > > > I have achieved snr by two different means and the results are > > different.Can any one help me finding the right one. > > > > All the samples are aligned and equalized > > > > Method 1: > > > > I gave speech+noise to the adaptive filter.The speech signal was having a > > long pause in between.So I recorded the output with the fraction of speech > > part and the pause part.Fractions of both were more than 1 second.As in > > the pause part there was no speech signal present the output is nothing > > but the residual noise while the speech part is the output speech+residual > > noise.I calculated snr with the formula in matlab as shown below. > > > > snr=mse((output_speech)-mse(residual_noise))/mse(residual_noise); > > snr_db=10*log10(snr) > > > > > > Method 2: > > > > In this method I took the entire output sample of 2 seconds of each input > > speech,input noise and the output signal; > > > > residual_noise=mse(output_speech)-mse(input_speech); > > snr_out_db=10*log10(mse(input_speech)/residual_noise); > > > > > > I got different results for both. > > For first i got 40dB improvement while for method 2 i got 10 dB > > improvement. > > So which one is correct. > > > > Secondly how much snr can be achieved using basic RLS algorithm.? > > --------------------------------------- > > Posted through http://www.DSPRelated.com > > Your first method seems to be on the right track depending on what exactly your mse() function does. > > Your method 1 computes: > > snr=mse((output_speech)-mse(residual_noise))/mse(residual_noise); > > If the noise process is stationary and uncorrelated with the signal then I would compute snr at the output as: > > snr = (Pout_s+n - Pout_n) / Pout_n > > where > Pout_s+n = sample variance of output signal when speech and noise are present at the input (after RLS convergence) > Pout_n = sample variance of output signal when noise only is present at the input (after RLS convergence)
The speech is non-stationary however so SNR has to be too. You can pick a particular utterance of course.
>On Tuesday, August 9, 2016 at 9:57:32 PM UTC+12, lit...@gmail.com wrote: >> On Sunday, August 7, 2016 at 4:35:28 PM UTC-4, abhi5491 wrote: >> > I have implemented RLS algorithm on TMSC6713 DSK.I am confused with >> > calculation of signal to noise ratio. >> > >> > I have achieved snr by two different means and the results are >> > different.Can any one help me finding the right one. >> > >> > All the samples are aligned and equalized >> > >> > Method 1: >> > >> > I gave speech+noise to the adaptive filter.The speech signal was
having
>a >> > long pause in between.So I recorded the output with the fraction of >speech >> > part and the pause part.Fractions of both were more than 1 second.As
in
>> > the pause part there was no speech signal present the output is
nothing
>> > but the residual noise while the speech part is the output >speech+residual >> > noise.I calculated snr with the formula in matlab as shown below. >> > >> > snr=mse((output_speech)-mse(residual_noise))/mse(residual_noise); >> > snr_db*log10(snr) >> > >> > >> > Method 2: >> > >> > In this method I took the entire output sample of 2 seconds of each >input >> > speech,input noise and the output signal; >> > >> > residual_noise=mse(output_speech)-mse(input_speech); >> > snr_out_db*log10(mse(input_speech)/residual_noise); >> > >> > >> > I got different results for both. >> > For first i got 40dB improvement while for method 2 i got 10 dB >> > improvement. >> > So which one is correct. >> > >> > Secondly how much snr can be achieved using basic RLS algorithm.? >> > --------------------------------------- >> > Posted through http://www.DSPRelated.com >> >> Your first method seems to be on the right track depending on what
exactly
>your mse() function does. >> >> Your method 1 computes: >> >> snr=mse((output_speech)-mse(residual_noise))/mse(residual_noise); >> >> If the noise process is stationary and uncorrelated with the signal
then I
>would compute snr at the output as: >> >> snr = (Pout_s+n - Pout_n) / Pout_n >> >> where >> Pout_s+n = sample variance of output signal when speech and noise are >present at the input (after RLS convergence) >> Pout_n = sample variance of output signal when noise only is present
at
>the input (after RLS convergence) > >The speech is non-stationary however so SNR has to be too. You can pick
a
>particular utterance of course.
----------------------------------------------------------------------- I have implemented noise canceler using adaptive filter so the primary signal has both(speech+noise) and the reference signal has only noise so the noise is correlated with the primary signal.secondly the noise is continuously varying. why do we use variance.It can be only applicable if the mean is zero.Am I right?If yes then the mean of my signals are not zero. residual_noise=(output_speech.^2)-(input_speech.^2); residual_noise=sqrt(residual_noise) snr_out_db=10*log10(sqrt(input_speech.^2)/residual_noise); Is this correct way to calculate? Why does the other method fails to give snr value.Its not even close?Where am I making the mistake or why I cannot use this method? --------------------------------------- Posted through http://www.DSPRelated.com
On Tuesday, August 16, 2016 at 11:40:08 PM UTC-4, abhi5491 wrote:
> ----------------------------------------------------------------------- > I have implemented noise canceler using adaptive filter so the primary > signal has both(speech+noise) and the reference signal has only noise so > the noise is correlated with the primary signal.secondly the noise is > continuously varying. > > why do we use variance.It can be only applicable if the mean is zero.Am I > right?If yes then the mean of my signals are not zero. > > residual_noise=(output_speech.^2)-(input_speech.^2); > residual_noise=sqrt(residual_noise) > snr_out_db=10*log10(sqrt(input_speech.^2)/residual_noise); > > Is this correct way to calculate? > Why does the other method fails to give snr value.Its not even close?Where > am I making the mistake or why I cannot use this method? > --------------------------------------- > Posted through http://www.DSPRelated.com
By definition output snr = P(s(n)) / P(vo(n)) where s(n) is the noiseless speech signal and vo(n) is the residual noise out of the canceller. Your method calculate output snr as P(input_speech)/P(output_speech - input_speech). To facilitate this discussion a generic model of an adaptive canceller is pictured in the link below. http://i.imgur.com/liwjKWp.png With regard to this model your input speech is actually noisy speech as it contains both the desired speech and noise. Your output_speech is the cancelled output which consists of the desired speech and residual noise. In the figure the quantity y(n) out of the adaptive filter is an estimate of the noise signal v1(n), let's call it v1_hat(n). The residual noise vo(n) is then the error between the actual and estimated input noise component of the noisy speech, vo(n) = v1(n) - v1_hat(n). If the noise only input v2(n) is perfectly isolated from the noisy speech input then the cancelled output e(n) contains the noiseless speech signal s(n) plus residual noise vo(n). Using this model, if you write the expressions for the canceller's input and output signals it is simple to see why your method does not compute the output snr.