synthesis_unvoiced_go.m

来自「这是一个用于语音信号处理的工具箱」· M 代码 · 共 149 行

M
149
字号
%To generate synthetic speech using the source and the formants specified
%Written by albert Hsiao
%Changes and interface by Karthik
%Modified by D. G. Childers 2/25/98

speech1=zeros(1,length(noise_excitation));

%--------------------------------------------------------------------%
%  process the excitation signal throught the formant filter %
%--------------------------------------------------------------------%



   rts=ff2root(Ff(1,:),Fb(1,:));
   pcofa=real( poly(rts) );
   filt_len=length(pcofa)-1;
   gp=noise_excitation;
   gx=filter(1,pcofa,gp);
   speech1=gx;

%Create display figure
PV = [179 55 611 464];
s2 = 'Speech Display window';

% Open analysis window
while exist('speech_display_fig')==1
   try1 = 'get(speech_display_fig,''position'');';
   eval(try1,catch2);
   if check ==0
      clear speech_display_fig;
      check = 1;
      break;
   end
   s1 = get(speech_display_fig,'Name');
   if ~strcmp(s1,s2)
      clear speech_display_fig;
      break;
   end
   figure(speech_display_fig);
   break;
end;

if exist('speech_display_fig')~=1;
   speech_display_fig= figure('Position',PV,...
      'Resize','on',...
      'Numbertitle','off',...
      'Color',[0.8 0.8 0.8],...
      'Name',s2);
end

clf;

ax1=axes('Position',[0.08 0.54 0.75 0.40]);
ax2=axes('Position',[0.08 0.04 0.75 0.40]);

uicontrol('Style','Pushbutton',...
   'Units','normalized',...
   'Position',[.85 .85 .12 .08], ...
   'String','play',...
   'Callback', 'soundsc(excitation,Srate);');

uicontrol('Style','Pushbutton',...
'Units','Normalized',...   
'Position',[.85 .70 .12 .08], ...
'String','spectrogram',...
'Callback', 'sgram2'); %sgram2--excitation for synthesized speech
uicontrol('Style','Pushbutton',...
   'Units','normalized',...
   'Position',[.85 .55 .12 .08], ...
   'String','waveform',...
   'Callback', 'axes(ax1);plot(excitation,''b'');title(''Excitation Signal'');');

uicontrol('Style','Pushbutton',...
   'Units','Normalized',...
   'Position',[.85 .35 .12 .08], ...
   'String','play',...
   'Callback', 'soundsc(speech1,Srate);');

uicontrol('Style','Pushbutton',...
   'Units','Normalized',...   
   'Position',[.85 .20 .12 .08], ...
   'String','Spectrogram',...
   'Units','normalized',...
   'Callback', 'sgram1'); %sgram1--speech1--synthesized speech 
uicontrol('Style','Pushbutton',...
   'Units','normalized',...
   'Position',[.85 .05 .12 .08], ...
   'String','waveform',...
   'Callback', 'axes(ax2);plot(speech1,''b'');title(''Synthesized speech'');');

axes(ax1);
plot(noise_excitation,'b'); 
title('Excitation Signal');
axes(ax2); 
plot(speech1,'b');
title('Synthesized Speech');


%Create a window to enable save and quit features

PV = [8 121 154 163];
s2 = 'Synthesis  Menu';

% Open analysis window
while exist('synth_fig_1')==1
   try1 = 'get(synth_fig_1,''position'');';
   eval(try1,catch2);
   if check ==0
      clear synth_fig_1;
      check = 1;
      break;
   end
   s1 = get(synth_fig_1,'Name');
   if ~strcmp(s1,s2)
      clear synth_fig_1;
      break;
   end
   figure(synth_fig_1);
   break;
end;

if exist('synth_fig_1')~=1;
   
   synth_fig_1=figure('Position',PV,...
      'Resize','off',...
      'Numbertitle','off',...
      'Color',[0.5 0.5 0.5],...
      'Name',s2);
   
   uicontrol('Style','frame',...
      'Units','Normalized',...
      'Position',[0.03 0.03 0.94 0.94],...
      'BackGroundColor',[0.9 0.9 0.9]);
   
   speech_save_popup = uicontrol('Style','Pushbutton',...
      'Units','Normalized',...
      'Position',[0.1 0.65 0.8 .2],...
      'String','Save(Ascii)',...
      'Callback','save_speech');
         
   uicontrol('Style','Pushbutton',...
      'Units','Normalized',...
      'Position',[0.1  0.2 0.8 .2],...
      'String','Cancel',...
      'Callback','speech_quit');
end


⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?