vcdet4st.m
来自「这是一个用于语音信号处理的工具箱」· M 代码 · 共 183 行
M
183 行
disp(' ');
disp('SCRIPT: vcdet4st.m ***********************************************');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Voiced Consonant Detection Program
% jmw
% 1/6/94
% 1/3/94
% 12/30/93
%
% playing with Weinstein, et al., algorithm for parsing based
% upon RMS values of BP filters
% gain calculated from sqrt of res NRG (this feature removed)
%
% THIS VERSION ALSO ADDS: multiple thresholds to better determine
% accurate v/c transition location...
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PLT = 1; % flag to plot results
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
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);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% compute freq response
N=256;
start1 = 2;
stop1 = 52;
start2 = 53;
stop2=N;
[m,n]=size(cofa);
vc = 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));
vc(i) = e1(i) /e2(i);
else
;
end;
end;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% smooth vc ratio
MFO = 5; % swiched back from 7 to 5 2/21/94 % median filter order
s=sprintf('smoothing vc ratio with median filter of order %d ...', MFO);
disp(s);
vc=median1(vc,MFO);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% calculate (voiced) consonant score
vc_thresh_LOW = 8; % thresholds - empirically determined
vc_thresh_HI = 18;
R = vc_thresh_HI - vc_thresh_LOW; % R= "range"
vc_score = zeros(1,m);
for i=1:m,
if (VUS_voicetype(i)=='b' | VUS_voicetype(i)=='v')
if (vc(i) >= vc_thresh_HI)
vc_score(i) = 1;
elseif (vc(i) > vc_thresh_LOW)
vc_score(i) = (vc(i) - vc_thresh_LOW) / R;
else
vc_score(i) = 0;
end;
end;
end;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
titles = 1; % turn off for diss figs
if (PLT)
disp('plotting results ...');
h=gcf;
figure(h);
clf;
subplot(311);
plot(signal);
grid;
axis_1=axis;
axis(axis_1);
s=sprintf('%s', name);
if (titles)
title(s);
end;
subplot(312);
stairs(range(:,1),vc);
grid;
axis([axis_1(1) axis_1(2) 0 40]);
s=sprintf('smoothed vc ratio (0-1000)/(1000-5000) - order %d median filt', MFO);
hold on;
%plot(range(:,1), ( vc_thresh_HI * ones(1,m)), ':');
%plot(range(:,1), ( vc_thresh_LOW * ones(1,m)), ':');
plot(( vc_thresh_HI * ones(1,axis_1(2))), '--');
plot( ( vc_thresh_LOW * ones(1,axis_1(2))), '--');
hold off;
if (titles)
title(s);
end;
subplot(313);
stairs(range(:,1),vc_score);
grid on;
axis([axis_1(1) axis_1(2) -0.5 1.5]);
if (titles)
title('(Voiced) Consonant Score (voiced segments only)');
end;
drawnow;
end;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% save to disk
s=sprintf('saving ./%s_VCscore to disk ...', name);
disp(s);
s=sprintf('save temp/%s_VCscore vc_score', name);
eval(s);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% clean up time
clear MFO e1 res_nrg
clear N e2 residue
clear PLT file_string signal
clear R gain start1
clear VUS_voicetype h start2
clear a i stop1
clear axis_1 m stop2
clear b mag vc
clear vc_score n vc_score
clear vc_thresh_HI voicetype
clear vc_thresh_LOW power w
clear cofa range titles
s=sprintf('clear %s',name);
eval(s);
clear s
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?