📄 syn1aexp3.m
字号:
disp(' ');
disp('SCRIPT: syn1aexp3.m *********************************');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% H.T Hu and JMW
% 3/1/94
% modified by D. G. Childers 2/16/98
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
file_string=sprintf('temp/%s_Excite.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/temp.mat',name);
s=sprintf('loading %s from hard disk ...',file_string);
disp(s);
s=sprintf('load %s',file_string);
eval(s); %this is to be able to get residue
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); %this is to be able to get range
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Performing amplitude perturbation if required (add shimmer)
% this is only done for successive duplicate frames
amp=ones(1,length(Excite));
total_frame=length(Excite);
for k=2:total_frame,
if (Excite(k)==Excite(k-1))
amp(k)=1+(rand-0.5)*.05;
else
amp(k)=1;
end;
end;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% filter/synthesize signal
disp('synthesis operation is processing, please wait ...');
%%%%%%%%%%%%%%%%%%%%%%%%%
% create message window and write message in that window also
message_window=figure('Unit','normalized',...
'Position',[0.05 0.2 0.5 0.2],...
'Resize','off',...
'Color',BACK_COLOR,...
'Numbertitle','off',...
'Name','Message');
axis('off');
ss=sprintf('The synthesis calculations are underway, please wait ...');
text(-0.05,1,ss,'color',[0 0 1],'FontSize',10);
pause(2.);
close(message_window);
clear message_window;
%%%%%%%%%%%%%%%%%%%%%%%%%
count=0;
syns=zeros(1,length(residue)*3); % three-time long
cmp_ratio=0.2;
Ziy=zeros(1,13);
tic
old_n = 0;
n_dist = 3; %1 for no missing frames
for k=1:total_frame
n=Excite(k);
excitation=residue(range(n,1):range(n,2))*amp(k); lenex=length(excitation);
if (k < total_frame)
if (Excite(k+1)==Excite(k) & VUS_voicetype(Excite(k))=='u')
rinput=rand(1,lenex)-.5;
excitation=sqrt((excitation*excitation')/ ...
(rinput*rinput'))*rinput;
end;
end;
% add smoothing by adjusting initial conditions of filter
% if there is a big discontinious jump (= n_dist) in excitation
% jmw 8/12/94
if ((n-old_n) > n_dist)
Ziy=zeros(1,13);
x_excitation=residue(range(n-1,1):range(n-1,2));
[y, Ziy]=filt_n1(1,cofa(n-1,:),x_excitation,Ziy);
st = sprintf('adjusting IC for frame %d, sample %d', n,count);
disp(st);
end;
old_n = n;
[y, Ziy]=filt_n1(1,cofa(n,:),excitation,Ziy);
len=range(n,2)-range(n,1)+1; syns(count+1:len+count)=y;% syns(count+(1:len))=y;
count=count+len;
if (k/total_frame > cmp_ratio)
Show=sprintf(' %2d%% completed', ...
round(cmp_ratio*100));
disp(Show);
cmp_ratio =cmp_ratio + 0.2;
end;
end;
disp(' 100% completed');
syns=syns(1:count); % truncate to signal length (remove appended zeros)
% The variable "syns" indicates synthetic speech.
s=sprintf('syn_%s = syns;', name);
eval(s);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% save syn"name" to hard disk
s=sprintf('saving ./syn_%s to hard disk ...', name);
disp(s);
s=sprintf('save temp/syn_%s.dat syn_%s -ascii', name, name);
eval(s);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%
% create message window and write message in that window also
message_window=figure('Unit','normalized',...
'Position',[0.05 0.2 0.6 0.2],...
'Resize','off',...
'Color',BACK_COLOR,...
'Numbertitle','off',...
'Name','Message');
axis('off');
ss=sprintf('The synthesis is completed and saved to temp/syn__%s.dat', name);
text(-0.05,1,ss,'color',[0 0 1],'FontSize',10);
pause(5.);
close(message_window);
clear message_window;
%%%%%%%%%%%%%%%%%%%%%%%%%
% clean up time
clear Excite file_string s
clear Show k
clear len syns
clear Ziy lenex
clear amp n
clear cmp_ratio y
clear count total_frame
clear excitation x_excitation
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -