热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

语音端点检测matlab论文,基于MATLAB的语音端点检测

求助,哪位高手帮忙看看以下程序全不?基于Matlab编写的语音端点检测程序function[x1,x2]vad(x)%幅度归一化到[-1,1]xdouble(x);xxmax(ab

求助,哪位高手帮忙看看以下程序全不?

基于Matlab编写的语音端点检测程序

function [x1,x2] = vad(x)

%幅度归一化到[-1,1]

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 &#61; (tmp1.*tmp2)<0;

diffs &#61; (tmp1 -tmp2)>0.02;

zcr   &#61; sum(signs.*diffs, 2);

%计算短时能量

amp &#61; sum(abs(enframe(filter([1 -0.9375], 1, x), FrameLen, FrameInc)), 2);

%调整能量门限

amp1 &#61; min(amp1, max(amp)/4);

amp2 &#61; min(amp2, max(amp)/8);

%开始端点检测

x1 &#61; 0;

x2 &#61; 0;

for n&#61;1:length(zcr)

goto &#61; 0;

switch status

case {0,1}                   % 0 &#61; 静音, 1 &#61; 可能开始

if amp(n) > amp1          % 确信进入语音段

x1 &#61; max(n-count-1,1);

status  &#61; 2;

silence &#61; 0;

count   &#61; count &#43; 1;

elseif amp(n) > amp2 | ... % 可能处于语音段

zcr(n) > zcr2

status &#61; 1;

count  &#61; count &#43; 1;

else                       % 静音状态

status  &#61; 0;

count   &#61; 0;

end

case 2,                       % 2 &#61; 语音段

if amp(n) > amp2 | ...     % 保持在语音段

zcr(n) > zcr2

count &#61; count &#43; 1;

else                       % 语音将结束

silence &#61; silence&#43;1;

if silence

count  &#61; count &#43; 1;

elseif count

status  &#61; 0;

silence &#61; 0;

count   &#61; 0;

else                    % 语音结束

status  &#61; 3;

end

end

case 3,

break;

end

end

count &#61; count-silence/2;

x2 &#61; x1 &#43; count -1;

subplot(311)

plot(x)

axis([1 length(x) -1 1])

ylabel(&#39;Speech&#39;);

line([x1*FrameInc x1*FrameInc], [-1 1], &#39;Color&#39;, &#39;red&#39;);

line([x2*FrameInc x2*FrameInc], [-1 1], &#39;Color&#39;, &#39;red&#39;);

subplot(312)

plot(amp);

axis([1 length(amp) 0 max(amp)])

ylabel(&#39;Energy&#39;);

line([x1 x1], [min(amp),max(amp)], &#39;Color&#39;, &#39;red&#39;);

line([x2 x2], [min(amp),max(amp)], &#39;Color&#39;, &#39;red&#39;);

subplot(313)

plot(zcr);

axis([1 length(zcr) 0 max(zcr)])

ylabel(&#39;ZCR&#39;);

line([x1 x1], [min(zcr),max(zcr)], &#39;Color&#39;, &#39;red&#39;);

line([x2 x2], [min(zcr),max(zcr)], &#39;Color&#39;, &#39;red&#39;);

程序&#xff1a;

%读入语音文件

fin&#61;fopen(&#39;DR4_MLJHO_SX334.ADC&#39;,&#39;r&#39;);

x&#61;fread(fin,&#39;short&#39;);

fclose(fin);

%窗长

l&#61;300;

step&#61;100;

e_x&#61;frame(x,&#39;energy&#39;);

figure(1);

plot(e_x,&#39;LineWidth&#39;,2);

xlabel(&#39;时间t&#39;);

ylabel(&#39;贞输出&#39;);

s&#61;sort(e_x);

min_e&#61;s(ceil(5*step/64));

max_e&#61;s(length(s)-ceil(5*step/64));

%设置阈值

threshold&#61;min_e&#43;0.2*(max_e-min_e);

a&#61;e_x>threshold;

%门限检验

if((length(a)<15*64/step)|(max_e/min_e<1.3)),

disp(&#39;No speech found&#39;);

else

figure(2);

plot(a,&#39;LineWidth&#39;,2);

xlabel(&#39;时间 t&#39;);

ylabel(&#39;端点&#39;);

set(gca,&#39;ylim&#39;,[0 1.5]);

end

%frame.m

function[yy]&#61;frame(x,func,SAMP_FREQ,1,step)

[m,n]&#61;size(x);

if m>n

n&#61;m;

else

n&#61;n;

x&#61;x&#39;;

end

if nargin<3,SAMP_FREQ&#61;8000;end;

if nargin<4,l&#61;SAMP_FREQ/40;end;

if nargin<5,step&#61;1/2;end;

%贞的数目

num_frame&#61;ceil(n/step);

%补零

x(n&#43;1:n&#43;2*1)&#61;zeros(2*1,1);

i&#61;[0:step:num_frames*step]&#39;;

j&#61;i*ones(1,1);

i&#61;j&#43;ones(num_frames&#43;1,1)*[1:1];

y&#61;reshape(x(i),num_frames&#43;1,1)&#39;;

y&#61;(hanning(l)*ones(1,num_frames&#43;1)).*y;

for i&#61;1:num_frames

cmd&#61;sprintf(&#39;yy(:,i)&#61;%s(y(:,i));&#39;,func);

eval(cmd);

end

[本帖最后由 mooni 于 2009-4-8 13:38 编辑]

a70cbf5f56cb187f20fb09bae08ed3de.gif

2009-4-8 13:30 上传

点击文件名下载附件

2.39 KB, 下载次数: 12025

a70cbf5f56cb187f20fb09bae08ed3de.gif

2009-4-8 13:30 上传

点击文件名下载附件

1.08 KB, 下载次数: 8257



推荐阅读
author-avatar
bls6653474
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有