资源简介
端点检测matlab程序,用于检测语音信号的起点和终点。分帧和预加重。
代码片段和文件信息
[xfswmodefidx]=readwav(‘8_.wav‘‘r‘);
voice_len=length(x);
x = double(x);
x = x / max(abs(x));
%常数设置
frameLen = 240;
frameInc = 80;
amp1 = 10;
amp2 = 2;
zcr1 = 10;
zcr2 = 5;
maxsilence = 8; % 6*10ms = 30ms
minlen = 15; % 15*10ms = 150ms
status = 0;
count = 0;
silence = 0;
%计算过零率
tmp1 = enframe(x(1:end-1) frameLen frameInc);
tmp2 = enframe(x(2:end) frameLen frameInc);
signs = (tmp1.*tmp2)<0;
diffs = (tmp1 -tmp2)>0.02;
zcr = sum(signs.*diffs 2);
%计算短时能量
amp = sum(abs(enframe(filter([1 -0.9375] 1 x) frameLen frameInc)) 2);
%调整能量门限
amp1 = min(amp1 max(amp)/4);
amp2 = min(amp2 max(amp)/8);
%开始端点检测
x1 = 0;
x2 = 0;
for n=1:length(zcr)
goto = 0;
switch status
case {01} % 0 = 静音 1 = 可能开始
if amp(n) > amp1 % 确信进入语音段
x1 = max(n-count-11);
status = 2;
silence = 0;
count = count + 1;
elseif amp(n) > amp2 | ... % 可能处于语音段
zcr(n) > zcr2
status = 1;
count = count + 1;
else % 静音状态
status = 0;
count = 0;
- 上一篇:B样条图形绘制matlab
- 下一篇:定位峰值点的matlab程序
评论
共有 条评论