-
Notifications
You must be signed in to change notification settings - Fork 0
/
e_13_06.m
76 lines (66 loc) · 1.76 KB
/
e_13_06.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
init;
s{1} = '../../dataset/Parus major/ParMaj00010.wav';
s{2} = '../../dataset/Parus major/ParMaj00024.wav';
s{3} = '../../dataset/Parus major/ParMaj00035.wav';
s{4} = '../../dataset/Parus major/ParMaj00052.wav';
s{5} = '../../dataset/Parus major/ParMaj00083.wav';
s{6} = '../../dataset/Parus major/ParMaj00140.wav';
s{7} = get_random_TIER_file( filenames, '../../' );
s{8} = get_random_TIER_file( filenames, '../../' );
s{9} = get_random_TIER_file( filenames, '../../' );
s{10} = get_random_TIER_file( filenames, '../../' );
s{11} = get_random_TIER_file( filenames, '../../' );
s{12} = get_random_TIER_file( filenames, '../../' );
estim_formants = true;
run = 1;
if run == 1
%%Experiment 1:
% K = 10
% Train on one example
% Use only the first formant
if estim_formants
clear F;
for i=1:12
tmp = formants_from_mfcc_file( s{i}, 6, 20 );
F{i} = tmp(:, 1);
end
end
clear hmm;
hmm.K=10;
hmm=hmminit(F{1}, hmm, 'full');
[m n] = size( F{1} );
hmm=hmmtrain(F{1}, m, hmm);
for i=1:12
[m n] = size( F{i} );
[v, t, ll] = hmmdecode( F{i}, m, hmm);
V{i} = v;
LL(i) = ll;
end
[t, indices] = sort(LL);
t
s{indices}
elseif run == 2
%%Experiment 2:
% K = 4
% Each example is a frame in a signal
% Use first three formants
if estim_formants
clear F;
for i=1:12
tmp = formants_from_mfcc_file( s{i}, 6, 20 );
F{i} = tmp(:, 1:3)';
end
end
hmm.K=4;
size( F{1} )
hmm=hmminit(F{1}, hmm, 'full');
hmm=hmmtrain( F{1}, 3, hmm);
for i=1:12
[m n] = size( F{i} );
[v, t, ll] = hmmdecode( F{i}, m, hmm);
V{i} = v;
LL(i) = ll;
end
[t, indices] = sort(LL);
s{indices}
end