matlab wav格式音频去除人声(原理自查)
先设立Hbs带阻函数(matlab2018a为例)
选择右上view可以查看函数效果如下
应用函数
代码块
代码块语法遵循标准markdown代码,例如:
function xinhaochuli(Hbs)
%clear; %Hbs需要调用不能使用clear
close all;
clc;
[x,fs]=audioread('林俊杰 - 可惜没如果.wav'); % 将 WAV 文件转换成变量,最好用wav格式mp3格式影响较大
sound(x,fs);
pause
x1=x(:,1); % 抽取第 1 声道
x2=x(:,2); % 抽取第 2 声道
n=length(x1);
X1=fft(x1,n); %快速傅里叶变换
figure(1)
subplot(4,1,1);
plot(x1);
xlabel('时间');
ylabel('幅度');
title('初始信号左波形'); %绘出时域波
grid on;
subplot(4,1,2); %绘出频域频谱
plot(abs(fftshift(X1)));
title('初始信号左频谱');
xlabel('频率');
ylabel('幅度');
grid on;
n=length(x2); %画出加噪之后,其时域频域
X2=fft(x2,n);
subplot(4,1,3)
plot(x2);
title('初始信号右波形')
xlabel('时间');
ylabel('幅度');
grid on;
subplot(4,1,4)
plot(abs(fftshift(X2)));
xlabel('频率');
ylabel('幅度');
title('初始信号右频谱');
grid;
pause;
NewLeft=x1-x2;
NewRight=x1-x2;
n=length(NewLeft);
NEWLEFT=fft(NewLeft,n); %快速傅里叶变换
figure(2)
subplot(4,1,1);
plot(NewLeft);
xlabel('时间');
ylabel('幅度');
title('声道相减后信号左波形'); %绘出时域波
grid on;
subplot(4,1,2); %绘出频域频谱
plot(abs(fftshift(NEWLEFT)));
title('声道相减后信号左频谱');
xlabel('频率');
ylabel('幅度');
grid on;
n=length(NewLeft); %声道相减之后,其时域频域
NEWRIGHT=fft(NewRight,n);
subplot(4,1,3)
plot(NewRight);
title('声道相减后信号右波形')
xlabel('时间');
ylabel('幅度');
grid on;
subplot(4,1,4)
plot(abs(fftshift(NEWRIGHT)));
xlabel('频率');
ylabel('幅度');
title('声道相减后信号右频谱');
grid on;
pause;
New=NewLeft+NewRight; % 两路单声道列向量矩阵变量合并
%New(:,1)=NewLeft;
%New(:,2)=NewRight;
n=length(New);
NEW=fft(New,n);
figure(3);
subplot(2,1,1)
plot(New);
title('两路单声道列向量矩阵变量合并信号波形')
xlabel('时间');
ylabel('幅度');
grid on;
subplot(2,1,2)
plot(abs(fftshift(NEW)));
xlabel('频率');
ylabel('幅度');
title('两路单声道列向量矩阵变量合并信号频谱');
grid on;
sound(New,fs)
pause
BandstopNew=filter(Hbs,New);%Hbs滤波函数 y为滤波输入
n=length(BandstopNew); %滤去人声一般80hz到700hz之后,其时域频域(在Hbs中可以自己改)
BANDSTOPNEW=fft(BandstopNew,n);
figure(4);
subplot(2,1,1)
plot(BandstopNew);
title('滤去人声一般80hz到700hz之后信号波形')
xlabel('时间');
ylabel('幅度');
grid on;
subplot(2,1,2)
plot(abs(fftshift(BANDSTOPNEW)));
xlabel('频率');
ylabel('幅度');
title('声道相减后信号频谱');
grid on;
sound(BandstopNew,fs)
end
效果
参考资料
https://blog.youkuaiyun.com/miao0967020148/article/details/54906628
https://blog.youkuaiyun.com/qq_17287777/article/details/79292278
https://blog.youkuaiyun.com/zouyu409709312/article/details/51330909