whole.m
资源名称:语音识别.rar [点击查看]
上传用户:doudz874
上传日期:2007-03-30
资源大小:792k
文件大小:2k
源码类别:
语音合成与识别
开发平台:
Matlab
- %read wave
- Fs=8000;
- mywave=wavrecord(2*Fs,Fs);
- wavplay(mywave,Fs);
- ave_wave=sum(mywave)/(2*Fs);
- end_wave=mywave-ave_wave;
- %E(i),Z(i),Z_opt(i)
- Z_cmp=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.4;
- E_low=0.2;
- Z_low=15;
- start1=1;
- end1=1;
- for i=2:Nframe
- if E(i)>E_high && E(i-1)<E_high
- start1=i;
- end
- if E(i)<E_high && E(i-1)>E_high
- end1=i;
- end
- %%%%%%%%%%%%%
- end
- i=start1;
- while E(i)>E_low && i>1
- i=i-1;
- end
- start2=i;
- i=end1;
- while E(i)>E_low && i<Nframe
- i=i+1;
- end
- end2=i;
- i=start2;
- while Z_opt(i)>Z_low && i>1
- i=i-1;
- end
- start3=i;
- %plot
- i=(start3-10)*80:(end2+10)*80;
- x1=start1;
- y1=-1:0.01:1;
- x2=end1;
- y=-1:0.01:1;
- %hold;
- figure;
- plot(i,end_wave(i));
- hold;
- plot(start3*80,y);
- plot(end2*80,y);
- hold off;
- for i=start3:end2
- [A,C]=lpc(end_wave((i-1)*80+1:(i-1)*80+160));
- ac=[A,C];
- model_test(i-start3+1,:)=ac;
- end
- %A(),C()
- %for i=start3:end2
- % [A,C]=lpc(end_wave((i-1)*80+1:(i-1)*80+160));
- % ac=[A,C];
- % filey(i-start3+1,:)=ac;
- %end %fid = fopen('exp.txt','w');
- %fprintf(fid,'%6.8f b%6.8fn',filey);
- %fclose(fid);