之前参考了网上的资料,参考了别人的写法之后,自己整理出来的版本。
一个主程式+一个端点侦测函数,自己整理的版本和网上的版本比较,多出来的功能是用一个for,连贯的把句子的每个音节切出来,存入数组。
主程式:
global wav_file;
global x1;
global x2;
wav_file = 'sunday.wav'; % input audio filename
inc=90;
start=[]; %阵列存声音开端
finish=[]; %阵列存声音尾端
% Read speech samples, sampling rate and precision from file
[ speech, fs, nbits ] = wavread( wav_file );
%%%%%%%%%%%%%%%%%%%%%%%%%%端点侦测开始%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
x3=1;
for i=1:length(speech)
if(length(speech)-(x3*inc)<6000) %此段语音长度小于6000的时候就视为已经没有音节存在,跳出
break;
end
[speech1,fs]=wavread(wav_file,[x3*inc,length(speech)]);
[x1 ,x2]=vad(speech1);
figure
start=[start,x1+x3]; %开端存入阵列