当前位置:首页 > 大学本科语音信号处理实验讲义8学时(DOC)
frameSize=length(frame);
frame2=frame.*hamming(length(frame)); rwy=rceps(frame2);
cepstrum=rwy(1:ylen/2);
for i=1:ylen/2
cepstrum1(i)=rwy(ylen/2+1-i); end
for i=(ylen/2+1):ylen
cepstrum1(i)=rwy(i+1-ylen/2); end
%基音检测
LF=floor(fs/500); HF=floor(fs/70); cn=cepstrum(LF:HF); [mx_cep ind]=max(cn); if mx_cep>0.08 a=fs/(LF+ind); else a=0; end pitch=a
%画图
figure(1);
subplot(3,1,1); plot(time1,y); title('语音波形'); axis tight
ylim=get(gca,'ylim');
line([time1(startIndex),time1(startIndex)],ylim,'color','r'); line([time1(endIndex),time1(endIndex)],ylim,'color','r'); xlabel('样点数'); ylabel('幅度');
subplot(3,1,2); plot(frame);
axis([0,240,-0.5,0.5]) title('一帧语音'); xlabel('样点数'); ylabel('幅度');
17
subplot(3,1,3);
time2=[-119:1:-1,0:1:120]; plot(time2,cepstrum1); axis([-120,120,-0.5,0.5]) title('一帧语音的倒谱'); xlabel('样点数'); ylabel('幅度');
图4-1 对浊音信号进行基音检测
2、利用同态处理计算给出语音信号的共振峰。 [y,fs,nbits]=wavread('speech_dsp.wav'); time1=1:length(y); time=(1:length(y))/fs;
frameSize=floor(30*fs/1000); startIndex=round(2080);
endIndex=startIndex+frameSize-1; frame=y(startIndex:endIndex); %frameSize=length(frame);
frame2=frame.*hamming(length(frame)); rwy=rceps(frame2); ylen=length(rwy);
cepstrum=rwy(1:ylen/2);
%基音检测
LF=floor(fs/500); HF=floor(fs/70); cn=cepstrum(LF:HF); [mx_cep,ind]=max(cn);
%共振峰检测核心代码
18
%找到最大的突起的位置 NN=ind+LF;
ham=hamming(NN); cep=cepstrum(1:NN); ceps=cep.*ham;
%formant1=20*log(abs(fft(ceps))); formant1=abs(fft(ceps)); formant(1:2)=formant1(1:2); for t=3:NN
%do some median filtering z=formant1(t-2:t); md=median(z); formant2(t)=md; end
for t=1:NN-1 if t<=2
formant(t)=formant1(t); else
formant(t)=formant2(t-1)*0.25+formant2(t)*0.5+formant2(t+1)*0.25; end end
subplot(3,1,1) plot(cepstrum); title('倒谱'); xlabel('样点数'); ylabel('幅度');
axis([0,ylen/2,-0.5,0.5])
spectral=20*log10(abs(fft(frame2))); subplot(3,1,2);
xj=(0:(length(spectral)/2-1))*fs/length(spectral); plot(xj,spectral(1:length(spectral)/2)); title('频谱') xlabel('频率/Hz') ylabel('幅度/dB')
axis([0,fs/2,-100,50])
subplot(3,1,3);
xi=(0:(NN/2-1))*fs/NN; plot(xi,formant(1:NN/2)); title('平滑对数幅度谱'); xlabel('频率/Hz') ylabel('幅度/dB')
19
axis([0,fs/2,0,0.5])
图4-2 共振峰检测
四、思考题
1、什么是语音信号的同态处理?倒谱与复倒谱有什么区别? 2、在基音检测过程中,程序段 if mx_cep>0.08 a=fs/(LF+ind); else a=0; end
的作用是什么?
3、解释共振峰的含义。不同人发同音时共振峰相同吗?
20
共分享92篇相关文档