setmodel.m
资源名称:语音识别.rar [点击查看]
上传用户:doudz874
上传日期:2007-03-30
资源大小:792k
文件大小:2k
源码类别:
语音合成与识别
开发平台:
Matlab
- Fs=8000;
- mywave=wavrecord(2*Fs,Fs);
- wavplay(mywave,Fs);
- %ave_wave=sum(mywave)/(2*Fs);
- end_wave=mywave-mean(mywave);
- %E(i),Z(i),Z_opt(i)
- Z_cmp=3*mean(abs(end_wave(100:500)));%0.02;
- Nframe=2*Fs/80-1;
- for i=1:Nframe;
- E(i)=(end_wave((i-1)*80+1))^2;
- Z(i)=0;
- Z_opt(i)=0;
- for j=2:160
- E(i)=E(i)+end_wave((i-1)*80+j)^2;
- Z(i)=Z(i)+abs(sign(end_wave((i-1)*80+j))-sign(end_wave((i-1)*80+j-1)));
- Z_opt(i)=Z_opt(i)+abs(sign(end_wave((i-1)*80+j)-Z_cmp)-sign(end_wave((i-1)*80+j-1)-Z_cmp));
- end
- Z(i)=Z(i)/2;
- Z_opt(i)= Z_opt(i)/2;
- end
- %start and end
- E_high= 0.3;
- E_low=20*mean(E(3:20));%%%%%%%%%0.2;
- Z_low=2*mean(Z_opt(1:10));%%%%%%%%%%%15;
- start=1;
- end0=1;
- for i=2:Nframe
- if E(i)>E_high && E(i-1)<E_high
- start=i;
- end
- if E(i)<E_high && E(i-1)>E_high
- end0=i;
- end
- if end0-start>15
- start1=start;
- end1=end0;
- end
- %%%%%%%%%%%%%
- end
- i=start1;
- while E(i)>E_low && i>1
- i=i-1;
- end
- start2=i+1;
- i=end1;
- while E(i)>E_low && i<Nframe
- i=i+1;
- end
- end2=i-1;
- i=start2;
- while Z_opt(i)>Z_low && i>1
- i=i-1;
- end
- start3=i+1;
- %plot
- %i=1:Fs*2;%%%%%%%%
- i=(start3-10)*80:(end2+10)*80;
- y=-1:0.01:1;
- figure(1);
- plot(i,end_wave(i));
- hold;
- plot(start3*80,y);
- plot(end2*80+160,y);
- hold off;
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%lpc%%%%%%%
- model=zeros(end2-start3+1,44);
- for i=start3:end2
- [A,C,F]=lpc(end_wave((i-1)*80+1:(i-1)*80+160));
- acf=[A,C,F];
- model(i-start3+1,:)=acf;
- end