semiv5st.m
来自「这是一个用于语音信号处理的工具箱」· M 代码 · 共 336 行
M
336 行
disp(' ');
disp('SCRIPT: semiv5st.m **********************************************');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% semiv5st.m
%
% jmw
% 9/30/94
% 1/26/94
% 1/14/94
%
% THIS METHOD loads results from vdet5st, vcdet4st, and r1_ratio3st
% in an attempt to identify semivowels
%
% AND STORES SCORE
%
% it also loads NASAL RESULT from naratio4st and does not allow
% semivowel hit if nasal score is greater than a specific value...
%
% THIS DIFFERS FROM my PREVIOUS SEMIVOWEL PROGRAMS by not calculating
% a binary score, instead it calculates a variable {0,1} score.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
file_string = sprintf('temp/%s.mat', name);
s=sprintf('loading ./%s from hard disk ...',file_string);
disp(s);
s=sprintf('load %s', file_string);
eval(s);
signal = eval(name);
file_string = sprintf('temp/%s_Data.mat', name);
s=sprintf('loading ./%s from hard disk ...',file_string);
disp(s);
s=sprintf('load %s', file_string);
eval(s);
file_string = sprintf('temp/%s_VCscore.mat', name);
s=sprintf('loading ./%s from hard disk ...',file_string);
disp(s);
s=sprintf('load %s', file_string);
eval(s);
file_string = sprintf('temp/%s_SONscore.mat', name);
s=sprintf('loading ./%s from hard disk ...',file_string);
disp(s);
s=sprintf('load %s', file_string);
eval(s);
file_string = sprintf('temp/%s_VWLscore.mat', name);
s=sprintf('loading ./%s from hard disk ...',file_string);
disp(s);
s=sprintf('load %s', file_string);
eval(s);
file_string = sprintf('temp/%s_BARscore.mat', name);
s=sprintf('loading ./%s from hard disk ...',file_string);
disp(s);
s=sprintf('load %s', file_string);
eval(s);
file_string = sprintf('temp/%s_NASscore.mat', name);
s=sprintf('loading ./%s from hard disk ...',file_string);
disp(s);
s=sprintf('load %s', file_string);
eval(s);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[m,n]=size(cofa);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PLT = 1; % plot decision flag
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% find sonorant consonant binary
VC_thresh = 0.5; % thresholds
SON_thresh = 0.5;
SC = zeros(1,m); % sonorant consonant binary
for i=1:m,
if (vc_score(i) > VC_thresh & son_score(i) > SON_thresh)
SC(i) = 1;
else
SC(i) = 0;
end;
end;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% compute freq response for murmur score
N=256;
start1 = 2;
stop1 = 21;
start2 = 22;
stop2=51;
murmur = zeros(m,1);
e1 = zeros(m,1);
e2 = zeros(m,1);
gain = zeros(m,1);
for i=1:m-1,
if(VUS_voicetype(i)=='v' | VUS_voicetype(i+1)=='v' )
a = range(i,1);
b = range(i,2);
%res_nrg = residue(a:b) * residue(a:b)' ;
%gain(i) = sqrt(res_nrg); % removed jmw 9/30/94
gain(i) = 1;
[h,w]=freqz(gain(i),cofa(i,:),N);
mag=abs(h);
e1(i)=sqrt(mag(start1:stop1)' * mag(start1:stop1));
e2(i) = sqrt(mag(start2:stop2)' * mag(start2:stop2));
murmur(i) = e1(i) /e2(i);
end;
end;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% smooth murmur ratio
MFO = 5; % median filter order
s=sprintf('smoothing murmur ratio with median filter of order %d ...', MFO);
disp(s);
murmur=median1(murmur,MFO);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% calculate murmur score
mur_thresh_LOW = 4; % thresholds
mur_thresh_HI = 12;
R = mur_thresh_HI - mur_thresh_LOW;
mur_score = zeros(1,m);
for i=1:m,
if (VUS_voicetype(i)=='v')
if (murmur(i) > mur_thresh_HI)
mur_score(i) = 1;
elseif (murmur(i) > mur_thresh_LOW)
mur_score(i) = (murmur(i) - mur_thresh_LOW ) / R;
else
mur_score(i) = 0;
end;
end;
end;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% now do it the continuously variable {0,1} method ... (john's method)
score1_cnt = 0;
score2_cnt = 0;
semivwl_score = zeros(1,m);
for i=1:m,
score1 = (1-mur_score(i)) * (1-bar_score(i));
score2 = (1-mur_score(i)) * bar_score(i); % not used - a test
if (score1 > score2)
score1_cnt = score1_cnt + 1;
else
score2_cnt = score2_cnt + 1;
end;
% three old abandoned ideas follow
%semivwl_score(i) = vc_score(i) * vc_score(i) * max([score1 score2]);
%semivwl_score(i) = sqrt(vc_score(i)) * max([score1 score2]);
%semivwl_score(i) = vc_score(i) * max([score1 score2]);
semivwl_score(i) = vc_score(i) * score1;
if (semivwl_score(i) > 1)
semivwl_score(i) = 1;
end;
end;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% zero semivowel score if nasal score exceeds certain threshold ...
old_semivwl_score = semivwl_score;
N_thresh = 0.50; % jmw 2/23/94
s=sprintf('eliminating frames with nasal score > %4.2f ...',N_thresh);
disp(s);
for i=1:m,
if (nas_score(i) > N_thresh ),
semivwl_score(i) = 0;
end;
end;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% segment
%old_semivwl_score = semivwl_score;
seg_cnt = 0;
flg = 1;
for i = 1:m,
if ( semivwl_score(i) > 0 & flg == 1)
% start new segment
seg_cnt = seg_cnt + 1;
seg_frames(seg_cnt,1) = i;
flg = 0;
elseif ( semivwl_score(i) > 0 & flg==0)
% continue in current segment
seg_frames(seg_cnt,2) = i;
elseif ( semivwl_score(i) == 0 & flg==0 )
% segment just ended on previous frame - reset flag
seg_frames(seg_cnt,2) = i-1;
flg = 1;
end;
end;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% and discard segments that are tooooo short
events = 0;
SEMIVWL_thresh = 300;
if ( seg_cnt >0)
% segments do exist
for i=1:seg_cnt,
a=range(seg_frames(i,1),1);
b=range(seg_frames(i,2),2);
if ( (b-a) < SEMIVWL_thresh)
% discard - too short
events = events + 1; % counter of segments eliminated
a=seg_frames(i,1);
b=seg_frames(i,2);
semivwl_score(a:b) = zeros(1,b-a+1);
end;
end;
end;
s=sprintf('eliminating semivowel segments less than');
s1 = sprintf(' %d samples: ... %d events',SEMIVWL_thresh,events);
s=[s s1];
disp(s);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if (PLT)
titles = 1; % turn off for diss figs
disp('plotting results ...');
h=gcf;
figure(h);
clf;
subplot(311)
plot(signal);
a=axis;
grid on;
s=sprintf('%s', name);
if (titles)
title(s);
end;
subplot(312);
stairs(range(:,1), old_semivwl_score);
axis([a(1) a(2) -0.5 1.5]);
grid on;
if (titles)
title('Unadjusted Semivowel Score');
end;
subplot(313);
stairs(range(:,1), semivwl_score);
axis([a(1) a(2) -0.5 1.5]);
grid on;
if (titles)
title('Final Semivowel Score');
end;
drawnow;
end;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% save to disk
smv_score = semivwl_score;
s=sprintf('saving ./%s_SMVscore to disk ...', name);
disp(s);
s=sprintf('save temp/%s_SMVscore smv_score', name);
eval(s);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% clean up time...
clear M b power
clear MFO bar_score range
clear MM cofa res_nrg
clear MS e1 residue
clear MUR_thresh_HI e2 s1
clear MUR_thresh_LOW events seg_cnt
clear N file_string seg_frames
clear NM flg semivwl_score
clear NS gain signal
clear N_thresh h smv_score
clear PLT i son_score
clear R m start1
clear S mag start2
clear SC mur_score stop1
clear SEMIVWL_thresh mur_thresh_HI stop2
clear SON_thresh mur_thresh_LOW vc_score
clear STOP_thresh_HI murmur voicetype
clear STOP_thresh_LOW n vwl_score
clear VC_thresh w
clear VUS_voicetype nas_score score1
clear a old_semivwl_score score2
clear score1_cnt score2_cnt titles
s=sprintf('clear %s',name);
eval(s);
clear s;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?