adding awgn noise to an audio signal and removing noise by wiener filter

19 visualizzazioni (ultimi 30 giorni)
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 Commenti
William Rose
William Rose il 26 Set 2022
@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.
GARIKIPATI VENKATA
GARIKIPATI VENKATA il 26 Set 2022
Modificato: GARIKIPATI VENKATA il 26 Set 2022
@William Rose thanks for responding , i have created audio file for noisy signal using audiowrite . but iam still getting these errors.
Error using audioread>readaudio
The filename specified was not found in the MATLAB path.
Error in audioread (line 137)
[y, Fs] = readaudio (filename, range, datatype);
Error in mycode (line 35)
[inSpeech,Fs] = audioread('Noisy_Signal');

Accedi per commentare.

Risposte (1)

William Rose
William Rose il 26 Set 2022
@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 Commenti
GARIKIPATI VENKATA
GARIKIPATI VENKATA il 27 Set 2022
Modificato: GARIKIPATI VENKATA il 27 Set 2022
@William Rose i don't know how to add the file extension . can u tell me how to do that ?
and at the last weiner filter , is that correct how can i listen filtered voice ? are the last two lines of my code correct? if it is wrong can u please tell me the right one .
[inSpeech,Fs] = audioread('noiseadded.wav');
[outSpeech ,z] = WienerNoiseReduction(inSpeech,Fs,10000);
William Rose
William Rose il 27 Set 2022
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.

Accedi per commentare.

Categorie

Scopri di più su Audio Processing Algorithm Design in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by