语音信号处理实验报告.docx
- 文档编号:11749617
- 上传时间:2023-03-31
- 格式:DOCX
- 页数:15
- 大小:198.51KB
语音信号处理实验报告.docx
《语音信号处理实验报告.docx》由会员分享,可在线阅读,更多相关《语音信号处理实验报告.docx(15页珍藏版)》请在冰豆网上搜索。
语音信号处理实验报告
语音信号处理实验报告
【实验一】
一、实验题目
Shorttimeanalysis
二、实验要求
WriteaMATLABprogramtoanalyzeaspeechandsimultaneously,onasinglepage,plotthefollowingmeasurements:
1.theentirespeechwaveform
2.theshort-timeenergy,En
3.theshort-timemagnitude,Mn
4.theshort-timezero-crossing,Zn
5.thenarrowbandspectrogram
6.thewidebandspectrogram
Useboththespeechwaveformsinthewznjdx_normal.wav.Chooseappropriatewindowsizes,windowshifts,andwindowfortheanalysis.Explainyourchoiceoftheseparameters.
三、实验程序
clear
[x,fs]=wavread('wznjdx_normal.wav');
n=length(x);
N=320;
subplot(4,1,1);plot(x);
h=linspace(1,1,N);
En=conv(h,x.*x);
subplot(4,1,2);plot(En);
Mn=conv(h,abs(x));
subplot(4,1,3);plot(Mn);
fori=1:
n-1
ifx(i)>=0y(i)=1;
elsey(i)=-1;
end
ifx(i+1)>=0y(i+1)=1;
elsey(i+1)=-1;
end
w(i)=abs(y(i+1)-y(i));
end
k=1;
j=0;
while(k+N-1) Zm(k)=0; fori=0: N-1 Zm(k)=Zm(k)+w(k+i); end j=j+1; k=k+N/2; end forw=1: j Q(w)=Zm(160*(w-1)+1)/(2*N); end subplot(4,1,4);plot(Q);grid; figure (2); subplot(2,1,1);spectrogram(x,h,256,200,0.0424*fs); subplot(2,1,2);spectrogram(x,h,256,200,0.0064*fs); 四、实验结果 语谱图: (Matlab7.0用不了spectrogram) 【实验二】 一、实验题目 Homomorphicanalysis 二、实验要求 WriteaMATLABprogramtocomputetherealcepstrumsofasectionofvoicedspeechandunvoicedspeech. Plotthesignal,thelogmagnitudespectrum,therealcepstrum,andthelowpasslifteredlogmagnitudespectrum. 三、实验程序 nfft=256; [x,fs]=wavread('wznjdx_normal.wav'); fx=x; Xvm=log(abs(fft(fx,nfft))); xhv=real(ifft(Xvm,nfft)); lifter=zeros(1,nfft); lifter(1: 30)=1; lifter(nfft-28: nfft)=1; fnlen=0.02*fs;%20ms win=hamming(fnlen);%加窗 n=fnlen;%窗宽度赋给循环自变量n noverlap=0.5*fnlen; while(n<=length(x)-1) fx=x(n-fnlen+1: n).*win; n=n+noverlap; end xhvp=xhv.*lifter'; figure; subplot(4,1,1) plot(lifter); title('倒谱滤波器'); subplot(4,1,2) plot(x); title('语音信号波形'); subplot(4,1,3) plot(Xvm); title('Xvm'); subplot(4,1,4) plot(xhv); title('xhv'); 四、实验结果 【实验三】 一、实验题目 LPanalysis 二、实验要求 WriteaMATLABprogramtoconvertfromaframeofspeechtoasetoflinearpredictioncoefficients.PlottheLPCspectrumsuperimposedonthecorrespondingSTFT. 三、实验程序 clear; [x,fs]=wavread('wznjdx_normal.wav'); fx=x(4000: 4160-1); p=10; [a,e,k]=aryule(fx,p); G=sqrt(e*length(fx)); f=log(abs(fft(fx))); h0=zeros(1,160); h=log(G)-log(abs(fft(a,160))); figure (1); subplot(211);plot(fx); subplot(212);plot(f); holdon; plot((0: 160-1),h,'r'); 四、实验结果 【实验四】 一、实验题目 Pitchestimation 二、实验内容 Writeaprogramtoimplementthepitchestimationandthevoiced/unvoiceddecisionusingtheLPC-basedmethod. 三、实验程序 clear [x,fs]=wavread('wznjdx_normal.wav'); n=length(x); Q=x'; NFFT=512; N=256; Hamm=hamming(N); frame=30; M=Q(((frame-1)*(N/2)+1): ((frame-1)*(N/2)+N)); Frame=M.*Hamm'; %lowpassfilter [b2,a2]=butter(2,900/4000); speech2=filter(b2,a2,Frame);%filter %residual [a,e]=lpc(speech2,20); errorlp=filter(a,1,speech2);%residual %Short-termautocorrelation. re=xcorr(errorlp); %Findmaxautocorrelationforlagsintheintervalminlagtomaxlag. minlag=17;%F0: 450Hz maxlag=160;%F0: 50Hz fnlen=256; [remax,idx]=max(re(fnlen+minlag: fnlen+maxlag)); figure subplot(3,1,1);plot(Frame); subplot(3,1,2);plot(speech2); subplot(3,1,3);plot(re);text(500,0,'idx'); idx=idx-1+minlag remax 四、实验结果 【实验五】 一、实验题目 Speechsynthesis 二、实验内容 WriteaprogramtoanalyzeaspeechandsynthesizeitusingtheLPC-basedmethod. 三、实验程序 主程序 clear; [x,sr]=wavread('wznjdx_normal.wav'); p=[1-0.9]; x=filter(p,1,x); N=256; inc=128; y=lpcsyn(x,N,inc); wavplay(y,sr); 子程序lpcsyn functiony=lpcsyn(x,N,inc) %[x,sr]=wavread('wznjdx_normal.wav'); %pre=[1-0.97]; %x=filter(pre,1,x); %N=256; %inc=128; fn=floor(length(x)/inc); y=zeros(1,50000); for(i=1: fn) order=16; x(1: N,i)=x((i-1)*inc+1: (i+1)*inc); [A(i,: ),G(i),P(i),fnlen,fnshift]=lpcana(x(1: N,i),order); if(P(i))%Voicedframe. e=zeros(N,1); e(1: P(i): N)=1;%Impulse-trainexcitation. else%Unvoicedframe. e=randn(N,1);%Whitenoiseexcitation. end yt=filter(G(i),A(i,: ),e); j=(i-1)*inc+[1: N]; y(j)=y(j)+yt'; end; end 子程序lpcana function[A,G,P,fnlen,fnshift]=lpcana(x,order) fnlen=256; fnshift=fnlen/2; n=length(x); [b2,a2]=butter(2,900/4000); speech2=filter(b2,a2,x); [A,e]=lpc(speech2,order); errorlp=filter(A,1,speech2); re=xcorr(errorlp); G=sqrt(e*length(speech2)); minlag=17; maxlag=160; [remax,idx]=max(re(n+minlag: n+maxlag)); P=idx-1+minlag; end 四、实验结果 【实验六】 一、实验题目 Speechenhancement 二、实验内容 Writeaprogramtoimplementthebasicspectralmagnitudesubtraction. 三、实验程序 clear [speech,fs,nbits]=wavread('wznjdx_normal.wav');%读入数据 alpha=0.04;%噪声水平 winsize=256;%窗长 size=length(speech);%语音长度 numofwin=floor(size/winsize);%帧数 hamwin=zeros(1,size);%定义汉明窗长度 enhanced=zeros(1,size);%定义增强语音的长度 ham=hamming(winsize)';%%产生汉明窗 x=speech'+alpha*randn(1,size);%信号加噪声 noisy=alpha*randn(1,winsize);%噪声估计 N=fft(noisy); nmag=abs(N);%噪声功率谱 %分帧 forq=1: 2*numofwin-1 frame=x(1+(q-1)*winsize/2: winsize+(q-1)*winsize/2);%对带噪语音帧间重叠一半取值 hamwin(1+(q-1)*winsize/2: winsize+(q-1)*winsize/2)=... hamwin(1+(q-1)*winsize/2: winsize+(q-1)*winsize/2)+ham;%加窗 y=fft(frame.*ham); mag=abs(y);%带噪语音功率谱 phase=angle(y);%带噪语音相位 %幅度谱减 fori=1: winsize ifmag(i)-nmag(i)>0 clean(i)=mag(i)-nmag(i); elseclean(i)=0; end end %频域中重新合成语音 spectral=clean.*exp(j*phase); %反傅里叶变换并重叠相加 enhanced(1+(q-1)*winsize/2: winsize+(q-1)*winsize/2)=... enhanced(1+(q-1)*winsize/2: winsize+(q-1)*winsize/2)+real(ifft(spectral)); end figure (1); subplot(3,1,1);plot(speech);xlabel('样点数');ylabel('幅度');title('原始语音波形'); subplot(3,1,2);plot(x);xlabel('样点数');ylabel('幅度');title('语音加噪波形'); subplot(3,1,3);plot(enhanced);xlabel('样点数');ylabel('幅度');title('增强语音波形'); 四、实验结果
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 语音 信号 处理 实验 报告
![提示](https://static.bdocx.com/images/bang_tan.gif)