adding awgn noise to an audio signal and removing noise by wiener filter
19 ビュー (過去 30 日間)
古いコメントを表示
clc
close all
clear all
audio = audioread( "male1.wav" );
figure(1)
subplot(211)
plot(audio)
title('original signal')
Original_Signal = audio(:,1 );
Signal_To_Noise_Ratio = 20 ;
Noisy_Signal = awgn(Original_Signal,Signal_To_Noise_Ratio );
figure(1)
subplot(212)
plot(Noisy_Signal)
title('noisy signal')
%Playing back at the sampling frequency, Fs %
Fs = 44100 ;
sound(Noisy_Signal,Fs);
audiowrite('noiseadded.wav',Noisy_signal,Fs);
[y,fs]=audioread('male1.wav');
t=linspace(0,length(y)/fs,length(y));
figure(2)
subplot(211);
plot(t,y,'k'); axis tight
Nfft=2000;
f=linspace(0,fs,Nfft);
G=abs(fft(y,Nfft));
figure(2)
subplot(212);
plot(f(1:Nfft/2),G(1:Nfft/2)); axis tight
[inSpeech,Fs] = audioread('Noisy_Signal');
[outSpeech ,~] = WienerNoiseReduction(inSpeech,Fs,10000);
2 件のコメント
William Rose
2022 年 9 月 26 日
@GARIKIPATI VENKATA, what is your question? The second-to-last line of your code will fail if file "Noisy_Signal" does not exist. You have created an array "Noisy_Signal", but you do not save it as a file in the script you have shown.
回答 (1 件)
William Rose
2022 年 9 月 26 日
@GARIKIPATI VENKATA, include the file extension in the file specificaiton for audioread and audiowrite.
fs=44100; %sampling frequency
f=440; %frequency of note A=440 Hz
t=(1:fs)/fs; %1 second of time values
x=0.1*sin(2*pi*f*t); %pure tone
xn=awgn(x,20); %add noise
audiowrite('noteAnoisy.wav',xn,fs); %write file
yn=audioread('noteAnoisy.wav'); %read file
sound(yn,fs) %play noisy tone
The code above produces a noisy tone with duration 1 second, when I run it on my computer. It executes without error, but does not make any sound, when I run it in the Matlab Answers window online.
.
.
2 件のコメント
William Rose
2022 年 9 月 27 日
Your code
[inSpeech,Fs] = audioread('noiseadded.wav');
is correct, if the noisy file is named noiseadded.wav. Your code does not show the file being created, so I do not know what its extension is. If you create the noisy file with
audiowrite('noiseAdded.wav',xn,fs); %write file
then its name will be noiseAdded.wav, and the audioread command above will work. (Assuming that the file is in a directory that Matlab knows about - google "Matlab path" if you need to know more about this.)
The command
[outSpeech ,z] = WienerNoiseReduction(inSpeech,Fs,10000);
looks good. It calls WienerNoiseReduction(), which is not part of Matlab or the toolboxes. It is from the Matlab file exchange, here. I recommend consulting the author of that function. Note that the third argument, where you have 10000, is the duration of the initial silence period, in samples. Adjust that value to fit your recording. Read the documentation here for more.
参考
カテゴリ
Help Center および File Exchange で Audio Processing Algorithm Design についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!