adding awgn noise to an audio signal and removing noise by wiener filter
조회 수: 21 (최근 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!