Matlab语音信号处理程序-f11.m
可以对语音信号的单个字,词进行频率及过零率分析
clc
[filename,pathname]=uigetfile;
[x,Fs]=wavread;
%幅度归一化到[-1,1]
x = double;
x = x / max);
%常数设置
FrameLen = 240;
FrameInc = 80;
amp1 = 10;
amp2 = 2;
zcr1 = 10;
zcr2 = 5;
maxsilence = 3; % 6*10ms = 30ms
minlen = 15; % 15*10ms = 150ms
status = 0;
count = 0;
silence = 0;
%计算过零率
tmp1 = enframe, FrameLen, FrameInc);
tmp2 = enframe , FrameLen, FrameInc);
signs = 0.02;
zcr = sum;
%计算短时能量
amp = sum, FrameLen, FrameInc)), 2);
%调整能量门限
amp1 = min/4);
amp2 = min/8);
%开始端点检测
x1 = 0;
x2 = 0;
x3=0;
x4=0;
for n=1:length
goto = 0;
switch status
case {0,1} % 0 = 静音, 1 = 可能开始
if amp > amp1 % 确信进入语音段
x1 = max;
status = 2;
silence = 0;
count = count 1;
elseif amp > amp2 | ... % 可能处于语音段
zcr > zcr2
status = 1;
count = count 1;
else % 静音状态
status = 0;
count = 0;
end
case 2, % 2 = 语音段
if amp > amp2 | ... % 保持在语音段
zcr > zcr2
count = count 1;
else % 语音将结束
silence = silence 1;
if silence < maxsilence % 静音还不够长,尚未结束
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
plot
axis -1 1])
ylabel;
line;
line;
subplot
plot;
axis 0 max])
ylabel;
line,max], 'Color', 'red');
line,max], 'Color', 'red');
subplot
plot;
axis 0 max])
ylabel;
line,max], 'Color', 'red');
line,max], 'Color', 'red');
复制代码
2022-03-30 21:15:37
2KB
matlab
1