-
Notifications
You must be signed in to change notification settings - Fork 127
/
Copy pathobjective_scoring.m
131 lines (103 loc) · 4.66 KB
/
objective_scoring.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
% AUTHOR: Aaron Nicolson
% AFFILIATION: Signal Processing Laboratory, Griffith University
%
% This Source Code Form is subject to the terms of the Mozilla Public
% License, v. 2.0. If a copy of the MPL was not distributed with this
% file, You can obtain one at http://mozilla.org/MPL/2.0/.
clear all; close all; clc;
%% GET MATLAB_FEAT REPOSITORY
addpath('./deepxi')
%% PARAMETERS
f_s = 16000; % sampling frequency (Hz).
snr = -5:5:15; % SNR levels to test.
%% PROCESSED (ENHANCED) SPEECH DIRECTORIES
y.dirs = {
% 'C:/Users/nic261/Outputs/DeepXi/mhanet-1.1c/e200/y/mmse-lsa',...
% 'C:/Users/nic261/Outputs/DeepXi/resnet-1.1n/e180/y/mmse-lsa',...
% 'C:/Users/nic261/Outputs/DeepXi/resnet-1.1c/e200/y/mmse-lsa',...
% 'C:/Users/nic261/Outputs/DeepXi/resnet-1.1c/e200/y/mmse-stsa',...
% 'C:/Users/nic261/Outputs/DeepXi/resnet-1.1c/e200/y/wf',...
% 'C:/Users/nic261/Outputs/DeepXi/resnet-1.1c/e200/y/cwf',...
% 'C:/Users/nic261/Outputs/DeepXi/resnet-1.1c/e200/y/srwf',...
'C:/Users/nic261/Outputs/DeepXi/resnet-1.1c/e200/y/irm',...
'C:/Users/nic261/Outputs/DeepXi/resnet-1.1c/e200/y/ibm',...
};
%% REFERENCE (CLEAN) SPEECH DIRECTORY
s.paths = dir('C:/Users/nic261/Datasets/deep_xi_dataset/test_clean_speech/*.wav');
%% OBJECTIVE SCORES DIRECTORY
res_dir = 'log/results/objective_scores';
if ~exist(res_dir, 'dir')
mkdir(res_dir)
end
%% OBJECTIVE SCORING
for i = 1:length(y.dirs)
noise_src_set = {};
results = MapNested();
split_str = strsplit(y.dirs{i}, '/');
ver = [split_str{end-3}, '_', split_str{end-2}, '_', split_str{end}];
for j = 1:length(s.paths)
for k = snr
s.wav = audioread([s.paths(j).folder, '/', s.paths(j).name]);
split_basename = strsplit(s.paths(j).name, '_');
noise_src = split_basename{end};
snr_str = num2str(k);
y.wav = audioread([y.dirs{i}, '/', s.paths(j).name(1:end-4), ...
'_', snr_str, 'dB.wav']);
y.wav = y.wav(1:length(s.wav));
if any(isnan(y.wav(:))) || any(isinf(y.wav(:)))
error('NaN or Inf value in enhanced speech.')
end
if ~any(strcmp(noise_src_set, noise_src))
noise_src_set{end+1} = noise_src;
end
[CSIG, CBAK, COVL] = composite(s.wav, y.wav, f_s);
PESQ = pesq(s.wav, y.wav, f_s);
STOI = stoi(s.wav, y.wav, f_s);
results = add_score(CSIG, results, noise_src, snr_str, 'CSIG');
results = add_score(CBAK, results, noise_src, snr_str, 'CBAK');
results = add_score(COVL, results, noise_src, snr_str, 'COVL');
results = add_score(PESQ, results, noise_src, snr_str, 'PESQ');
results = add_score(STOI, results, noise_src, snr_str, 'STOI');
end
clc;
fprintf('%.2f%%\n', 100*j/length(s.paths));
end
fileID = fopen([res_dir, '/', ver, '.csv'],'w');
fprintf(fileID, 'noise_src, snr_db, CSIG, CBAK, COVL, PESQ, STOI\n');
avg.CSIG = [];
avg.CBAK = [];
avg.COVL = [];
avg.PESQ = [];
avg.STOI = [];
for j = 1:length(noise_src_set)
for k = snr
snr_str = num2str(k);
CSIG = mean(results(noise_src_set{j}, snr_str, 'CSIG'));
CBAK = mean(results(noise_src_set{j}, snr_str, 'CBAK'));
COVL = mean(results(noise_src_set{j}, snr_str, 'COVL'));
PESQ = mean(results(noise_src_set{j}, snr_str, 'PESQ'));
STOI = mean(results(noise_src_set{j}, snr_str, 'STOI'));
fprintf(fileID, '%s, %s, %.2f, %.2f, %.2f, %.2f, %.2f\n', ...
noise_src_set{j}, snr_str, ...
CSIG, CBAK, COVL, PESQ, 100*STOI);
avg.CSIG = [avg.CSIG; results(noise_src_set{j}, snr_str, 'CSIG')];
avg.CBAK = [avg.CBAK; results(noise_src_set{j}, snr_str, 'CBAK')];
avg.COVL = [avg.COVL; results(noise_src_set{j}, snr_str, 'COVL')];
avg.PESQ = [avg.PESQ; results(noise_src_set{j}, snr_str, 'PESQ')];
avg.STOI = [avg.STOI; results(noise_src_set{j}, snr_str, 'STOI')];
end
end
fclose(fileID);
avg_path = [res_dir, '/average.csv'];
if ~exist(avg_path, 'file')
fileID = fopen(avg_path, 'w');
fprintf(fileID, 'ver, CSIG, CBAK, COVL, PESQ, STOI\n');
fclose(fileID);
end
fileID = fopen(avg_path, 'a');
fprintf(fileID, '%s, %.2f, %.2f, %.2f, %.2f, %.2f\n', ver, ...
mean(avg.CSIG), mean(avg.CBAK), mean(avg.COVL), ...
mean(avg.PESQ), 100*mean(avg.STOI));
fclose(fileID);
end
% EOF