基于MATLAB的语音端点检测(3)
时间:2026-01-17
时间:2026-01-17
基于MATLAB的语音端点检测
elseif amp(n) > amp2 || zcr(n) > zcr2 % 可能处于语音段 status = 1;
count = count + 1;
else % 静音状态
status = 0;
count = 0;
end
case 2, % 2 = 语音段
if amp(n) > amp2 ||zcr(n) > zcr2 % 保持在语音段
count = count + 1;
else % 语音将结束
silence = silence+1;
if silence < minsilence % 静音还不够长,尚未结束 count = count + 1;
elseif count < minlen % 语音长度太短,认为是噪声 status = 0;
silence = 0;
count = 0;
else % 语音结束
status = 3;
end
end
case 3,
break;
end
end
count = count-silence/2;
x2 = x1 + count -1; %记录语音段结束点
subplot(3,1,1)
plot(x)
axis([1 length(x) -1 1])
ylabel('Speech');
line([x1*inc x1*inc], [-1 1], 'Color', 'red');
line([x2*inc x2*inc], [-1 1], 'Color', 'red');
subplot(3,1,2)
plot(amp);
axis([1 length(amp) 0 max(amp)])
ylabel('Energy');
line([x1 x1], [min(amp),max(amp)], 'Color', 'red');
line([x2 x2], [min(amp),max(amp)], 'Color', 'red');