matlab wav格式音頻去除人聲

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.csdn.net/miao0967020148/article/details/54906628
https://blog.csdn.net/qq_17287777/article/details/79292278
https://blog.csdn.net/zouyu409709312/article/details/51330909

DONE

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章