基于matlab语音信号数学模型
clc clear all close all T1=5; %5ms T2=3; %3ms fs=8; %8kHz N1=T1*fs; N2=T2*fs; n1=1:N1-1; n2=N1:N1+N2; g=zeros(1,20*fs); t=(1:20*fs)/fs; g(1:N1-1)=0.5*(1-cos(pi*n1/N1)); g(N1:N1+N2)=cos(pi*(n2-N1)/(2*N2)); plot(t,g) ylim([-0.4,1.2]) line([0 20],[0 0]) line([5 5],[0 1],'LineStyle','--') xlabel('时间/ms') ylabel('g(n)') title('(a)时域波形') figure N=length(g); f=(0:N-1)*fs/N; fftg=fft(g); disg=20*log10(abs(fftg)); plot(f(1:N/2+1),disg(1:N/2+1)) line([0 fs/2],[0 0]) xlabel('频率/kHz') = [500 1500 2500]; sampleRate = 8000; pitch = 100; f1=f(1);f2=f(2);f3=f(3); %冲激函数 yt=zeros(1,8000); yt(1)=1; if f1 > 0 cft = f1/sampleRate; bw = 50; q = f1/bw; rho = exp(-pi * cft / q); theta = 2 * pi * cft * sqrt(1-1/(4 * q*q)); a2 = -2*rho*cos(theta); a3 = rho*rho; y=filter([1+a2+a3],[1,a2,a3],yt); end; figure N=length(y); fn=(0:N-1)*sampleRate/N; fftg=fft(y); disg=20*log10(abs(fftg)); plot(fn(1:N/2+1),disg(1:N/2+1)) % line([0 sampleRate/2],[0 0]) xlabel('频率/Hz') ylabel('幅度/dB') title('(a)第一共振峰的二阶谐振器') % 根据指定的共振峰频率和带宽(50Hz)建模语音信号中的共振峰 % 第二共振峰 if f2 > 0 cft = f2/sampleRate; bw = 50; q = f2/bw; rho = exp(-pi * cft / q); theta = 2 * pi * cft * sqrt(1-1/(4 * q*q)); a2 = -2*rho*cos(theta); a3 = rho*rho; y=filter([1+a2+a3],[1,a2,a3],y); end; figure N=length(y); fn=(0:N-1)*sampleRate/N; fftg=fft(y); disg=20*log10(abs(fftg)); plot(fn(1:N/2+1),disg(1:N/2+1)) % line([0 sampleRate/2],[0 0]) xlabel('频率/Hz')
版本:2014a
完整代码或代写加1564658423