⑴ 濡備綍灏嗛噰闆嗕俊鍙疯緭鍏matlab
濡傛灉鏄鎯冲皢澹伴煶淇″彿褰曞埗鍒癿atlab閲岄潰锛屽垯鍙浠ヤ娇鐢ㄤ互涓嬬殑鍑芥暟銆
R = audiorecorder( 44100, 16 ,2 ) 锛
%鍒涘缓涓涓淇濆瓨闊抽戜俊鎭鐨勫硅薄锛屽畠鍖呭惈閲囨牱鐜囷紝鏃堕棿鍜屽綍鍒剁殑闊抽戜俊鎭绛夌瓑銆44100琛ㄧず閲囨牱涓44100Hz锛堝彲鏀逛负8000, 11025, 22050绛夛紝姝ゆ暟鍊艰秺澶э紝褰曞叆鐨勫0闊宠川閲忚秺濂斤紝鐩稿簲闇瑕佺殑瀛樺偍绌洪棿瓒婂ぇ锛夛紝16涓虹敤16bits瀛樺偍锛2涓轰袱閫氶亾鍗崇珛浣撳0锛堜篃鍙浠ユ敼涓1鍗冲崟澹伴亾锛夈
record(R);
%寮濮嬪綍鍒讹紝姝ゆ椂瀵圭潃楹﹀厠椋庤磋瘽鍗冲彲銆
pause(R);
%鏆傚仠褰曞埗銆
play(R)
%鎾鏀惧綍鍒剁殑澹伴煶銆
resume(R);
%缁х画褰曞埗.
stop(R);
%鍋滄㈠綍鍒
myspeech = getaudiodata(R);
%寰楀埌浠n*2鍒楁暟瀛楃煩闃靛瓨鍌ㄧ殑鍒氬綍鍒剁殑闊抽戜俊鍙枫
%瀵硅繖涓鐭╅樀浣犲氨鍙浠ョ敤鍚勭嶆护娉㈠櫒杩涜屽勭悊锛屾垨鑰呮妸瀹冨拰鍒鐨勯煶棰戞贩闊崇瓑绛夈備綘涔熷彲浠ョ敾鍑哄畠鐨勬尝褰锛堝傛灉鏃堕棿杈冮暱鐢绘尝褰㈠彲鑳戒細鑺辩偣鏃堕棿锛夈
plot(myspeech)
%鐢诲嚭娉㈠舰
%濡傛灉浣犳兂淇濆瓨鍙浠ヤ娇鐢
wavwrite(myspeech,44100,16,'myspeech')锛
%myspeech琛ㄧず瑕佸瓨鍏ョ殑娉㈠舰鐭╅樀锛44100琛ㄩ噰鏍风巼锛16 涓轰互16bits瀛樺偍锛'myspeech'涓哄瓨鍌ㄧ殑鏂囦欢鍚嶃
%matlab鏈夋瀬鍏朵赴瀵岀殑闊抽戝勭悊婊ゆ尝鍔燂紝姝ゅ勪粙缁嶆渶鍩烘湰鐨勫綍鍏ャ佹挱鏀惧拰淇濆瓨鎿嶄綔锛屽笇鏈涜兘瀵逛綘鏈夋墍甯鍔
⑵ 鑳界粰鎴戜竴涓璋卞噺娉昺atlab鍘诲櫔鐨勭▼搴忓悧锛熸湁宸插綍鐨勭函鍑璇闊 瑕佺畝鍗曠殑鏈夋敞閲婂氨鏇村ソ浜 锛 涓囧垎鎰熻阿
winsize=256;%绐楅暱
n=0.1;%鍣澹版按骞
a=2;
b=6;
[speech,fs,nbits]=wavread('E:\matlab\louyin.wav');%璇诲叆wav鏂囦欢
size=length(speech);%璇闊抽暱搴
numofwin=floor(size/winsize);%绐楁暟
%瀹氫箟姹夋槑绐
ham=hamming(winsize)';
hamwin=zeros(1,size);
enhanced=zeros(1,size);
improved=zeros(1,size);
%鐢熸垚鍣澹颁俊鍙
noise=n*randn(1,size);
y=speech'+noise;
%鍣澹板勭悊
noisy=n*randn(1,winsize);
N=fft(noisy);
npow=abs(N);
for q=1:2*numofwin-1
yframe=y(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;%
%鍔犲櫔淇″彿FFT
y1=fft(yframe.*ham);
ypow=abs(y1);%鍔犲櫔淇″彿骞呭害
yangle=angle(y1);%鐩镐綅
%璁$畻鍔熺巼璋卞瘑搴
Py=ypow.^2;
Pn=npow.^2;
Pyy=ypow.^a;
Pnn=npow.^a;
%鍩烘湰璋卞噺
for i=1:winsize
if Py(i)-Pn(i)>0
Ps(i)=Py(i)-Pn(i);
else
Ps(i)=0;
end
end
s=sqrt(Ps).*exp(j*yangle);
for i=1:winsize
if Pyy(i)-b*Pnn(i)>0
Pss(i)=Pyy(i)-b*Pnn(i);
else
Pss(i)=0;
end
end
ss=Pss.^(1/a).*exp(j*yangle);
%鍘诲櫔璇闊矷FFT
enhanced(1+(q-1)*winsize/2:winsize+(q-1)*winsize/2)=enhanced(1+(q-1)*winsize/2:winsize+(q-1)*winsize/2)+real(ifft(s));
improved(1+(q-1)*winsize/2:winsize+(q-1)*winsize/2)=improved(1+(q-1)*winsize/2:winsize+(q-1)*winsize/2)+real(ifft(ss));
end
%鍘婚櫎姹夋槑绐楀紩璧风殑澧炵泭
for i=1:size
if hamwin(i)==0
enhanced(i)=0;
improved(i)=0;
else
enhanced(i)=enhanced(i)/hamwin(i);
improved(i)=improved(i)/hamwin(i);
end
end
SNR1=10*log10(var(speech')/var(noisy));%鍔犲櫔璇闊充俊鍣姣
SNR2=10*log10(var(speech')/var(enhanced-speech'));%澧炲己璇闊充俊鍣姣
SNR3=10*log10(var(speech')/var(improved-speech'));
figure(1);plot(speech');%鍘熷嬭闊虫尝褰
title(['Original Voice(n=',num2str(n),')']);
figure(2);plot(y);
title(['Noise Added(SNR=',num2str(SNR1),'dB)']);
figure(3);plot(enhanced);
title(['Enhanced Voice(SNR=',num2str(SNR2),'dB)']);
figure(4);plot(improved);
title(['Improved Voice(SNR=',num2str(SNR3),'dB)']);
⑶ 闂闂鍏充簬matlab涓鐨勮闊宠瘑鍒珇~
鍏跺疄杩欐典唬鐮佹垜鐪嬭繃 - -
鎴戣夊緱鏈変簺鑾鍚嶅叾濡欑殑锛屾垜缁欎綘涓涓濂界綉绔欙紝浣犲幓涓婇潰鐪嬶紝鍏跺疄灏8姝ワ細
http://neural.cs.nthu.e.tw/jang/books/audiosignalprocessing/speechFeatureMfcc_chinese.asp?title=12-2%20MFCC
杩欐垫枃绔犲氨鏄缃戜笂鏈骞挎硾鐨凪FCC 8姝ラわ紝璁插緱闈炲父娓呮氾紝鎴戣垂灏藉ぇ鍔涙皵鎵嶆壘鍒板師鐗堛
杩欐湰涔︽暣涓閮藉緢濂斤紝閫傚悎鍏ラ棬鐪嬶紝鎴戝幓骞存悶浜嗗ソ涔
鍙鑳芥湇鍔″櫒鍏虫帀浜嗭紝鎴戠粰浣犲彂浜嗙佷俊锛屼綘閫氳繃閭d釜鑱旂郴鎴戯細锛夋垜缁欎綘pdf鐗堟湰