how adjustrange of the voice while implement high and low pass filter

1 次查看(过去 30 天)
confused about separte the audio and noise and doing range of frequency for normal voice human and neglect the rest of noisy thing

回答(1 个)

Saarthak Gupta
Saarthak Gupta 2023-12-27
Hi Sherif,
I understand that you wish to filter the noise out of a given audio sample containing human voice.
To separate the audio (human voice) from noise, you typically need to know the frequency range of the human voice and apply a band-pass filter that allows only that range to pass through.
Refer to the following code:
%% Read complete audio file
% using sample data file (available in MATLAB), since original data file is not provided
load handel.mat
%% Plot the original sound waveform
subplot(421);
plot(y,'r');
title('Original sound');
len = length(y);
xdft = fft(y);
freq = (Fs/len)*(0:len/2-1);
%% Plot the original DFT
subplot(422);
plot(freq,abs(xdft(1:len/2)),'k');
Warning: Integer operands are required for colon operator when used as index.
title('Original DFT');
% Band-pass filter, assuming the desired voice range from 200 Hz to 1300 Hz
fmin = 200; % lower cutoff frequency
fmax = 1300; % upper cutoff frequency
kmin = round((fmin*len)/Fs) + 1;
kmax = round((fmax*len)/Fs) + 1;
xfilter = zeros(len, 1);
xfilter(kmin:kmax) = xdft(kmin:kmax); % pass the frequencies within the voice range
xfilter(end-kmax+2:end-kmin+2) = xdft(end-kmax+2:end-kmin+2);
%% Plot the DFT after BPF
subplot(423);
plot(freq,abs(xfilter(1:len/2)),'b');
Warning: Integer operands are required for colon operator when used as index.
title('DFT after BPF');
%% Plot the audio signal after BPF
datafilter = ifft(xfilter);
datafilter_real = real(datafilter);
subplot(424);
plot(datafilter_real,'y');
title('Audio after BPF');
% Play the filtered audio
sound(datafilter_real,Fs);
Given that the "handel" audio sample primarily contains frequencies within the 200 to 1300 Hz range, the code sets this range as the threshold for the band-pass filter.
Refer to the following MATLAB documentation for further reference:

类别

Help CenterFile Exchange 中查找有关 Audio I/O and Waveform Generation 的更多信息

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by