【问题标题】:Remove noise from mp3 file, MATLAB从 mp3 文件中去除噪音,MATLAB
【发布时间】:2018-12-31 22:52:48
【问题描述】:

我在下面的链接中有一个 mp3 文件,其中有一个男人的人声和背景中的一些嗡嗡声。我想消除嗡嗡声。有谁可以告诉我如何在MATLAB中做到这一点? https://www.dropbox.com/s/h95y1oelbzvcgkc/allthatbass.mp3?dl=0

%% Read in the file
clearvars;
close all;
[f,fs] = audioread('allthatbass.mp3');
%% Play original file
pOrig = audioplayer(f,fs);
N = size(f,1);
%% Plot the spectrum
df = fs / N;
w = (-(N/2):(N/2)-1)*df;
y = fft(f(:,1), N) / N; % For normalizing, but not needed for our analysis
y2 = fftshift(y);
figure;
plot(w,abs(y2));
%% Design a bandpass filter that filters out between 700 to 12000 Hz
n = 7;
beginFreq = 700 / (fs/2);
endFreq = 12000 / (fs/2);
[b,a] = butter(n, [beginFreq, endFreq], 'bandpass');
%% Filter the signal
fOut = filter(b, a, f);
%% Construct audioplayer object and play
p = audioplayer(fOut, fs);
p.play;

我希望消除嗡嗡声,但输出的声音就像原始声音一样。

enter link description here

【问题讨论】:

    标签: matlab audio noise-reduction


    【解决方案1】:

    我已经下载了您在问题中链接的原始文件,并在末尾添加了以下行:

    audiowrite('filtered.wav', fOut, fs);
    

    生成的文件“filtered.wav”在我耳中听起来非常不同(我使用耳机听)。例如,如果您在 Audacity 中打开“filtered.wav”并查看频谱,那么它看起来确实与原始频谱不同(正如预期的那样,低于 700 Hz 和高于 12 kHz 的频率被删除了)。

    让我们尝试在 matlab 中验证这一点。以下脚本读取两个文件并绘制两个 fft 的 dB 值。下图表示滤波后的信号,可以清楚地看到低音频率被去除。 12 kHz 以上的切割也是可见的,但似乎这些频率在原始信号中已经衰减,带通滤波器加强了这一点。

    %% Read in both files
    clearvars;
    close all;
    [f,fs] = audioread('allthatbass.mp3');
    [fflt, fsflt] = audioread('filtered.wav');
    N = size(f,1);
    %% Compute the ffts
    df = fs / N;
    n = N / 2; % plot only the second half of the spectrum
    w = (0:(n)-1)*df;
    y = fft(f(:,1), N) / N;
    y2 = fftshift(y);
    yflt = fft(fflt(:,1), N) / N;
    y2flt = fftshift(yflt);
    %% Plot the spectrum of both files (use the dB value, i.e. 10 * log(abs(x)) )
    figure;
    ax1 = subplot(2,1,1);
    plot(w,10*log(abs(y2(n:end-1,1))));
    ax2 = subplot(2,1,2);
    plot(w, 10*log(abs(y2flt(n:end-1,1))));
    linkaxes([ax1, ax2], 'y'); % link the axes (this makes it easier to visually compare the plots)
    

    【讨论】:

      【解决方案2】:

      尝试在 MATLAB 中使用低通滤波器。它们相对容易实现。您可以找到文档以及示例,here

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-03-04
        • 2019-06-03
        • 2018-07-18
        相关资源
        最近更新 更多