Wednesday, October 6, 2010

NIST SNR tool

After I lost a lot of time, trying to compile the NIST signal to noise ratio (SNR) tool,
I've decided to write about the solution and probably that will save some time to those, who have the problem with compiling it. Not that a lot of people use it, but anyway...

The NIST Speech Quality Assurance (SPQA) package is special for calculating the SNR for speech and the biggest advantage of this piece of sw is that it is something like standard and it can also calculate the SNR of an audio file without a reference audio file (noise or noise free).
It can be downloaded from here:

NIST spqa

It's compiled on a 64bit machine running SuSe. But after the compilation I copied the executables on another 32bit machine, running Ubuntu and they were usable. Here the solution that worked for me:

Unpack spqa_2.3+sphere_2.5.tar.Z with the command:
> zcat spqa_2.3+sphere_2.5.tar.Z | tar xvf -

That will create a nist directory. Go to the dir
> cd nist

Before you start, you have to know your system architecture. To find that out, type in the bash.
> uname -a
Example architecture is i686, i585, SUN, Darwin etc..

Before you run the install, open the exit.c file (located in dir nist/src/lib/sp) in a text editor. Make the following changes:
1. Replace the line:
extern int errno;
with the following line:
#include <errno.h>
2. Comment out the line:
extern char *sys_errlist[];
and also the line:
strcat(exitmessage, sys_errlist[errno]);
3. Save the file

Now, start with the install. Run:
> sh src/scripts/install.sh
If you use gcc as a compiler, choose the "Custom" option when asked. Then write gcc, when you're asked about the compiler. Then you can accept the proposed options by pressing enter. They should be fine, except for the last one, when you should enter your system architecture (i686, i585, SUN, Darwin etc).

The installation begins then. When finished, checked if errors occurred. If you find executables in the nist/bin directory (for example the stnr, segsnr, atismd, etc.), then the compilation was successful, otherwise, go to nist/lib directory and rename the libutil.a library with the following command:
> mv libutil.a libsputil.a

Then change directory to nist/src/bin and open the Makefile. In the Makefile, find the following line:
LLIBS = -lsnr -lsp -lutil -lm
and change it to
LLIBS = -lsnr -lsp -lsputil -lm
so that it reflect the change you've just made.

Now, from the nist/ directory run:
> make clean
and then repeat the make with the command:
> make

If after that you still get errors, see where the error comes from and change some code if necessary. The problematic library is usually the sphere (nist/src/lib/sp), because it is pretty old (1992) and some functions are deprecated (that's why the high amount of warnings you'll get while compiling). Good luck.

Btw, I also tried another tool, which is much easier to compile and seems to be reliable. Here it is: CTU snr tool . I suspect, that it will spit the same result as the NIST tool, when the appropriate options chosen, but didn't tried to compare them. More about the algorithms behind the CTU snr tool here: Calculating the SNR for speech - paper.

4 comments:

  1. I try this solution and it did not work for me as well as the CTU snr tool you commented. I suggest to use the following software that includes NIST stnr in a precompiled form (stnr.GLNX86) among other SNR estimators:

    http://labrosa.ee.columbia.edu/projects/snreval/#9

    ReplyDelete
  2. Hi there! Yes, it's been awhile, the things might have been changed..

    Thank you for the link, it looks very good. I installed the Mac OS version on my laptop and there is lots of stuff packed there . The best of all - Java libs!

    I am not at the cognitive systems lab anymore, but I will recommend it to the guys there, because they use such tools on a daily basis.

    ReplyDelete
  3. Thanks a lot for the solution.
    Spend hours on it with a lot of frustration until I read your solution.

    ReplyDelete
  4. One more change from 2015: src/scripts/gen_make.sh has two instances f "+1" please change those lines from

    "sort -t_ -n +1" to

    "sort -t_ -n --key=2"

    ReplyDelete