数字语音处理B第二次实验

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

数字语音处理B2016–2017学年第2学期电信1405龙为花第二次实验一、实验目的1.掌握短时傅里叶变换的定义,并理解其两种解释2.理解窗函数对短时傅里叶谱的影响,并能根据需要选择适当的窗函数3.理解同态信号处理的原理4.掌握倒谱的定义及计算方法5.对以上各项能用Matlab代码实现,并能画出相应谱图二、实验内容1.画出ah第20帧单帧语音时域图,窗长20ms,帧移10ms,同时加矩形窗和hamming窗分帧函数:function[frameSet,timeAxis,frameCount]=enframe(data,fs,timeperFrame,overlapRate,winF)winfunc=str2func(winF);ndata=length(data(:));frameLength=fs*timeperFrame*0.001;nframeLength=length(winfunc(frameLength));%取窗长overlap=frameLength*overlapRate;inc=frameLength-overlap;if(nframeLength==1)len=frameLength;elselen=nframeLength;endframeCount=fix((ndata-overlap)/inc);%计算帧数frameSet=zeros(len,frameCount);startIndexf=(0:(frameCount-1))*inc;%每帧在数据data中开始的位置startIndexs=(1:len);startIndexsT=startIndexs(:);frameSet(:)=data(startIndexsT(:,ones(frameCount,1))+startIndexf(ones(1,len),:));w=winfunc(frameLength);if(nframeLength1)frameSet=frameSet.*w(:,ones(frameCount,1));endtimeAxis=(((1:frameCount)-1)*inc+frameLength/2)/fs;%求出每帧对应的时间主函数:clcclearallcloseall%----------------------------------------loadah;x1=enframe(data,fs,20,0.5,'boxcar');x2=enframe(data,fs,20,0.5,'hamming');plot(x1(:,20),'g','LineWidth',2);holdon;plot(x2(:,20),'b','LineWidth',2);legend('矩形窗信号','汉明窗信号');xlabel('时间(采样点数)');ylabel('幅度');suptitle('电信1405龙为花0121409341029')图1:语音ah第20帧时域波形图与加hammming窗10k采样2.语音单帧频谱图clcclearallcloseall%----------------------------------------loadah;fs=10000;x2=enframe(data,fs,20,0.5,'boxcar');x1=enframe(data,fs,20,0.5,'hamming');u1=x1(:,20);%取得一帧数据u2=x2(:,20);N=1024;t=(0:N-1)/fs;y1=20*log10(fft(u1,N));y2=20*log10(fft(u2,N));f=(0:511)*fs/1024;figure(1);xlabel('Hz');ylabel('db');plot(f,y1(1:512),'r','LineWidth',1);%做原始语音信号的FFT频谱legend('汉明窗的频谱');figure(2);plot(f,y2(1:512),'b','LineWidth',1);xlabel('Hz');ylabel('db');legend('矩形窗的频谱');suptitle('电信1405龙为花0121409341029')图2:ah第20帧单帧语音频谱图,窗长20ms,帧移10ms,矩形窗和hamming窗,10k采样3.语音频域功率谱图clcclearallcloseall%----------------------------------------loadah;fs=10000;x2=enframe(data,fs,20,0.5,'boxcar');x1=enframe(data,fs,20,0.5,'hamming');u1=x1(:,20);%取得一帧数据u2=x2(:,20);N=1024;t=(0:N-1)/fs;y1=20*log10(fft(u1,N));y2=20*log10(fft(u1,N).^2);f=(0:511)*fs/1024;figure(1);plot(f,y1(1:512),'b','LineWidth',1.5);%做原始语音信号的频谱holdon;plot(f,y2(1:512),'r','LineWidth',1.5);%做原始语音信号的功率谱xlabel('Hz');ylabel('db');suptitle('电信1405龙为花0121409341029')legend('汉明窗的频谱','汉明窗功率谱');z1=20*log10(fft(u2,N));z2=20*log10(fft(u2,N).^2);figure(2);plot(f,z1(1:512),'b','LineWidth',1);%做原始语音信号的频谱holdon;plot(f,z2(1:512),'r','LineWidth',1);%做原始语音信号的功率谱xlabel('Hz');ylabel('db');suptitle('电信1405龙为花0121409341029')legend('矩形窗的频谱','矩形窗功率谱');图3:Ah第20帧时域波形图,10k采样,帧长20ms,hamming窗图4:Ah第20帧时域波形图,10k采样,帧长20ms,矩形窗4.语谱图(1)clcclearcloseall[x,fs]=audioread('E:\1.wav');m1=42230;m2=138000;x=x(m1:m2);win=0.01;inc=win/2;winlen=win.*fs;inclen=inc.*fs;amp1=enframe(filter([1-0.9375],1,x),hamming(winlen),inclen)';n=fix((length(x)-winlen+inclen)/inclen);w=winlen/2+1;n2=1:w;freq=(n2-1)*fs/winlen;Y=fft(amp1);Yn=Y(n2,:);clf;frameTime=(1:n)*inclen;imagesc(frameTime,freq,20*log10(abs(Yn)+eps));axisxy;xlabel('时间/s)');ylabel('频率/Hz');colormap(jet);suptitle('电信1405龙为花0121409341029')图5:语音WHUT语谱图,10k采样(2)clcclearcloseall[x,fs]=audioread('E:\1.wav');m1=42230;m2=138000;x=x(m1:m2);win=0.04;inc=win/2;winlen=win.*fs;inclen=inc.*fs;amp1=enframe(filter([1-0.9375],1,x),hamming(winlen),inclen)';n=fix((length(x)-winlen+inclen)/inclen);w=winlen/2+1;n2=1:w;freq=(n2-1)*fs/winlen;Y=fft(amp1);Yn=Y(n2,:);clf;frameTime=(1:n)*inclen;imagesc(frameTime,freq,20*log10(abs(Yn)+eps));axisxy;xlabel('时间/s');ylabel('频率/Hz');colormap(jet);suptitle('电信1405龙为花0121409341029')图64.2(1)clcclearcloseallload('should.mat');fs=10000;win=0.01;inc=win/2;winlen=win.*fs;inclen=inc.*fs;amp1=enframe(filter([1-0.9375],1,data),hamming(winlen),inclen)';n=fix((length(data)-winlen+inclen)/inclen);w=winlen/2+1;n2=1:w;freq=(n2-1)*fs/winlen;Y=fft(amp1);Yn=Y(n2,:);clf;frameTime=(1:n)*inclen;imagesc(frameTime,freq,20*log10(abs(Yn)+eps));axisxy;xlabel('时间/s');ylabel('频率/Hz');colormap(jet);suptitle('电信1405龙为花0121409341029')图7(2)clcclearcloseallload('should.mat');fs=10000;win=0.04;inc=win/2;winlen=win.*fs;inclen=inc.*fs;amp1=enframe(filter([1-0.9375],1,data),hamming(winlen),inclen)';n=fix((length(data)-winlen+inclen)/inclen);w=winlen/2+1;n2=1:w;freq=(n2-1)*fs/winlen;Y=fft(amp1);Yn=Y(n2,:);clf;frameTime=(1:n)*inclen;imagesc(frameTime,freq,20*log10(abs(Yn)+eps));axisxy;xlabel('时间/s');ylabel('频率/Hz');colormap(jet);suptitle('电信1405龙为花0121409341029')图85.语音倒谱图clcclearallcloseall%----------------------------------------loadah;fs=10000;x2=enframe(data,fs,40,0.5,'boxcar');x1=enframe(data,fs,40,0.5,'hamming');u1=x1(:,15);%取得一帧数据u2=x2(:,15);y1=rceps(u1);y2=rceps(u2);figure(1);xlabel('Hz');ylabel('幅度');plot(y1,'r');%做原始语音信号的FFT频谱holdon;plot(u1);legend('汉明窗的倒谱','汉明窗的时域');figure(2);plot(y2,'b');holdon;plot(u2);suptitle('电信1405龙为花0121409341029')xlabel('Hz');ylabel('幅度');suptitle('电信1405龙为花0121409341029')legend('矩形窗的倒谱','矩形窗的时域');图9:语音ah第15帧单帧语音倒谱图,hamming窗图10:语音ah第15帧单帧语音倒谱图,矩形窗

1 / 13
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功