-
Notifications
You must be signed in to change notification settings - Fork 4
/
test_mrGEDI.m
107 lines (89 loc) · 3.42 KB
/
test_mrGEDI.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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% test_mrGEDI
% Test code for mr-GEDI
%
% Yamamoto K.,
% Created : 26 Dec. 2018 based on test_GEDI
% Modified: 12 Jul. 2020 updated parameters
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear all
close all
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Environment settings
% Root
DirRoot = [getenv('HOME') '/Desktop/GEDI/'];
chdir(DirRoot);
% Sounds
DirData = [DirRoot 'wav_sample/'];
% Package of dynamic compressive gammachirp filterbank
% Please download the "GCFBv211pack" and put into the "package" directory
%DirGCFB = [DirRoot 'package/GCFBv210pack/'];
DirGCFB = [DirRoot 'package/GCFBv211pack/'];
StrPath = path;
if ~contains(StrPath,'GCFBv211pack/') == 1
addpath(genpath(DirRoot));
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% GEDI and materials
% Parameters of dcGC filterbank
GCparam.Ctrl = 'dynamic';
GCparam.NumCh = 100;
GCparam.fs = 48000;
% Parameter settings for material conditions
fs = 16000;
SPL = 65; % sound pressure level
ParamSNR = [-6 -3 0 3]; % SNR between clean speech and noise
TimeSndBefore = 0.35; % onset time of the noisy speech from noise only sound (sec)
% Model parameters
Conditions = [1.43 0.5 20000 1.81 fs]; % [k q m sigma_s fs]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Start simulation
Pcorrects = zeros(1,length(ParamSNR));
for i = 1:length(ParamSNR)
% Index number of a sample speech file
idxSp = i;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Test signal (enhanced/Unprocessed speech); the speech intelligiblity is calculated
% Name of wav-file (example: '*/GEDI_Software/wav_sample/sample_sp1')
strTest = [DirData 'sample_sp' num2str(idxSp)];
% Read wav-file of test speech
[SndTest, ~] = audioread([strTest '.wav']);
disp(strTest);
%% Reference signal (Clean speech)
% Name of wav-file
strClean = [DirData 'sample_sp_clean'];
% Read wav-file of clean speech
[SndClean, ~] = audioread([strClean '.wav']);
disp(strClean);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Pre-processing with a half-cosine function
TimeHalfCos = 0.02; % [sec]
LenSndClean = length(SndClean);
LenHalfCos = round(TimeHalfCos * fs);
SigHalfCos = hann(LenHalfCos*2);
SigHalfCosUp = SigHalfCos(1:LenHalfCos)';
CompHalfCosFunc = [SigHalfCosUp ones(1,LenSndClean-LenHalfCos*2) fliplr(SigHalfCosUp)];
SndClean = SndClean .* CompHalfCosFunc';
% Extract a speech segment for sample data
SndTest = SndTest(fs*TimeSndBefore+1:fs*TimeSndBefore+LenSndClean) .* CompHalfCosFunc';
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Speech intelligibility prediction by mr-GEDI
Result = mrGEDI(SndTest, SndClean, GCparam, Conditions, SPL);
Pcorrect = Result.Pcorrect;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Pcorrects(idxSp) = Pcorrect;
disp('==========================================');
disp(['Percent correct:' num2str(Pcorrect) '(%)']);
disp('==========================================');
end
%% Plot results
figure
plot(ParamSNR,Pcorrects);
xlim([-0.5+min(ParamSNR) max(ParamSNR)+0.5]);
ylim([-0.5+0 100+0.5]);
xlabel('SNR (dB)');
ylabel('Percent correct (%)')
legend('Unprocessed')
title('Examples of mr-GEDI');