⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pctour.m

📁 这是一个用于语音信号处理的工具箱
💻 M
字号:
%FUNCTION PCTOUR construct the pitch contour from the GCI sequence and 
%         decompose the pitch contour into three components.
% [p0,pw,pb,gcidx,seglens]=pctour(gci);
% INPUT : gci == GCI sequence of a voiced sound
% OUTPUT : p0 == fundamental pitch period
%          pw == the pitch wave
%          pb == perturbation of the pitch contour
%       gcidx == gci index for the segmental pc contour
%     seglens == the lengths of each segment
% See also: g_gci.

function [p0,pw,pb,gcidx,seglens]=pctour(gci);

  %
  % 1. segment the pitch contour by unvoiced region
  %

gcidx=gci;
pc=diff(gci);
nx=length(pc);
c=round( 0.5*pc(nx-1)+0.5*pc(nx) );
pc=[pc c];

c=mean(pc);
seglens=[]; % length of each segments

startp=1;
for ii=1:length(pc)
    if ( pc(ii) > 1.75*c )  % unvoiced region

       if (ii-startp)<1     % erratic case
          pc(startp:ii)=zeros(1,ii-startp+1);
       else
         seglens=[seglens ii-startp+1];
         pc(ii)=round( 0.5*pc(ii-2)+ 0.5*pc(ii-1) );
       end
       startp=ii+1;
    end
end
seglens=[seglens ii-startp+1];
pc=pc(pc~=0);
seglens=seglens(seglens~=0);

  %
  % 2. calculate the mean value of the pitch contour
  %

p0=mean(pc);
  % if there is only one output argument, return
  if nargout<2
    return;
  end

  %
  % 3. segment and smooth the pitch wave by unvoiced region
  %

NR=length(seglens);  % number of segments
startp=1;
for kf=1:NR
   endp=seglens(kf)+startp-1;
   pc1=pc( startp : endp );
   pc1=pc1-p0;
   pp1=medfilt(pc1,5);
   pp1=medfilt(pp1,5);
   pw(startp: endp)=pp1;
   startp=endp+1;
end

   %
   % 4. calculate the perturbation %
   %
jitter=(pc-pw-p0)/p0;
pb=std(jitter);

⌨️ 快捷键说明

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