1 简介
语音信号端点检测是语音信号的预处理,正确的语音信号端点检测结果直接影响语音识别等后续工作的运算量和准确率.本文介绍了时域方法中基于短时能量的语音信号端点检测方法,并用三种不同的短时能量计算方式和五种短时能量闲值进行了端点检测实验.
2 完整代码
clear all; clc; close all;
filedir=[];                % 设置路径
filename='s.wav';   % 设置文件名
fle=[filedir filename];    % 构成完整的路径和文件名
[x,Fs]=audioread(fle);     % 读入数据文件
wlen=200; inc=80;          % 给出帧长和帧移
win=hanning(wlen);         % 给出海宁窗
N=length(x);               % 信号长度
X=enframe(x,win,inc)';     % 分帧
fn=size(X,2);              % 求出帧数。size函数里选择1时是返回行数,2是返回列数
time=(0:N-1)/Fs;           % 计算出信号的时间刻度
for i=1 : fn
    u=X(:,i);              % 取出一帧
    u2=u.*u;               % 求出能量
    En(i)=sum(u2);         % 对一帧累加求和
end
subplot 211; plot(time,x,'k'); % 画出时间波形 
title('语音波形');
ylabel('幅值'); xlabel(['时间/s' 10 '(a)']);
frameTime=frame2time(fn,wlen,inc,Fs);   % 求出每帧对应的时间
subplot 212; plot(frameTime,En,'k')     % 画出短时能量图
title('短时能量');
 ylabel('幅值'); xlabel(['时间/s' 10 '(b)']);function frameTime=frame2time(frameNum,framelen,inc,fs)
% ================= 计算分帧后每一帧对应的时间=====================
% ================= 输     入 ===================================
%frameNum          :  总帧数
%framelen          : 帧长
%inc               :  帧移
%fs                : 采样频率
%================== 输     出 ====================================
%frametime         : 每帧的时间,即取这一帧数据中间位置的时间
frameTime=(((1:frameNum)-1)*inc+framelen/2)/fs;function f=enframe(x,win,inc) 
%ENFRAME split signal up into (overlapping) frames: one per row. F=(X,WIN,INC) 
% 
%  F = ENFRAME(X,LEN) splits the vector X up into 
%  frames. Each frame is of length LEN and occupies 
%  one row of the output matrix. The last few frames of X 
%  will be ignored if its length is not divisible by LEN. 
%  It is an error if X is shorter than LEN. 
% 
%  F = ENFRAME(X,LEN,INC) has frames beginning at increments of INC 
%  The centre of frame I is X((I-1)*INC+(LEN+1)/2) for I=1,2,... 
%  The number of frames is fix((length(X)-LEN+INC)/INC) 
% 
%  F = ENFRAME(X,WINDOW) or ENFRAME(X,WINDOW,INC) multiplies 
%  each frame by WINDOW(:) 
%     Copyright (C) Mike Brookes 1997 
%      Version: $Id: enframe.m,v 1.3 2005/02/21 15:22:12 dmb Exp $ 
% 
%   VOICEBOX is a MATLAB toolbox for speech processing. 
%   Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 
% 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%   This program is free software; you can redistribute it and/or modify 
%   it under the terms of the GNU General Public License as published by 
%   the Free Software Foundation; either version 2 of the License, or 
%   (at your option) any later version. 
% 
%   This program is distributed in the hope that it will be useful, 
%   but WITHOUT ANY WARRANTY; without even the implied warranty of 
%   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
%   GNU General Public License for more details. 
% 
%   You can obtain a copy of the GNU General Public License from 
%   ftp://prep.ai.mit.edu/pub/gnu/COPYING-2.0 or by writing to 
%   Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
nx=length(x); 
nwin=length(win); 
if (nwin == 1) 
   len = win; 
else 
   len = nwin; 
end 
if (nargin < 3) 
   inc = len; 
end 
nf = fix((nx-len+inc)/inc); 
f=zeros(nf,len); 
indf= inc*(0:(nf-1)).'; 
inds = (1:len); 
f(:) = x(indf(:,ones(1,len))+inds(ones(nf,1),:)); 
if (nwin > 1) 
    w = win(:)'; 
    f = f .* w(ones(nf,1),:); 
end3 仿真结果

4 参考文献
[1]董梅, 廖云霞, 刘海山,等. 基于Matlab的语音信号特征提取系统的设计[J]. 电脑知识与技术:学术版, 2018(7Z):4.
博主简介:擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,相关matlab代码问题可私信交流。
部分理论引用网络文献,若有侵权联系博主删除。











