neverlib 0.2.5__py3-none-any.whl → 0.2.7__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- neverlib/.claude/settings.local.json +9 -0
- neverlib/Docs/audio_aug/test_volume.ipynb +416 -0
- neverlib/Docs/audio_aug_test/test_volume.ipynb +289 -0
- neverlib/Docs/filter/biquad.ipynb +129 -0
- neverlib/Docs/filter/filter_family.ipynb +450 -0
- neverlib/Docs/filter/highpass.ipynb +139 -0
- neverlib/Docs/filter/scipy_filter_family.ipynb +110 -0
- neverlib/Docs/vad/VAD_Energy.ipynb +167 -0
- neverlib/Docs/vad/VAD_Silero.ipynb +325 -0
- neverlib/Docs/vad/VAD_WebRTC.ipynb +189 -0
- neverlib/Docs/vad/VAD_funasr.ipynb +192 -0
- neverlib/Docs/vad/VAD_rvADfast.ipynb +162 -0
- neverlib/Docs/vad/VAD_statistics.ipynb +532 -0
- neverlib/Docs/vad/VAD_tenVAD.ipynb +292 -0
- neverlib/Docs/vad/VAD_vadlib.ipynb +168 -0
- neverlib/Docs/vad/VAD_whisper.ipynb +404 -0
- neverlib/QA/gen_init.py +117 -0
- neverlib/QA/get_fun.py +19 -0
- neverlib/__init__.py +21 -4
- neverlib/audio_aug/HarmonicDistortion.py +19 -13
- neverlib/audio_aug/__init__.py +30 -12
- neverlib/audio_aug/audio_aug.py +19 -14
- neverlib/audio_aug/clip_aug.py +15 -18
- neverlib/audio_aug/coder_aug.py +44 -24
- neverlib/audio_aug/coder_aug2.py +54 -37
- neverlib/audio_aug/loss_packet_aug.py +7 -7
- neverlib/audio_aug/quant_aug.py +19 -17
- neverlib/data/000_short_enhance.wav +0 -0
- neverlib/data/3956_speech.wav +0 -0
- neverlib/data/3956_sweep.wav +0 -0
- neverlib/data/vad_example.wav +0 -0
- neverlib/data/white.wav +0 -0
- neverlib/data/white_EQ.wav +0 -0
- neverlib/data/white_matched.wav +0 -0
- neverlib/data_analyze/__init__.py +25 -20
- neverlib/data_analyze/dataset_analyzer.py +109 -114
- neverlib/data_analyze/quality_metrics.py +87 -89
- neverlib/data_analyze/rms_distrubution.py +23 -42
- neverlib/data_analyze/spectral_analysis.py +43 -46
- neverlib/data_analyze/statistics.py +76 -76
- neverlib/data_analyze/temporal_features.py +15 -6
- neverlib/data_analyze/visualization.py +208 -144
- neverlib/filter/__init__.py +17 -20
- neverlib/filter/auto_eq/__init__.py +18 -35
- neverlib/filter/auto_eq/de_eq.py +0 -2
- neverlib/filter/common.py +24 -5
- neverlib/metrics/DNSMOS/bak_ovr.onnx +0 -0
- neverlib/metrics/DNSMOS/model_v8.onnx +0 -0
- neverlib/metrics/DNSMOS/sig.onnx +0 -0
- neverlib/metrics/DNSMOS/sig_bak_ovr.onnx +0 -0
- neverlib/metrics/__init__.py +23 -0
- neverlib/metrics/dnsmos.py +4 -15
- neverlib/metrics/pDNSMOS/sig_bak_ovr.onnx +0 -0
- neverlib/metrics/pesq_c/PESQ +0 -0
- neverlib/metrics/pesq_c/dsp.c +553 -0
- neverlib/metrics/pesq_c/dsp.h +138 -0
- neverlib/metrics/pesq_c/pesq.h +294 -0
- neverlib/metrics/pesq_c/pesqdsp.c +1047 -0
- neverlib/metrics/pesq_c/pesqio.c +392 -0
- neverlib/metrics/pesq_c/pesqmain.c +610 -0
- neverlib/metrics/pesq_c/pesqmod.c +1417 -0
- neverlib/metrics/pesq_c/pesqpar.h +297 -0
- neverlib/metrics/snr.py +5 -1
- neverlib/metrics/spec.py +31 -21
- neverlib/metrics/test_pesq.py +0 -4
- neverlib/tests/test_imports.py +17 -0
- neverlib/utils/__init__.py +26 -15
- neverlib/utils/audio_split.py +5 -1
- neverlib/utils/checkGPU.py +17 -9
- neverlib/utils/lazy_expose.py +29 -0
- neverlib/utils/utils.py +40 -12
- neverlib/vad/__init__.py +33 -25
- neverlib/vad/class_get_speech.py +1 -1
- neverlib/vad/class_vad.py +3 -3
- neverlib/vad/img.png +0 -0
- {neverlib-0.2.5.dist-info → neverlib-0.2.7.dist-info}/METADATA +20 -17
- {neverlib-0.2.5.dist-info → neverlib-0.2.7.dist-info}/RECORD +80 -37
- {neverlib-0.2.5.dist-info → neverlib-0.2.7.dist-info}/WHEEL +0 -0
- {neverlib-0.2.5.dist-info → neverlib-0.2.7.dist-info}/licenses/LICENSE +0 -0
- {neverlib-0.2.5.dist-info → neverlib-0.2.7.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,610 @@
|
|
|
1
|
+
/*****************************************************************************
|
|
2
|
+
|
|
3
|
+
Perceptual Evaluation of Speech Quality (PESQ)
|
|
4
|
+
ITU-T Recommendation P.862.
|
|
5
|
+
Version 1.2 - 2 August 2002.
|
|
6
|
+
|
|
7
|
+
****************************************
|
|
8
|
+
PESQ Intellectual Property Rights Notice
|
|
9
|
+
****************************************
|
|
10
|
+
|
|
11
|
+
DEFINITIONS:
|
|
12
|
+
------------
|
|
13
|
+
For the purposes of this Intellectual Property Rights Notice
|
|
14
|
+
the terms 'Perceptual Evaluation of Speech Quality Algorithm'
|
|
15
|
+
and 'PESQ Algorithm' refer to the objective speech quality
|
|
16
|
+
measurement algorithm defined in ITU-T Recommendation P.862;
|
|
17
|
+
the term 'PESQ Software' refers to the C-code component of P.862.
|
|
18
|
+
|
|
19
|
+
NOTICE:
|
|
20
|
+
-------
|
|
21
|
+
All copyright, trade marks, trade names, patents, know-how and
|
|
22
|
+
all or any other intellectual rights subsisting in or used in
|
|
23
|
+
connection with including all algorithms, documents and manuals
|
|
24
|
+
relating to the PESQ Algorithm and or PESQ Software are and remain
|
|
25
|
+
the sole property in law, ownership, regulations, treaties and
|
|
26
|
+
patent rights of the Owners identified below. The user may not
|
|
27
|
+
dispute or question the ownership of the PESQ Algorithm and
|
|
28
|
+
or PESQ Software.
|
|
29
|
+
|
|
30
|
+
OWNERS ARE:
|
|
31
|
+
-----------
|
|
32
|
+
|
|
33
|
+
1. British Telecommunications plc (BT), all rights assigned
|
|
34
|
+
to Psytechnics Limited
|
|
35
|
+
2. Royal KPN NV, all rights assigned to OPTICOM GmbH
|
|
36
|
+
|
|
37
|
+
RESTRICTIONS:
|
|
38
|
+
-------------
|
|
39
|
+
|
|
40
|
+
The user cannot:
|
|
41
|
+
|
|
42
|
+
1. alter, duplicate, modify, adapt, or translate in whole or in
|
|
43
|
+
part any aspect of the PESQ Algorithm and or PESQ Software
|
|
44
|
+
2. sell, hire, loan, distribute, dispose or put to any commercial
|
|
45
|
+
use other than those permitted below in whole or in part any
|
|
46
|
+
aspect of the PESQ Algorithm and or PESQ Software
|
|
47
|
+
|
|
48
|
+
PERMITTED USE:
|
|
49
|
+
--------------
|
|
50
|
+
|
|
51
|
+
The user may:
|
|
52
|
+
|
|
53
|
+
1. Use the PESQ Software to:
|
|
54
|
+
i) understand the PESQ Algorithm; or
|
|
55
|
+
ii) evaluate the ability of the PESQ Algorithm to perform
|
|
56
|
+
its intended function of predicting the speech quality
|
|
57
|
+
of a system; or
|
|
58
|
+
iii) evaluate the computational complexity of the PESQ Algorithm,
|
|
59
|
+
with the limitation that none of said evaluations or its
|
|
60
|
+
results shall be used for external commercial use.
|
|
61
|
+
|
|
62
|
+
2. Use the PESQ Software to test if an implementation of the PESQ
|
|
63
|
+
Algorithm conforms to ITU-T Recommendation P.862.
|
|
64
|
+
|
|
65
|
+
3. With the prior written permission of both Psytechnics Limited
|
|
66
|
+
and OPTICOM GmbH, use the PESQ Software in accordance with the
|
|
67
|
+
above Restrictions to perform work that meets all of the following
|
|
68
|
+
criteria:
|
|
69
|
+
i) the work must contribute directly to the maintenance of an
|
|
70
|
+
existing ITU recommendation or the development of a new ITU
|
|
71
|
+
recommendation under an approved ITU Study Item; and
|
|
72
|
+
ii) the work and its results must be fully described in a
|
|
73
|
+
written contribution to the ITU that is presented at a formal
|
|
74
|
+
ITU meeting within one year of the start of the work; and
|
|
75
|
+
iii) neither the work nor its results shall be put to any
|
|
76
|
+
commercial use other than making said contribution to the ITU.
|
|
77
|
+
Said permission will be provided on a case-by-case basis.
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
ANY OTHER USE OR APPLICATION OF THE PESQ SOFTWARE AND/OR THE PESQ
|
|
81
|
+
ALGORITHM WILL REQUIRE A PESQ LICENCE AGREEMENT, WHICH MAY BE OBTAINED
|
|
82
|
+
FROM EITHER OPTICOM GMBH OR PSYTECHNICS LIMITED.
|
|
83
|
+
|
|
84
|
+
EACH COMPANY OFFERS OEM LICENSE AGREEMENTS, WHICH COMBINE OEM
|
|
85
|
+
IMPLEMENTATIONS OF THE PESQ ALGORITHM TOGETHER WITH A PESQ PATENT LICENSE
|
|
86
|
+
AGREEMENT. PESQ PATENT-ONLY LICENSE AGREEMENTS MAY BE OBTAINED FROM OPTICOM.
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
***********************************************************************
|
|
90
|
+
* OPTICOM GmbH * Psytechnics Limited *
|
|
91
|
+
* Am Weichselgarten 7, * Fraser House, 23 Museum Street, *
|
|
92
|
+
* D- 91058 Erlangen, Germany * Ipswich IP1 1HN, England *
|
|
93
|
+
* Phone: +49 (0) 9131 691 160 * Phone: +44 (0) 1473 261 800 *
|
|
94
|
+
* Fax: +49 (0) 9131 691 325 * Fax: +44 (0) 1473 261 880 *
|
|
95
|
+
* E-mail: info@opticom.de, * E-mail: info@psytechnics.com, *
|
|
96
|
+
* www.opticom.de * www.psytechnics.com *
|
|
97
|
+
***********************************************************************
|
|
98
|
+
|
|
99
|
+
Further information is also available from www.pesq.org
|
|
100
|
+
|
|
101
|
+
*****************************************************************************/
|
|
102
|
+
|
|
103
|
+
#include <stdio.h>
|
|
104
|
+
#include <math.h>
|
|
105
|
+
#include "pesq.h"
|
|
106
|
+
#include "dsp.h"
|
|
107
|
+
|
|
108
|
+
#define ITU_RESULTS_FILE "_pesq_itu_results.txt"
|
|
109
|
+
#define SIMPLE_RESULTS_FILE "_pesq_results.txt"
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
int main (int argc, const char *argv []);
|
|
113
|
+
void usage (void);
|
|
114
|
+
void pesq_measure (SIGNAL_INFO * ref_info, SIGNAL_INFO * deg_info,
|
|
115
|
+
ERROR_INFO * err_info, long * Error_Flag, char ** Error_Type);
|
|
116
|
+
|
|
117
|
+
void usage (void) {
|
|
118
|
+
printf ("Usage:\n");
|
|
119
|
+
printf (" PESQ HELP Displays this text\n");
|
|
120
|
+
printf (" PESQ [options] ref deg [smos] [cond]\n");
|
|
121
|
+
printf (" Run model on reference ref and degraded deg\n");
|
|
122
|
+
printf ("\n");
|
|
123
|
+
printf ("Options: +8000 +16000 +swap\n");
|
|
124
|
+
printf (" Sample rate - No default. Must select either +8000 or +16000.\n");
|
|
125
|
+
printf (" Swap byte order - machine native format by default. Select +swap for byteswap.\n");
|
|
126
|
+
printf ("\n");
|
|
127
|
+
printf (" [smos] is an optional number copied to %s\n", ITU_RESULTS_FILE);
|
|
128
|
+
printf (" [cond] is an optional condition number copied to %s\n", ITU_RESULTS_FILE);
|
|
129
|
+
printf (" smos must always precede cond. However, both may be omitted.");
|
|
130
|
+
printf ("\n");
|
|
131
|
+
printf ("File names, smos, cond may not begin with a + character.\n");
|
|
132
|
+
printf ("\n");
|
|
133
|
+
printf ("Files with names ending .wav or .WAV are assumed to have a 44-byte header, which");
|
|
134
|
+
printf (" is automatically skipped. All other file types are assumed to have no header.\n");
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
int main (int argc, const char *argv []) {
|
|
138
|
+
int arg;
|
|
139
|
+
int names = 0;
|
|
140
|
+
long sample_rate = -1;
|
|
141
|
+
|
|
142
|
+
SIGNAL_INFO ref_info;
|
|
143
|
+
SIGNAL_INFO deg_info;
|
|
144
|
+
ERROR_INFO err_info;
|
|
145
|
+
|
|
146
|
+
long Error_Flag = 0;
|
|
147
|
+
char * Error_Type = "Unknown error type.";
|
|
148
|
+
|
|
149
|
+
if (Error_Flag == 0) {
|
|
150
|
+
printf("Perceptual Evaluation of Speech Quality (PESQ) - ITU-T Recommendation P.862.\n");
|
|
151
|
+
printf("Version 1.2 - 2 August 2002.\n");
|
|
152
|
+
printf("\n");
|
|
153
|
+
printf("PESQ Intellectual Property Rights Notice.\n");
|
|
154
|
+
printf("\n");
|
|
155
|
+
printf("DEFINITIONS:\n");
|
|
156
|
+
printf("For the purposes of this Intellectual Property Rights Notice the terms\n");
|
|
157
|
+
printf("'Perceptual Evaluation of Speech Quality Algorithm' and 'PESQ Algorithm'\n");
|
|
158
|
+
printf("refer to the objective speech quality measurement algorithm defined in ITU-T\n");
|
|
159
|
+
printf("Recommendation P.862; the term 'PESQ Software' refers to the C-code component\n");
|
|
160
|
+
printf("of P.862.\n");
|
|
161
|
+
printf("\n");
|
|
162
|
+
printf("NOTICE:\n");
|
|
163
|
+
printf("All copyright, trade marks, trade names, patents, know-how and all or any other\n");
|
|
164
|
+
printf("intellectual rights subsisting in or used in connection with including all\n");
|
|
165
|
+
printf("algorithms, documents and manuals relating to the PESQ Algorithm and or PESQ\n");
|
|
166
|
+
printf("Software are and remain the sole property in law, ownership, regulations,\n");
|
|
167
|
+
printf("treaties and patent rights of the Owners identified below. The user may not\n");
|
|
168
|
+
printf("dispute or question the ownership of the PESQ Algorithm and or PESQ Software.\n");
|
|
169
|
+
printf("\n");
|
|
170
|
+
printf("OWNERS ARE:\n");
|
|
171
|
+
printf("1. British Telecommunications plc (BT), all rights assigned\n");
|
|
172
|
+
printf(" to Psytechnics Limited\n");
|
|
173
|
+
printf("2. Royal KPN NV, all rights assigned to OPTICOM GmbH\n");
|
|
174
|
+
printf("\n");
|
|
175
|
+
printf("RESTRICTIONS:\n");
|
|
176
|
+
printf("The user cannot:\n");
|
|
177
|
+
printf("1. alter, duplicate, modify, adapt, or translate in whole or in\n");
|
|
178
|
+
printf(" part any aspect of the PESQ Algorithm and or PESQ Software\n");
|
|
179
|
+
printf("2. sell, hire, loan, distribute, dispose or put to any commercial\n");
|
|
180
|
+
printf(" use other than those permitted below in whole or in part any\n");
|
|
181
|
+
printf(" aspect of the PESQ Algorithm and or PESQ Software\n");
|
|
182
|
+
printf("\n");
|
|
183
|
+
printf("PERMITTED USE:\n");
|
|
184
|
+
printf("The user may:\n");
|
|
185
|
+
printf("1. Use the PESQ Software to:\n");
|
|
186
|
+
printf(" i) understand the PESQ Algorithm; or\n");
|
|
187
|
+
printf(" ii) evaluate the ability of the PESQ Algorithm to perform its intended\n");
|
|
188
|
+
printf(" function of predicting the speech quality of a system; or\n");
|
|
189
|
+
printf(" iii) evaluate the computational complexity of the PESQ Algorithm,\n");
|
|
190
|
+
printf(" with the limitation that none of said evaluations or its\n");
|
|
191
|
+
printf(" results shall be used for external commercial use.\n");
|
|
192
|
+
printf("2. Use the PESQ Software to test if an implementation of the PESQ\n");
|
|
193
|
+
printf(" Algorithm conforms to ITU-T Recommendation P.862.\n");
|
|
194
|
+
printf("3. With the prior written permission of both Psytechnics Limited and\n");
|
|
195
|
+
printf(" OPTICOM GmbH, use the PESQ Software in accordance with the above\n");
|
|
196
|
+
printf(" Restrictions to perform work that meets all of the following criteria:\n");
|
|
197
|
+
printf(" i) the work must contribute directly to the maintenance of an\n");
|
|
198
|
+
printf(" existing ITU recommendation or the development of a new ITU\n");
|
|
199
|
+
printf(" recommendation under an approved ITU Study Item; and\n");
|
|
200
|
+
printf(" ii) the work and its results must be fully described in a\n");
|
|
201
|
+
printf(" written contribution to the ITU that is presented at a formal\n");
|
|
202
|
+
printf(" ITU meeting within one year of the start of the work; and\n");
|
|
203
|
+
printf(" iii) neither the work nor its results shall be put to any\n");
|
|
204
|
+
printf(" commercial use other than making said contribution to the ITU.\n");
|
|
205
|
+
printf(" Said permission will be provided on a case-by-case basis.\n");
|
|
206
|
+
printf("\n");
|
|
207
|
+
printf("ANY OTHER USE OR APPLICATION OF THE PESQ SOFTWARE AND/OR THE PESQ ALGORITHM\n");
|
|
208
|
+
printf("WILL REQUIRE A PESQ LICENCE AGREEMENT, WHICH MAY BE OBTAINED FROM EITHER\n");
|
|
209
|
+
printf("OPTICOM GMBH OR PSYTECHNICS LIMITED. \n");
|
|
210
|
+
printf("\n");
|
|
211
|
+
printf("EACH COMPANY OFFERS OEM LICENSE AGREEMENTS, WHICH COMBINE OEM\n");
|
|
212
|
+
printf("IMPLEMENTATIONS OF THE PESQ ALGORITHM TOGETHER WITH A PESQ PATENT LICENSE\n");
|
|
213
|
+
printf("AGREEMENT. PESQ PATENT-ONLY LICENSE AGREEMENTS MAY BE OBTAINED FROM OPTICOM.\n");
|
|
214
|
+
printf("\n");
|
|
215
|
+
printf("***********************************************************************\n");
|
|
216
|
+
printf("* OPTICOM GmbH * Psytechnics Limited *\n");
|
|
217
|
+
printf("* Am Weichselgarten 7, * Fraser House, 23 Museum Street, *\n");
|
|
218
|
+
printf("* D- 91058 Erlangen, Germany * Ipswich IP1 1HN, England *\n");
|
|
219
|
+
printf("* Phone: +49 (0) 9131 691 160 * Phone: +44 (0) 1473 261 800 *\n");
|
|
220
|
+
printf("* Fax: +49 (0) 9131 691 325 * Fax: +44 (0) 1473 261 880 *\n");
|
|
221
|
+
printf("* E-mail: info@opticom.de, * E-mail: info@psytechnics.com, *\n");
|
|
222
|
+
printf("* www.opticom.de * www.psytechnics.com *\n");
|
|
223
|
+
printf("***********************************************************************\n");
|
|
224
|
+
printf("\n");
|
|
225
|
+
|
|
226
|
+
if (argc < 3){
|
|
227
|
+
usage ();
|
|
228
|
+
return 0;
|
|
229
|
+
} else {
|
|
230
|
+
|
|
231
|
+
strcpy (ref_info.path_name, "");
|
|
232
|
+
ref_info.apply_swap = 0;
|
|
233
|
+
strcpy (deg_info.path_name, "");
|
|
234
|
+
deg_info.apply_swap = 0;
|
|
235
|
+
err_info. subj_mos = 0;
|
|
236
|
+
err_info. cond_nr = 0;
|
|
237
|
+
|
|
238
|
+
for (arg = 1; arg < argc; arg++) {
|
|
239
|
+
if (argv [arg] [0] == '+') {
|
|
240
|
+
if (strcmp (argv [arg], "+swap") == 0) {
|
|
241
|
+
ref_info.apply_swap = 1;
|
|
242
|
+
deg_info.apply_swap = 1;
|
|
243
|
+
} else {
|
|
244
|
+
if (strcmp (argv [arg], "+16000") == 0) {
|
|
245
|
+
sample_rate = 16000L;
|
|
246
|
+
} else {
|
|
247
|
+
if (strcmp (argv [arg], "+8000") == 0) {
|
|
248
|
+
sample_rate = 8000L;
|
|
249
|
+
} else {
|
|
250
|
+
usage ();
|
|
251
|
+
fprintf (stderr, "Invalid parameter '%s'.\n", argv [arg]);
|
|
252
|
+
return 1;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
} else {
|
|
257
|
+
switch (names) {
|
|
258
|
+
case 0:
|
|
259
|
+
strcpy (ref_info.path_name, argv [arg]);
|
|
260
|
+
break;
|
|
261
|
+
case 1:
|
|
262
|
+
strcpy (deg_info.path_name, argv [arg]);
|
|
263
|
+
break;
|
|
264
|
+
case 2:
|
|
265
|
+
sscanf (argv [arg], "%f", &(err_info. subj_mos));
|
|
266
|
+
break;
|
|
267
|
+
case 3:
|
|
268
|
+
sscanf (argv [arg], "%d", &(err_info. cond_nr));
|
|
269
|
+
break;
|
|
270
|
+
default:
|
|
271
|
+
usage ();
|
|
272
|
+
fprintf (stderr, "Invalid parameter '%s'.\n", argv [arg]);
|
|
273
|
+
return 1;
|
|
274
|
+
}
|
|
275
|
+
names++;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
if (sample_rate == -1) {
|
|
280
|
+
printf ("PESQ Error. Must specify either +8000 or +16000 sample frequency option!\n");
|
|
281
|
+
exit (1);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
strcpy (ref_info. file_name, ref_info. path_name);
|
|
285
|
+
if (strrchr (ref_info. file_name, '\\') != NULL) {
|
|
286
|
+
strcpy (ref_info. file_name, 1 + strrchr (ref_info. file_name, '\\'));
|
|
287
|
+
}
|
|
288
|
+
if (strrchr (ref_info. file_name, '/') != NULL) {
|
|
289
|
+
strcpy (ref_info. file_name, 1 + strrchr (ref_info. file_name, '/'));
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
strcpy (deg_info. file_name, deg_info. path_name);
|
|
293
|
+
if (strrchr (deg_info. file_name, '\\') != NULL) {
|
|
294
|
+
strcpy (deg_info. file_name, 1 + strrchr (deg_info. file_name, '\\'));
|
|
295
|
+
}
|
|
296
|
+
if (strrchr (deg_info. file_name, '/') != NULL) {
|
|
297
|
+
strcpy (deg_info. file_name, 1 + strrchr (deg_info. file_name, '/'));
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
select_rate (sample_rate, &Error_Flag, &Error_Type);
|
|
301
|
+
pesq_measure (&ref_info, °_info, &err_info, &Error_Flag, &Error_Type);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
if (Error_Flag == 0) {
|
|
306
|
+
printf ("\nPrediction : PESQ_MOS = %.3f\n", (double) err_info.pesq_mos);
|
|
307
|
+
return 0;
|
|
308
|
+
} else {
|
|
309
|
+
printf ("An error of type %d ", Error_Flag);
|
|
310
|
+
if (Error_Type != NULL) {
|
|
311
|
+
printf (" (%s) occurred during processing.\n", Error_Type);
|
|
312
|
+
} else {
|
|
313
|
+
printf ("occurred during processing.\n");
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
return 0;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
double align_filter_dB [26] [2] = {{0.,-500},
|
|
321
|
+
{50., -500},
|
|
322
|
+
{100., -500},
|
|
323
|
+
{125., -500},
|
|
324
|
+
{160., -500},
|
|
325
|
+
{200., -500},
|
|
326
|
+
{250., -500},
|
|
327
|
+
{300., -500},
|
|
328
|
+
{350., 0},
|
|
329
|
+
{400., 0},
|
|
330
|
+
{500., 0},
|
|
331
|
+
{600., 0},
|
|
332
|
+
{630., 0},
|
|
333
|
+
{800., 0},
|
|
334
|
+
{1000., 0},
|
|
335
|
+
{1250., 0},
|
|
336
|
+
{1600., 0},
|
|
337
|
+
{2000., 0},
|
|
338
|
+
{2500., 0},
|
|
339
|
+
{3000., 0},
|
|
340
|
+
{3250., 0},
|
|
341
|
+
{3500., -500},
|
|
342
|
+
{4000., -500},
|
|
343
|
+
{5000., -500},
|
|
344
|
+
{6300., -500},
|
|
345
|
+
{8000., -500}};
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
double standard_IRS_filter_dB [26] [2] = {{ 0., -200},
|
|
349
|
+
{ 50., -40},
|
|
350
|
+
{100., -20},
|
|
351
|
+
{125., -12},
|
|
352
|
+
{160., -6},
|
|
353
|
+
{200., 0},
|
|
354
|
+
{250., 4},
|
|
355
|
+
{300., 6},
|
|
356
|
+
{350., 8},
|
|
357
|
+
{400., 10},
|
|
358
|
+
{500., 11},
|
|
359
|
+
{600., 12},
|
|
360
|
+
{700., 12},
|
|
361
|
+
{800., 12},
|
|
362
|
+
{1000., 12},
|
|
363
|
+
{1300., 12},
|
|
364
|
+
{1600., 12},
|
|
365
|
+
{2000., 12},
|
|
366
|
+
{2500., 12},
|
|
367
|
+
{3000., 12},
|
|
368
|
+
{3250., 12},
|
|
369
|
+
{3500., 4},
|
|
370
|
+
{4000., -200},
|
|
371
|
+
{5000., -200},
|
|
372
|
+
{6300., -200},
|
|
373
|
+
{8000., -200}};
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
#define TARGET_AVG_POWER 1E7
|
|
377
|
+
|
|
378
|
+
void fix_power_level (SIGNAL_INFO *info, char *name, long maxNsamples)
|
|
379
|
+
{
|
|
380
|
+
long n = info-> Nsamples;
|
|
381
|
+
long i;
|
|
382
|
+
float *align_filtered = (float *) safe_malloc ((n + DATAPADDING_MSECS * (Fs / 1000)) * sizeof (float));
|
|
383
|
+
float global_scale;
|
|
384
|
+
float power_above_300Hz;
|
|
385
|
+
|
|
386
|
+
for (i = 0; i < n + DATAPADDING_MSECS * (Fs / 1000); i++) {
|
|
387
|
+
align_filtered [i] = info-> data [i];
|
|
388
|
+
}
|
|
389
|
+
apply_filter (align_filtered, info-> Nsamples, 26, align_filter_dB);
|
|
390
|
+
|
|
391
|
+
power_above_300Hz = (float) pow_of (align_filtered,
|
|
392
|
+
SEARCHBUFFER * Downsample,
|
|
393
|
+
n - SEARCHBUFFER * Downsample + DATAPADDING_MSECS * (Fs / 1000),
|
|
394
|
+
maxNsamples - 2 * SEARCHBUFFER * Downsample + DATAPADDING_MSECS * (Fs / 1000));
|
|
395
|
+
|
|
396
|
+
global_scale = (float) sqrt (TARGET_AVG_POWER / power_above_300Hz);
|
|
397
|
+
|
|
398
|
+
for (i = 0; i < n; i++) {
|
|
399
|
+
info-> data [i] *= global_scale;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
safe_free (align_filtered);
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
|
|
406
|
+
void pesq_measure (SIGNAL_INFO * ref_info, SIGNAL_INFO * deg_info,
|
|
407
|
+
ERROR_INFO * err_info, long * Error_Flag, char ** Error_Type)
|
|
408
|
+
{
|
|
409
|
+
float * ftmp = NULL;
|
|
410
|
+
|
|
411
|
+
ref_info-> data = NULL;
|
|
412
|
+
ref_info-> VAD = NULL;
|
|
413
|
+
ref_info-> logVAD = NULL;
|
|
414
|
+
|
|
415
|
+
deg_info-> data = NULL;
|
|
416
|
+
deg_info-> VAD = NULL;
|
|
417
|
+
deg_info-> logVAD = NULL;
|
|
418
|
+
|
|
419
|
+
if ((*Error_Flag) == 0)
|
|
420
|
+
{
|
|
421
|
+
printf ("Reading reference file %s...", ref_info-> path_name);
|
|
422
|
+
|
|
423
|
+
load_src (Error_Flag, Error_Type, ref_info);
|
|
424
|
+
if ((*Error_Flag) == 0)
|
|
425
|
+
printf ("done.\n");
|
|
426
|
+
}
|
|
427
|
+
if ((*Error_Flag) == 0)
|
|
428
|
+
{
|
|
429
|
+
printf ("Reading degraded file %s...", deg_info-> path_name);
|
|
430
|
+
|
|
431
|
+
load_src (Error_Flag, Error_Type, deg_info);
|
|
432
|
+
if ((*Error_Flag) == 0)
|
|
433
|
+
printf ("done.\n");
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
if (((ref_info-> Nsamples - 2 * SEARCHBUFFER * Downsample < Fs / 4) ||
|
|
437
|
+
(deg_info-> Nsamples - 2 * SEARCHBUFFER * Downsample < Fs / 4)) &&
|
|
438
|
+
((*Error_Flag) == 0))
|
|
439
|
+
{
|
|
440
|
+
(*Error_Flag) = 2;
|
|
441
|
+
(*Error_Type) = "Reference or Degraded below 1/4 second - processing stopped ";
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
if ((*Error_Flag) == 0)
|
|
445
|
+
{
|
|
446
|
+
alloc_other (ref_info, deg_info, Error_Flag, Error_Type, &ftmp);
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
if ((*Error_Flag) == 0)
|
|
450
|
+
{
|
|
451
|
+
int maxNsamples = max (ref_info-> Nsamples, deg_info-> Nsamples);
|
|
452
|
+
float * model_ref;
|
|
453
|
+
float * model_deg;
|
|
454
|
+
long i;
|
|
455
|
+
FILE *resultsFile;
|
|
456
|
+
|
|
457
|
+
printf (" Level normalization...\n");
|
|
458
|
+
fix_power_level (ref_info, "reference", maxNsamples);
|
|
459
|
+
fix_power_level (deg_info, "degraded", maxNsamples);
|
|
460
|
+
|
|
461
|
+
printf (" IRS filtering...\n");
|
|
462
|
+
apply_filter (ref_info-> data, ref_info-> Nsamples, 26, standard_IRS_filter_dB);
|
|
463
|
+
apply_filter (deg_info-> data, deg_info-> Nsamples, 26, standard_IRS_filter_dB);
|
|
464
|
+
|
|
465
|
+
model_ref = (float *) safe_malloc ((ref_info-> Nsamples + DATAPADDING_MSECS * (Fs / 1000)) * sizeof (float));
|
|
466
|
+
model_deg = (float *) safe_malloc ((deg_info-> Nsamples + DATAPADDING_MSECS * (Fs / 1000)) * sizeof (float));
|
|
467
|
+
|
|
468
|
+
for (i = 0; i < ref_info-> Nsamples + DATAPADDING_MSECS * (Fs / 1000); i++) {
|
|
469
|
+
model_ref [i] = ref_info-> data [i];
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
for (i = 0; i < deg_info-> Nsamples + DATAPADDING_MSECS * (Fs / 1000); i++) {
|
|
473
|
+
model_deg [i] = deg_info-> data [i];
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
input_filter( ref_info, deg_info, ftmp );
|
|
477
|
+
|
|
478
|
+
printf (" Variable delay compensation...\n");
|
|
479
|
+
calc_VAD (ref_info);
|
|
480
|
+
calc_VAD (deg_info);
|
|
481
|
+
|
|
482
|
+
crude_align (ref_info, deg_info, err_info, WHOLE_SIGNAL, ftmp);
|
|
483
|
+
|
|
484
|
+
utterance_locate (ref_info, deg_info, err_info, ftmp);
|
|
485
|
+
|
|
486
|
+
for (i = 0; i < ref_info-> Nsamples + DATAPADDING_MSECS * (Fs / 1000); i++) {
|
|
487
|
+
ref_info-> data [i] = model_ref [i];
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
for (i = 0; i < deg_info-> Nsamples + DATAPADDING_MSECS * (Fs / 1000); i++) {
|
|
491
|
+
deg_info-> data [i] = model_deg [i];
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
safe_free (model_ref);
|
|
495
|
+
safe_free (model_deg);
|
|
496
|
+
|
|
497
|
+
if ((*Error_Flag) == 0) {
|
|
498
|
+
if (ref_info-> Nsamples < deg_info-> Nsamples) {
|
|
499
|
+
float *new_ref = (float *) safe_malloc((deg_info-> Nsamples + DATAPADDING_MSECS * (Fs / 1000)) * sizeof(float));
|
|
500
|
+
long i;
|
|
501
|
+
for (i = 0; i < ref_info-> Nsamples + DATAPADDING_MSECS * (Fs / 1000); i++) {
|
|
502
|
+
new_ref [i] = ref_info-> data [i];
|
|
503
|
+
}
|
|
504
|
+
for (i = ref_info-> Nsamples + DATAPADDING_MSECS * (Fs / 1000);
|
|
505
|
+
i < deg_info-> Nsamples + DATAPADDING_MSECS * (Fs / 1000); i++) {
|
|
506
|
+
new_ref [i] = 0.0f;
|
|
507
|
+
}
|
|
508
|
+
safe_free (ref_info-> data);
|
|
509
|
+
ref_info-> data = new_ref;
|
|
510
|
+
new_ref = NULL;
|
|
511
|
+
} else {
|
|
512
|
+
if (ref_info-> Nsamples > deg_info-> Nsamples) {
|
|
513
|
+
float *new_deg = (float *) safe_malloc((ref_info-> Nsamples + DATAPADDING_MSECS * (Fs / 1000)) * sizeof(float));
|
|
514
|
+
long i;
|
|
515
|
+
for (i = 0; i < deg_info-> Nsamples + DATAPADDING_MSECS * (Fs / 1000); i++) {
|
|
516
|
+
new_deg [i] = deg_info-> data [i];
|
|
517
|
+
}
|
|
518
|
+
for (i = deg_info-> Nsamples + DATAPADDING_MSECS * (Fs / 1000);
|
|
519
|
+
i < ref_info-> Nsamples + DATAPADDING_MSECS * (Fs / 1000); i++) {
|
|
520
|
+
new_deg [i] = 0.0f;
|
|
521
|
+
}
|
|
522
|
+
safe_free (deg_info-> data);
|
|
523
|
+
deg_info-> data = new_deg;
|
|
524
|
+
new_deg = NULL;
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
printf (" Acoustic model processing...\n");
|
|
530
|
+
pesq_psychoacoustic_model (ref_info, deg_info, err_info, ftmp);
|
|
531
|
+
|
|
532
|
+
safe_free (ref_info-> data);
|
|
533
|
+
safe_free (ref_info-> VAD);
|
|
534
|
+
safe_free (ref_info-> logVAD);
|
|
535
|
+
safe_free (deg_info-> data);
|
|
536
|
+
safe_free (deg_info-> VAD);
|
|
537
|
+
safe_free (deg_info-> logVAD);
|
|
538
|
+
safe_free (ftmp);
|
|
539
|
+
|
|
540
|
+
resultsFile = fopen (ITU_RESULTS_FILE, "at");
|
|
541
|
+
|
|
542
|
+
if (resultsFile != NULL) {
|
|
543
|
+
long start, end;
|
|
544
|
+
|
|
545
|
+
if (0 != fseek (resultsFile, 0, SEEK_SET)) {
|
|
546
|
+
printf ("Could not move to start of results file %s!\n", ITU_RESULTS_FILE);
|
|
547
|
+
exit (1);
|
|
548
|
+
}
|
|
549
|
+
start = ftell (resultsFile);
|
|
550
|
+
|
|
551
|
+
if (0 != fseek (resultsFile, 0, SEEK_END)) {
|
|
552
|
+
printf ("Could not move to end of results file %s!\n", ITU_RESULTS_FILE);
|
|
553
|
+
exit (1);
|
|
554
|
+
}
|
|
555
|
+
end = ftell (resultsFile);
|
|
556
|
+
|
|
557
|
+
if (start == end) {
|
|
558
|
+
fprintf (resultsFile, "REFERENCE\t DEGRADED\t PESQMOS\t PESQMOS\t SUBJMOS\t COND\t SAMPLE_FREQ\t CRUDE_DELAY\n");
|
|
559
|
+
fflush (resultsFile);
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
fprintf (resultsFile, "%s\t ", ref_info-> path_name);
|
|
563
|
+
fprintf (resultsFile, "%s\t ", deg_info-> path_name);
|
|
564
|
+
fprintf (resultsFile, "SQValue=%.3f\t ", err_info->pesq_mos);
|
|
565
|
+
fprintf (resultsFile, "%.3f\t ", err_info->pesq_mos);
|
|
566
|
+
fprintf (resultsFile, "%.3f\t ", err_info->subj_mos);
|
|
567
|
+
fprintf (resultsFile, "%d\t ", err_info->cond_nr);
|
|
568
|
+
fprintf (resultsFile, "%d\t", Fs);
|
|
569
|
+
fprintf (resultsFile, "%.4f\n ", (float) err_info-> Crude_DelayEst / (float) Fs);
|
|
570
|
+
|
|
571
|
+
fclose (resultsFile);
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
resultsFile = fopen (SIMPLE_RESULTS_FILE, "at");
|
|
575
|
+
|
|
576
|
+
if (resultsFile != NULL) {
|
|
577
|
+
long start, end;
|
|
578
|
+
|
|
579
|
+
if (0 != fseek (resultsFile, 0, SEEK_SET)) {
|
|
580
|
+
printf ("Could not move to start of results file %s!\n", SIMPLE_RESULTS_FILE);
|
|
581
|
+
exit (1);
|
|
582
|
+
}
|
|
583
|
+
start = ftell (resultsFile);
|
|
584
|
+
|
|
585
|
+
if (0 != fseek (resultsFile, 0, SEEK_END)) {
|
|
586
|
+
printf ("Could not move to end of results file %s!\n", SIMPLE_RESULTS_FILE);
|
|
587
|
+
exit (1);
|
|
588
|
+
}
|
|
589
|
+
end = ftell (resultsFile);
|
|
590
|
+
|
|
591
|
+
if (start == end) {
|
|
592
|
+
fprintf (resultsFile, "DEGRADED\t PESQMOS\t SUBJMOS\t COND\t SAMPLE_FREQ\t CRUDE_DELAY\n");
|
|
593
|
+
fflush (resultsFile);
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
fprintf (resultsFile, "%s\t ", deg_info-> file_name);
|
|
597
|
+
fprintf (resultsFile, "%.3f\t ", err_info->pesq_mos);
|
|
598
|
+
fprintf (resultsFile, "%.3f\t ", err_info->subj_mos);
|
|
599
|
+
fprintf (resultsFile, "%d\t ", err_info->cond_nr);
|
|
600
|
+
fprintf (resultsFile, "%d\t", Fs);
|
|
601
|
+
fprintf (resultsFile, "%.4f\n ", (float) err_info-> Crude_DelayEst / (float) Fs);
|
|
602
|
+
|
|
603
|
+
fclose (resultsFile);
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
return;
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
/* END OF FILE */
|