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

📄 end_point1.m

📁 自己写的MATLAB程序,用与端点检测的程序,很有用的哦~
💻 M
字号:
function [y] = end_point(x,l,step);
%END_POINT Estimates the end points to extract the speech-only section
%       Y=END_POINT(X,L,STEP) estimates the begin and end of the utterance 
%       and extracts the speech only section from the signal X.
%       The short-time processing uses a window size of L samples, and
%       a step size of STEP samples.
if isstr(x), 
  x=read(x);
end;
x=column(x);
if nargin < 2, l = 300; end 
if nargin < 3, step=ceil(l/3); end
e_x=(frame(x,'energy')); %祯
z_x=(frame(x,'zc'));     %过零点
subplot(311),plt(x);
subplot(312),plt(e_x);
s=sort(e_x);
min_e=s(ceil(5*step/64));
max_e=s(length(s)-ceil(5*step/64));
sz=sort(z_x);
min_z=sz(ceil(5*step/64));
max_z=sz(length(s)-ceil(5*step/64));
threshold_z=min_z+0.2*(max_z-min_z);
threshold=min_e+0.2*(max_e-min_e);
a=e_x>threshold;
if ((length(a) < 15*64/step) | (max_e/min_e < 1.3))%old is 1.3 
  disp('No speech found');
else
  subplot(313),plt(a), set(gca,'ylim',[0 1.5]);
  
  g=find(a>0);
  sp_ind=0;
  i=1;
  begin=g(i);
  while sp_ind<10*64/step,
    if g(i+1)-g(i) < 4*64/step
      sp_ind=sp_ind+1;
    else
      begin=g(i+1);
      sp_ind=0;
    end
    i=i+1;
  end

  sp_ind=0;
  i=length(g);
  finish=g(i);
  while sp_ind<10*64/step,%10--20?
    if g(i)-g(i-1) < 4*64/step %4---8?
      sp_ind=sp_ind+1;
    else
      finish=g(i-1);
      sp_ind=0;
    end
    i=i-1;
  end
overlap=l-step;

%从开始点回溯10-15帧
a_z=z_x>threshold_z;
for i=begin-10:begin
    if a_z(i)>0
        first=i;
        break;
    end
end
if(sum(a_z(begin-15:begin))>3)
    begin=first;
end

i=length(g);
finish=g(i);
b_z=z_x>threshold_z;
for i=finish:finish+10
    if b_z(i)>0
        last=i;
        break;
    end
end
if(sum(a_z(finish:finish+15))>3)
    finish=last;
end

%begin=max(1,(begin-1)*step);
%finish=min(finish*step+l,length(x));
subplot(311),
set(gca,'xlim',[0 length(x)+200]);
yy=axis;
yrange=[yy(3) yy(4)];
hold on,
plot([begin*overlap begin*overlap],yrange,'k-');%,'erase','none'); %old  k is w
plot([finish*overlap finish*overlap],yrange,'k-');%,'erase','none'); 
hold off
y=x(begin:finish);
end

⌨️ 快捷键说明

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