/*****************************************************************************
Perceptual Evaluation of Speech Quality (PESQ)
ITU-T Recommendation P.862.
Version 1.2 - 2 August 2002.
****************************************
PESQ Intellectual Property Rights Notice
****************************************
DEFINITIONS:
------------
For the purposes of this Intellectual Property Rights Notice
the terms Perceptual Evaluation of Speech Quality Algorithm
and PESQ Algorithm refer to the objective speech quality
measurement algorithm defined in ITU-T Recommendation P.862;
the term PESQ Software refers to the C-code component of P.862.
NOTICE:
-------
All copyright, trade marks, trade names, patents, know-how and
all or any other intellectual rights subsisting in or used in
connection with including all algorithms, documents and manuals
relating to the PESQ Algorithm and or PESQ Software are and remain
the sole property in law, ownership, regulations, treaties and
patent rights of the Owners identified below. The user may not
dispute or question the ownership of the PESQ Algorithm and
or PESQ Software.
OWNERS ARE:
-----------
1. British Telecommunications plc (BT), all rights assigned
to Psytechnics Limited
2. Royal KPN NV, all rights assigned to OPTICOM GmbH
RESTRICTIONS:
-------------
The user cannot:
1. alter, duplicate, modify, adapt, or translate in whole or in
part any aspect of the PESQ Algorithm and or PESQ Software
2. sell, hire, loan, distribute, dispose or put to any commercial
use other than those permitted below in whole or in part any
aspect of the PESQ Algorithm and or PESQ Software
PERMITTED USE:
--------------
The user may:
1. Use the PESQ Software to:
i) understand the PESQ Algorithm; or
ii) evaluate the ability of the PESQ Algorithm to perform
its intended function of predicting the speech quality
of a system; or
iii) evaluate the computational complexity of the PESQ Algorithm,
with the limitation that none of said evaluations or its
results shall be used for external commercial use.
2. Use the PESQ Software to test if an implementation of the PESQ
Algorithm conforms to ITU-T Recommendation P.862.
3. With the prior written permission of both Psytechnics Limited
and OPTICOM GmbH, use the PESQ Software in accordance with the
above Restrictions to perform work that meets all of the following
criteria:
i) the work must contribute directly to the maintenance of an
existing ITU recommendation or the development of a new ITU
recommendation under an approved ITU Study Item; and
ii) the work and its results must be fully described in a
written contribution to the ITU that is presented at a formal
ITU meeting within one year of the start of the work; and
iii) neither the work nor its results shall be put to any
commercial use other than making said contribution to the ITU.
Said permission will be provided on a case-by-case basis.
ANY OTHER USE OR APPLICATION OF THE PESQ SOFTWARE AND/OR THE PESQ
ALGORITHM WILL REQUIRE A PESQ LICENCE AGREEMENT, WHICH MAY BE OBTAINED
FROM EITHER OPTICOM GMBH OR PSYTECHNICS LIMITED.
EACH COMPANY OFFERS OEM LICENSE AGREEMENTS, WHICH COMBINE OEM
IMPLEMENTATIONS OF THE PESQ ALGORITHM TOGETHER WITH A PESQ PATENT LICENSE
AGREEMENT. PESQ PATENT-ONLY LICENSE AGREEMENTS MAY BE OBTAINED FROM OPTICOM.
***********************************************************************
* OPTICOM GmbH * Psytechnics Limited *
* Am Weichselgarten 7, * Fraser House, 23 Museum Street, *
* D- 91058 Erlangen, Germany * Ipswich IP1 1HN, England *
* Phone: +49 (0) 9131 691 160 * Phone: +44 (0) 1473 261 800 *
* Fax: +49 (0) 9131 691 325 * Fax: +44 (0) 1473 261 880 *
* E-mail: info@opticom.de, * E-mail: info@psytechnics.com, *
* www.opticom.de * www.psytechnics.com *
***********************************************************************
Further information is also available from www.pesq.org
*****************************************************************************/
#include <math.h>
#include <stdio.h>
#include "pesq.h"
#include "pesqpar.h"
#include "dsp.h"
#define CRITERIUM_FOR_SILENCE_OF_5_SAMPLES 500.
float Sl, Sp;
int *nr_of_hz_bands_per_bark_band;
double *centre_of_band_bark;
double *centre_of_band_hz;
double *width_of_band_bark;
double *width_of_band_hz;
double *pow_dens_correction_factor;
double *abs_thresh_power;
void input_filter(
SIGNAL_INFO * ref_info, SIGNAL_INFO * deg_info, float * ftmp )
{
DC_block( (*ref_info).data, (*ref_info).Nsamples );
DC_block( (*deg_info).data, (*deg_info).Nsamples );
apply_filters( (*ref_info).data, (*ref_info).Nsamples );
apply_filters( (*deg_info).data, (*deg_info).Nsamples );
}
void calc_VAD( SIGNAL_INFO * sinfo )
{
apply_VAD( sinfo, sinfo-> data, sinfo-> VAD, sinfo-> logVAD );
}
int id_searchwindows( SIGNAL_INFO * ref_info, SIGNAL_INFO * deg_info,
ERROR_INFO * err_info )
{
long Utt_num = 0;
long count, VAD_length;
long this_start;
int speech_flag = 0;
float VAD_value;
long del_deg_start;
long del_deg_end;
VAD_length = ref_info-> Nsamples / Downsample;
del_deg_start = MINUTTLENGTH - err_info-> Crude_DelayEst / Downsample;
del_deg_end =
((*deg_info).Nsamples - err_info-> Crude_DelayEst) / Downsample -
MINUTTLENGTH;
for (count = 0; count < VAD_length; count++)
{
VAD_value = ref_info-> VAD [count];
if( (VAD_value > 0.0f) && (speech_flag == 0) )
{
speech_flag = 1;
this_start = count;
err_info-> UttSearch_Start [Utt_num] = count - SEARCHBUFFER;
if( err_info-> UttSearch_Start [Utt_num] < 0 )
err_info-> UttSearch_Start [Utt_num] = 0;
}
if( ((VAD_value == 0.0f) || (count == (VAD_length-1))) &&
(speech_flag == 1) )
{
speech_flag = 0;
err_info-> UttSearch_End [Utt_num] = count + SEARCHBUFFER;
if( err_info-> UttSearch_End [Utt_num] > VAD_length - 1 )
err_info-> UttSearch_End [Utt_num] = VAD_length -1;
if( ((count - this_start) >= MINUTTLENGTH) &&
(this_start < del_deg_end) &&
(count > del_deg_start) )
Utt_num++;
}
}
err_info-> Nutterances = Utt_num;
return Utt_num;
}
void id_utterances( SIGNAL_INFO * ref_info, SIGNAL_INFO * deg_info,
ERROR_INFO * err_info )
{
long Utt_num = 0;
long Largest_uttsize = 0;
long count, VAD_length;
int speech_flag = 0;
float VAD_value;
long this_start;
long last_end;
long del_deg_start;
long del_deg_end;
VAD_length = ref_info-> Nsamples / Downsample;
del_deg_start = MINUTTLENGTH - err_info-> Crude_DelayEst / Downsample;
del_deg_end =
((*deg_info).Nsamples - err_info-> Crude_DelayEst) / Downsample -
MINUTTLENGTH;
for (count = 0; count < VAD_length ; count++)
{
VAD_value = ref_info-> VAD [count];
if( (VAD_value > 0.0f) && (speech_flag == 0) )
{
speech_flag = 1;
this_start = count;
err_info-> Utt_Start [Utt_num] = count;
}
if( ((VAD_value == 0.0f) || (count == (VAD_length-1))) &&
(speech_flag == 1) )
{
speech_flag = 0;
err_info-> Utt_End [Utt_num] = count;
if( ((
- 1
- 2
- 3
前往页