2014-12-04 78 views
1

這裏我必須發出聲音信號 - 一個是男性語音信號,另一個是噪聲信號,我已經將它們加在一起 ​​- 稱之爲信號「混合」 - 現在,米要求過濾它,以便消除噪音,剩下的只是男性的語音信號。 https://www.dropbox.com/s/m5frew6f0qlbae5/filteres%20signal.jpg?dl=0低通理想濾波器實現使用matlab 2014a

enter image description here

頻域

enter image description here

我觀察到: 分析男性語音和噪聲的曲線圖在時間和頻率域

時域1後那個男性語音的最大頻率略小於噪聲的最小頻率,所以我製作了低通濾波器 - 使用矩形函數 - 並在頻域進行濾波。

理想的低通濾波器

enter image description here

我繪製在頻率和時域上的最終得到的信號,在頻域的曲線是相同的頻域,但在時間上的男性語音圖表域名是不完全一樣的

濾波信號

enter image description here 我注意到了這個變化,當我發出了結果信號。 任何幫助,請知道爲什麼過濾後的信號不完全像原來的男性講話?我知道用這種方式過濾是不夠的,但目前我們應該在我們的課程報告中這樣做。

這裏是我的代碼:

[voice,Fs] = audioread ('hamid1.wav'); 
[noise,Fs] = audioread ('noise.wav'); 
voice(55126: 131072)=0 % to add both voice and noise signal together their dimensio must agree 
mix = voice + noise; % the mixed signal 

%vp = audioplayer(voice,Fs); 
%play(vp); 
%-- data for plotting voice --% 
iFs = 1/Fs; 
voiceLen = length(voice); 
voiceF0 = 1/(iFs*voiceLen); 
f_voice = 0:voiceF0: (voiceLen-1)*voiceF0; 
t_voice = 0:iFs:(voiceLen-1)*iFs; 
mag_voice = abs(fft(voice)); 

%-- data for plotting noise --% 
noiseLen = length(noise); 
noiseF0 = 1/(iFs*noiseLen); 
f_noise = 0:noiseF0: (noiseLen-1)*noiseF0; 
t_noise = 0:iFs:(noiseLen-1)/Fs; 
mag_noise = abs(fft(noise)); 
%--------------------------------------------% 

%-- data for plotting mix --% 
mixLen = length(mix); 
mixF0 = 1/(iFs*mixLen); 
f_mix= 0:mixF0: (mixLen-1)*mixF0; 
t_mix = 0:iFs:(mixLen-1)/Fs; 
mag_mix = abs(fft(mix)); 

%-- plotting voice speech, noise and mix in frequency domain --% 
figure(1); 
subplot(3,1,1); 
plot(f_voice,mag_voice); 
title('voice speech in frequency domain'); 
xlabel('frequency'); ylabel('Magnitude'); 
subplot(3,1,2); 
plot(f_noise,mag_noise); 
title('noise in frequency domain'); 
xlabel('frequency'); ylabel('Magnitude'); 
subplot(3,1,3); 
plot(f_mix,mag_mix); 
title('mix signal in frequency domain'); 
xlabel('frequency'); ylabel('Magnitude') 

%-- plotting voice speech, noise and mix in time domain --% 
figure(2); 
subplot(3,1,1); 
plot(t_voice,voice); 
title('voice speech in time domain'); 
xlabel('time'); ylabel('Amplitude'); 
subplot(3,1,2); 
plot(t_noise,noise); 
title('noise in time domain'); 
xlabel('time'); ylabel('Amplitude'); 
subplot(3,1,3); 
plot(t_mix, mix); 
title('mix signal in time domain'); 
xlabel('time'); ylabel('Amplitude') 

%-- design the bandpass filter -- 
rect = 1*(f_mix>=0 & f_mix <3000); 
rect2= rect+0*(f_mix>=3000 & f_mix <5482); 
%-- plotting the ideal filter --% 
figure(3) 
plot(f_mix, rect2,'linewidth',2); 
title('bandpass ideal filter'); 
xlabel('frequency'); ylabel('Magnitude') 
axis([0 11000 0 1.5]) 

%-- Filtering the mix signal to extract voice speech without noise --% 
filtered = rect2.*mag_mix' 
filteredT = ifft(filtered) 

figure(4) 
subplot(2,1,1) 
plot(f_mix, filtered) 
title('Filtered signal in frequency domain') 
xlabel('frequency') 
ylabel('Magnitude') 

subplot(2,1,2) 
plot(t_mix, real(filteredT)) 
title('Filtered signal in time domain') 
xlabel('time') 
ylabel('Amplitude') 
%-------------------------------------------% 
filtSig = audioplayer(filteredT,Fs) 
play(filtSig) 
+0

圖片不顯示。可能最好檢查超鏈接。 – am304 2014-12-04 15:37:03

+0

@ am304我已經添加了圖片的鏈接,我希望它現在會顯示 – AMH9 2014-12-04 15:47:08

+1

當我在鏈接上點擊時出現以下消息:「Error(403)。 看起來你不屬於這裏!你應該登錄。查看我們的幫助中心和論壇尋求幫助,或者回到家中。「 – am304 2014-12-04 15:53:18

回答

2

這裏有一個提示 - 是一種理想的過濾器實現的?理想低通濾波器的逆傅里葉變換是什麼?自從我看過這些東西已經有一段時間了,但我認爲你沒有收到任何錯誤。相反,您會看到過濾器設計過於嚴格的影響。

+0

我的理想濾波器的逆傅立葉變換將是時域中的sinc函數,對嗎? – AMH9 2014-12-04 19:40:10

+0

是的,我認爲是。因此,如果您在頻域中乘以理想的濾波器,那麼這是如何轉化爲時域的? – RGHummel 2014-12-04 19:42:41

+0

嗯我覺得在時間域中,我將不得不在濾波器 - sinc函數與信號之間進行卷積運算,但由於sinc函數在matlab中無法實現,因爲matlab會進入無窮大,所以默認情況下,matlab會將其切斷。是幾種類型的窗口 - 矩形..凱澤等。 - 達到最完美的過濾器。 – AMH9 2014-12-04 19:50:03