ceps_go.m

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

M
117
字号
%Callback function for real and complex cepstum
%Author D. G. Childers
%Date June 11, 1997
%Modified from a program by Karthik
%

x = 1;
PV=[270 44 515 268];
s2 = 'Cepstral Analysis - Output';

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

if exist('ceps_out_win_h')~=1;
    ceps_out_win_h = figure('Position',PV,...
      'Numbertitle','off',...
      'Name',s2);
end

if ceps_window == 1
	window = hamming(ceps_frame_len);	   % Window type
elseif ceps_window == 2
	window = hanning(ceps_frame_len);	   % Window type
elseif ceps_window == 3
	beta=0.5;
	window = kaiser(ceps_frame_len,beta);	% Window type
elseif ceps_window == 4
	window = triang(ceps_frame_len);     	% Window type
elseif ceps_window == 5
	window = bartlett(ceps_frame_len);	   % Window type
elseif ceps_window == 6
	window = blackman(ceps_frame_len);	   % Window type
elseif ceps_window == 7
	window = boxcar(ceps_frame_len);	      % Window type
elseif ceps_window == 8
	rdb=3;
	window = chebwin(ceps_frame_len,rdb);	% Window type
end
button=1;
while button == 1
	if freq_ceps_mark_flag == 0
		S=sprintf('The analysis frame is the first %d points of current data window',ceps_frame_len);
		disp(S);
		speech1=SPEECH_OLD(LEFT:LEFT+ceps_frame_len-1);
		button=0;
	else
		disp('Please select a starting point of analysis frame');
		figure(ana_wav_win_h);
      [x,y,button]=ginput(1);
      x=round(x);
		if button ~= 1
			break;
		end
   end
   
x_end=x+ceps_frame_len-1;
   if x > RIGHT
      disp('You have reached the end of the data.  The analysis will use');
      disp('the last data point.');
      x=RIGHT-ceps_frame_len;
      x_end=x+ceps_frame_len-1;
   end
   if x_end > RIGHT
      disp('You have reached the end of the data.  The analysis will use');
      disp('the last data point.');
      x_end=RIGHT;
      x=RIGHT-(ceps_frame_len-1);
   end
   

   speech1=SPEECH_OLD(x:x_end);
   figure(ceps_out_win_h);
   window = window(1:(x_end-x+1));
   speech1=window.*speech1;
   
val=get(ceps_po_method_h,'Value');

if val==1
   cepstrum = rceps(speech1);
   vh=1:length(cepstrum)/2;
%vh=1:length(cepstrum(1:ceps_frame_len/2));
cepstrum = cepstrum(1:length(cepstrum)/2);
plot(vh,cepstrum);
xlabel('quefrency');
title('Real Cepstrum');  
  
elseif val==2
   cepstrum = cceps(speech1);
   vh=1:length(cepstrum)/2;
%vh=1:length(cepstrum(1:ceps_frame_len/2));
cepstrum = cepstrum(1:length(cepstrum)/2);
plot(vh,cepstrum);
xlabel('quefrency');
title('Complex Cepstrum');
end
clear speech1
clear x
clear x_end
end


⌨️ 快捷键说明

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