How to start a voice quality PESQ test? - c++

I'm trying to do a voice quality test (pesq), but I don't understand how to start. I trying to compile a public source code (http://www.itu.int/itu-t/recommendations/index.aspx?ser=P (p.862)) but can't start a test. Maybe anyone work with this?

You will need a C compiler (The ITU PESQ reference implementation is actually C, so you don't need a C++ compiler, although both should work just fine)
For instance, on linux, you would enter the source directory and compile with gcc:
$ cd Software/P862_annex_A_2005_CD/source
$ gcc -o PESQ *.c
This will compile the files dsp.c, pesqdsp.c, pesqio.c, pesqmain.c, pesqmod.c into a binary file PESQ which you can then run with ./PESQ:
$ ./PESQ
Perceptual Evaluation of Speech Quality (PESQ)
Reference implementation for ITU-T Recommendations P.862, P.862.1 and P.862.2.
Version 2.0 October 2005.
<snip long unenlightening IP notice>
Usage:
PESQ HELP Displays this text
PESQ [options] ref deg
Run model on reference ref and degraded deg
Options: +8000 +16000 +swap +wb
Sample rate - No default. Must select either +8000 or +16000.
Swap byte order - machine native format by default. Select +swap for byteswap.
Default mode of operation is P.862 (narrowband handset listening). Select +wb
to use P.862.2 wideband extension (headphone listening).
File names may not begin with a + character.
Files with names ending .wav or .WAV are assumed to have a 44-byte header, which is automatically skipped. All other file types are assumed to have no header.
To run this binary and test your algorithm, you need the "reference" .wav file (This is the clean, original speech) and the "degraded" .wav file (This is the output of your algorithm). Simply pass both into PESQ, and it will give you the output of the test. An example run on two .wav files included in the source distribution from the ITU:
$ cd Software/P862_annex_A_2005_CD/conform
$ ../source/PESQ +8000 or105.wav dg105.wav
Perceptual Evaluation of Speech Quality (PESQ)
Reference implementation for ITU-T Recommendations P.862, P.862.1 and P.862.2.
Version 2.0 October 2005.
<snip IP notice>
Reading reference file or105.wav...done.
Reading degraded file dg105.wav...done.
Level normalization...
IRS filtering...
Variable delay compensation...
Acoustic model processing...
P.862 Prediction (Raw MOS, MOS-LQO): = 2.237 1.844
Where the +8000 parameter denotes that the wav files are sampled at 8000Hz.

In last versions of GCC, you may have to use this comamnd to compile:
gcc -o PESQ *.c -lm
BR

In addition to the answer from staticfloat, and building on the answer from AntoineF, some gcc version might throw the following warnings:
pesqmain.c: In function 'main':
pesqmain.c:322:17: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long int' [-Wformat=]
printf ("An error of type %d ", Error_Flag);
^
pesqmain.c: In function 'pesq_measure':
pesqmain.c:629:35: warning: format '%d' expects argument of type 'int', but argument 3 has type 'long int' [-Wformat=]
fprintf (resultsFile, "%d\t", Fs);
^
pesqmain.c:636:34: warning: too many arguments for format [-Wformat-extra-args]
fprintf (resultsFile, "\n", Fs);
To solve the issue, you can ignore these warnings explicitly by running:
gcc -Wno-format -Wno-format-extra-args -o pesq *.c -lm # works on Ubuntu 16.04, gcc 5.4.0
Hope that can help some people not familiar with compiling C code like me!

Try AQuA software, it's not an ITU-T standard, but solves VoIP speech quality testing very well:
http://www.sevana.fi/voice_quality_testing_measurement_analysis.php

Please, don't use PESQ / ITU-T P.862 anymore. It's superseded by P.863 (aka POLQA) for many good reasons.
For decades, people were using PESQ for applications it was not developed for (e.g., noise reduction, acoustic paths, etc.) - just because it was "available". For PESQ-WB, no one noticed for ~12 years that there was a bug in the implementation (wrong filter coefficients for input bandpass).
Note that even though the source code is available on ITU-T website for download, you need a commercial license to use it! The reference code at ITU-T is only there to re-generate reference results on your specific platform.
Finally: do not rely only on one single MOS metric for voice quality testing. Professionals should use a measurement system like the already mentioned ACQUA software or similar.

Unrar the setup file
Drop both(original and deformed file) file in the conform folder and
execute the file
you will get the results in a notepad

Related

Conversion from ttf to type 2 CID font (type 42 base font)

I have ttf font files for Indian languages such as Tamil, Telugu, Malayalam, etc.
In order to access ttf files through a postscript program, I have to convert them to Type 2 CIDfont (Type 42 base font).
I tried online conversion (as well as utilities from GitHub) but unfortunately they all failed to convert.
Is there any conversion utility available?
As I could not proceed further with my work due to font conversion issue, so I decided to take up conversion task by myself.
Since I was neither a font programmar nor a font designer, I had to learn the internals of ttf (Apple Computers) and
Type 0 composite fonts (Adobe Corporation), just enough to write a conversion program, with the help of the following documents.
Microsoft OpenType® Specification Version 1.9
Fonts - TrueType Reference Manual - Apple Developer
PostScript Language Reference, third edition - Adobe Corporation (912 pages PDF, 7410K) Feb/1999
The Type 42 Font Format Specification #5012 (28 pages PDF, 159k) 31/Jul/1998
Adobe CMap and CID Font Files Specification #5014 (102 pages PDF, 541k) 11/Jun/1996 Version 1.0
In order to benefit others, I have just released this conversion utility through GitHub on the following platforms.
Windows 10 Platform (Github Public Repository for Conversion Utility on Windows 10)
Open up DOS command line and issue the following clone command to download source code:
git clone https://github.com/marmayogi/TTF2PostscriptCID-Win
Or execute the following curl command to download source code release in zip form:
curl -o TTF2PostscriptCID-Win-3.0.zip -L https://github.com/marmayogi/TTF2PostscriptCID-Win/archive/refs/tags/v3.0.zip
Or execute the following wget command to download source code release in zip form:
wget -O TTF2PostscriptCID-Win-3.0.zip https://github.com/marmayogi/TTF2PostscriptCID-Win/archive/refs/tags/v3.0.zip
Linux Platform (Github Public Repository for Conversion Utility on Linux)
Issue the following clone command to download source code:
git clone https://github.com/marmayogi/TTF2PostscriptCID-Linux
Or execute the following curl command to download source code release in tar form:
curl -o TTF2PostscriptCID-Linux-3.0.tar.gz -L https://github.com/marmayogi/TTF2PostscriptCID-Linux/archive/refs/tags/v3.0.tar.gz
Or execute the following wget command to download source code release in tar form:
wget -O TTF2PostscriptCID-Linux-3.0.tar.gz https://github.com/marmayogi/TTF2PostscriptCID-Linux/archive/refs/tags/v3.0.tar.gz
Note:
This utility converts ttf file to t42 file which is readily accessible through a postscript program. This conversion program also generates a ps file (a postscript program) which will display all the glyphs associated with the character set of ttf file.
The two program files (main.cpp and ttf.h) are 100% portable. i.e. the contents of two files are same and identical across platforms.
A README Document in Markdown format has been included with the release.
This conversion software has been tested for the following Indian Languages successfully whose number of Glyphs exceed 256 characters with horizontal writing.
Tamil
Malayalam
Telugu
Kannada
Gujarati
Gurmukhi (Punjabi)
Oriya
Bengali (Assamese)
Devanagari (Sanskrit, Hindi and Marathi)

Installing Fortran library Expokit (Windows/Ubuntu)

I am looking to perform matrix exponentials, which apparently the Expokit library is suitable for. Sadly unlike Lapack or OpenMP this is not easily installed from Cygwin or Mingw for Windows. Therefore I have downloaded the library from here, however once unpacked it consists purely of .f files with little guidance on how to use them. The only site I've found online isn't much use (Fortran Wiki), as it doesn't give any indication of how the Expokit library is linked.
I would greatly appreciate any guidance on how to install Expokit on Windows, or alternatively on Ubuntu if Windows is not suitable.
Making the change suggested by ripero and running 'make sample_d' on Ubuntu I get the log shown below. I assume this means the sample has been compiled successfully, but I have no idea how this enables me to use Expokit as a library in my Fortran programs. Could someone please provide guidance on this?
XX:~/programs/expokit/expokit/fortran$ make sample_d
f77 -O3 -c blas.f
blas.f:404:72:
10 assign 30 to next
1
Warning: Deleted feature: ASSIGN statement at (1)
blas.f:409:19:
20 go to next,(30, 50, 70, 110)
1
Warning: Deleted feature: Assigned GOTO statement at (1)
blas.f:411:72:
assign 50 to next
1
Warning: Deleted feature: ASSIGN statement at (1)
blas.f:420:72:
assign 70 to next
1
Warning: Deleted feature: ASSIGN statement at (1)
blas.f:427:72:
assign 110 to next
1
Warning: Deleted feature: ASSIGN statement at (1)
blas.f:1621:72:
10 assign 30 to next
1
Warning: Deleted feature: ASSIGN statement at (1)
blas.f:1628:19:
go to next,(30, 50, 70, 90, 110)
1
Warning: Deleted feature: Assigned GOTO statement at (1)
blas.f:1630:72:
assign 50 to next
1
Warning: Deleted feature: ASSIGN statement at (1)
blas.f:1639:72:
assign 70 to next
1
Warning: Deleted feature: ASSIGN statement at (1)
blas.f:1644:72:
100 assign 110 to next
1
Warning: Deleted feature: ASSIGN statement at (1)
blas.f:1671:72:
85 assign 90 to next
1
Warning: Deleted feature: ASSIGN statement at (1)
blas.f:1689:16:
go to next,( 50, 70, 90, 110 )
1
Warning: Deleted feature: Assigned GOTO statement at (1)
f77 -O3 -c lapack.f
f77 -o sample_d sample_d.o clock.o expokit.o mataid.o blas.o lapack.o
Your Fortran compiler fails to compile file sample_d.f due to a non-standard format statement. The source code of the same file provides instructions for how to fix it if this happens:
9001 format( <mprint>(1X,D11.4) )
*--- Some compliers (e.g., g77) generate 'Unsupported FORMAT specifier'
* with the specification above. In this case, simply use this form:
* 9001 format( 5(1X,D11.4) )
If you comment the first line above (add a * as the first character of the line) and uncomment the last line (remove the leading *), the error should disappear.
I don't think there is a particular significance to running make sample_d other than ensuring that the object files are created and that a sample program can be compiled and linked against them in order to create a working binary.
First, you should be aware that you have compiled Expokit and one of the sample programs using what their Makefile calls case 3, where the required BLAS and LAPACK subroutines are provided by files blas.o and lapack.o, respectively, compiled from their .f counterparts provided by Expokit.
# Among the 3 possibilities below, uncomment the appropriate
# case for your environment and comment the others.
# case 1: works when LAPACK and BLAS are installed.
OBJLIBS =
LIBS = -llapack -lblas
# case 2: works when LAPACK is not installed but BLAS is.
#LIBS = -lblas
#OBJLIBS = lapack.o
# case 3: works when neither LAPACK nor BLAS are installed.
#OBJLIBS = blas.o lapack.o
#LIBS =
If your system already has BLAS and LAPACK libraries, they very likely are more optimized than the ones in blas.o and lapack.o, and you probably will want to change the case in the Makefile (add/remove leading # to comment/uncomment the appropriate definitions of OBJLIBS and LIBS) so that you can use the system BLAS and LAPACK.
In order to use Expokit in your Fortran programs, you need to call from your source code the relevant subroutines (see the Expokit paper and the source code of expokit.f and mataid.f in order to read about the provided subroutines) and then the simplest is to add to your linking line the following
object files: expokit.o mataid.o followed by all the object files listed in the active OBJLIBS variable in the Expokit Makefile, if any; and
libraries: all the ones listed in the active LIBS variable in the Expokit Makefile, if any.

g++ not compiling with wildcard filenames on Windows

All of a sudden I seem to be struggling with compiling c++ programs (specifically TDM64 5.1.0) from the command-line on Windows (specifically 10) when using wildcard based filenames. It works fine when the names are given in full. I've done this countless times before with no problem Edit: But not normally on windows... my memories of this working before must be false. What am I missing?
C:\Users\Duncan Coulter\Code>dir *.cpp
Volume in drive C has no label.
Volume Serial Number is 9EE6-DBBD
Directory of C:\Users\Duncan Coulter\Code
2016/04/04 01:35 PM 7 869 LittleMan.cpp
2016/04/04 01:35 PM 1 912 main.cpp
2 File(s) 9 781 bytes
0 Dir(s) 90 288 394 240 bytes free
C:\Users\Duncan Coulter\Code>g++ *.cpp
g++: error: *.cpp: Invalid argument
C:\Users\Duncan Coulter\Code>g++ main.cpp LittleMan.cpp
Your problem is where you write:
g++ *.cpp
g++ is a linux style program, and expects the shell to expand wildcards for it. The windows command shell doesn't do that - it expects individual programs to expand wildcards for themselves.
The easiest solution is to download cygwin - which does expand wildcards for you. Otherwise the answers to this question may be useful:
https://superuser.com/questions/460598/is-there-any-way-to-get-the-windows-cmd-shell-to-expand-wildcard-paths
I note that TDM is based on the MINGW port of GCC. I've found that different versions of this compiler do in fact treat the wildcard differently. For example, it works perfectly fine for me as of version 3.4.2, compiling in Windows 7:
However, when I upgraded to GCC v.4.9.2, this batch file and others I was using broke (specifically, the *.cpp was not recognized). This was a version of MINGW GCC which came with the Dev-C++ IDE. Because I needed this feature rather badly (specifically, test-compiling large submissions of student code with unspecified random filenames), I actually had to downgrade and revert back to the old version for just this purpose.

Compiling DISLIN gfortran

I am having trouble compiling Fortran code with references to DISLIN. I have downloaded DISLIN from the website, unzipped the file and ran the setup. I have added an environment variable called DISLIN (C:\dislin) and added C:\dislin\win to the PATH section of my system variables.
I am trying to compile some example code of the DISLIN website which includes line
USE DISLIN
I am using a MinGW shell to compile with command gfortran -o progrname -ldislin EX11_1.f90 and am getting the following error:
Fatal Error: Cant open module file 'dislin.mod' for reading at (1): No such file or directory.
I have tried changing the variable path and even moving the dislin.mod file (which is there) but still get the same message.
Ok I fixed this problem so thought I come back and post what worked for me incase any one else needs it...
Install both DISLIN and MinGW on the c drive
Copy disgf.a from /c/dislin and dislin.f90 from /c/dislin/gf into the directory containing your fortran files
(for me this is /c/MinGW/pnote)
Using the MinGW shell navigate to you files: cd /c/MinGW/pnote
compile dislin.f90 and your fortran program: gfortran -c dislin.f90 progName.f90 (dislin.f90 obviously only needs to be done once)
link libraries etc and compile: gfortran progName.o disgf.a -luser32 -lgdi32 -lopengl32 -o exeName
'run' exeName
You probably need to specify the path to the DISLIN module files:
gfortran EX11_1.f90 -o progrname -ldislin -I/path/to/DISLIN/modules
and, if not already configured like described here, also the path to the library itself:
gfortran EX11_1.f90 -o progrname -ldislin -I/path/to/DISLIN/modules \
-L/path/to/DISLIN/library
They provide a batch file (windows) to do the compiling and linking for you.
f90link -c My_Program
This is located in c:\dislin\Win
Also, if you are having trouble with the dislin.mod file which resides in c:\dislin\gf then recompile that with the -c compile option. I found all of this info in c:\dislin\readme.inf
near as I can tell (Jan 2018) dislin (64 bit) fails miserably with gfortran 7.2, period; and probably with many other newer compilers.
When trying to link, gfortran 7 says 'dislin.mod' is an unrecognizable format.
I think this program is highly dependent on exactly correct version synchronization - something that renders such software useless imho after many years in research.
and no, the correctness of various 'paths' seems not to help.
after all, gnuplot works, "at all". Not sure why I spent so much time on brand x.
jrc

DOS-reported error: Bad file number

I have a batch file that tries to compile a static library using Borland C++ Builder 6.0
It is called from Borland make (makefile created with bpr2mak) which is called from a .bat file (used to compile the whole project with Visual Studio and some Borland C++ Builder legacy projects), which is called from a bash shell script running inside Cygwin.
When I run the .bat file directly from a Cygwin shell, it runs OK, but when its being run from a Program calling cygwin with Boost::Process::launcher I'm getting this error:
C:\ARQUIV~1\Borland\CBUILD~1\Bin\..\BIN\TLib /u bclibs.lib #MAKE0000.###
DOS-reported error: Bad file number
TLIB 4.5 Copyright (c) 1987, 1999 Inprise Corporation
opening 'MAKE0000.###'
** error 1 ** deleting bclibs.lib
It's a complicated scenario, but this Program which calls cygwin is run whenever we need to build our software package which needs to be build for various Linux distos and Windows 32 and 64-bit.
Note: It's the only Borland Project failing, the other compile just fine (it's the only static library using borland also, so it can be some problem with the TLib tool.
The problem was that TLib does not like to have his output redirected (seen here) without having an input pipe as well. Solved by creating an input pipe to in the Boost::Process::launcher using set_stdin_behavior
I'm just guessing here, but this may have to do with long filenames and/or spaces in paths.
1) Modify your makefile so it would save current environment to a file, immediately before executing the failing command (set > d:\env.txt & echo CD=%CD% >> d:\env.txt). Then run it both ways (directly and via program) and compare the environments of good run and bad run.
2) Using filemon from Sysinternals, capture logs of disk access in both cases (these logs are going to be huge, though you can uncheck everything except Open in the filter to reduce the size). Again, compare and check for clues...
3) Try instaling everything involved to paths conforming to 8.3 scheme.
This error is not related to C++ itself. It happens when your build script opens too much files (more than defined in DOS command processor environment). To resolve this issue try to set value of files variable to 253. For Windows XP this variable defined in the file %WINDIR%\system32\config.nt.
files=253
Seems it is known bug in Borland C++ tools. Here is description and possible workaround for this issue:
Problem: Some static Lib projects will
not link correctly when compiled. You might see something
like this :
J:\Borland\CBUILD~1\bin\..\BIN\TLib /u debug\jpegD.lib #MAKE0000.###
DOS-reported error: Bad file number
TLIB 4.5 Copyright (c) 1987, 1999 Inprise Corporation
opening 'MAKE0000.###'
** error 1 ** deleting debug\jpegD.lib
MAKE failed, returned : 1
Workaround : In some cases (where the "Bad file number" error is seen) it may be possible to work around this by specifying -tDEFLIB.BMK in the BPR2MAKE Options field, and Turning off the "Capture Make Output" option.
I have not tested it, but I hope that helps.