⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 speechproc.m

📁 滤波器的设计以及零极点对应频率响应分析
💻 M
字号:
%function speechproc()
FL=80; %帧长
FL_v=2*FL;
WL=240;%窗长
P=10; % the number of lpc components
%s=wavread('D:\zr\matlab\corpus\F17A2.WAV');% load speech s
s=is';
L=length(s);% the speech length
FN=floor(L/FL)-2; % the number of frame
exc=zeros(L,1); % the error of lpc
zi_pre=zeros(P,1); % the filter
s_rec=zeros(L,1); % reconstruct 
zi_rec=zeros(P,1);
 %************* synthesize filter ******************
exc_syn=zeros(L,1); % synthesize impulse signal
s_syn=zeros(L,1); % synthesize speech

%***************** change tone and unchange speed ********

exc_syn_t=zeros(L,1); % synthesize impulse
s_syn_t=zeros(L,1); %  synthesize speech

%*********** change speed (slow) and unchange tone ******

exc_syn_v=zeros(2*L,1); % synthesize impulse
s_syn_v=zeros(2*L,1); % synthesize speech

%******** processing the each frame signal **********
hw=hamming(WL); % hamming windows
for n=3:FN
s_w=s((n*FL-WL+1):n*FL).*hw;
[a e]=lpc(s_w,P);

if n==27
%****** the zeros and poles of system
%t=linspace(0,length(s_w)-1,length(s_w));
%impulse(1,a,s_w);
%[g, p, k]=residue(1,a);
%*****************
end
s_f=s((n-1)*FL+1:n*FL);% the frame that we want processing

exc((n-1)*FL+1:n*FL)=filter(a,1,s_f);% the s_f as the imput, the e(n) as the out put, exc is the impulse

s_rec((n-1)*FL+1:n*FL)=filter(1,a,exc((n-1)*FL+1:n*FL)); % the exc as the imput,the reconstruct speech as the output

s_Pitch=exc(n*FL-222:n*FL);
%***** synthesize the impulse*****
PT=findpitch(s_Pitch); % get the periods of speech
pt(n-2)=PT;
G=sqrt(e*PT); % compute the power of impulse 
sf=8000; % the sample frequence
SL=length(s_Pitch);
tmp=SL/sf;
tim=linspace(0,tmp-tmp/SL,SL);
exc_syn((n-1)*FL+1:n*FL)=G*(rem(tim(1:FL),PT)==0);% the synthesize impulse
s_syn((n-1)*FL+1:n*FL)=filter(1,a,exc_syn((n-1)*FL+1:n*FL));% the synthesize speech
%*********** change the length of impulse and synthesize the speech that
%various the speed and unvarious the pitch

exc_syn_v((n-1)*FL_v+1:n*FL_v)= G*(rem(tim(1:FL_v),0.5*PT)==0); % the changed impulse;
s_syn_v((n-1)*FL+1:n*FL)= filter(1,a,exc_syn_v((n-1)*FL+1:n*FL));% the synthesized speech


%******** change the period to half and formant add to 150HZ to synthesize
%speech

end
%writespeech('D:\zr\matlab\corpus\exc.WAV',exc);
%writespeech('D:\zr\matlab\corpus\s_rec.WAV',s_rec);
%writespeech('D:\zr\matlab\corpus\exc_syn.WAV',exc_syn);
%writespeech('D:\zr\matlab\corpus\syn.WAV',s_syn);
%writespeech('D:\zr\matlab\corpus\exc_syn_v.WAV',exc_syn_v);
%writespeech('D:\zr\matlab\corpus\syn_v.WAV',s_syn_v);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -