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

조회 수: 14(최근 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
GARIKIPATI VENKATA
GARIKIPATI VENKATA 2022년 9월 26일
편집: GARIKIPATI VENKATA 2022년 9월 26일
@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');

댓글을 달려면 로그인하십시오.

답변(1개)

William Rose
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
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.

댓글을 달려면 로그인하십시오.

범주

Find more on Audio I/O and Waveform Generation in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by