%% 1.1 Read wav file and retrieve spectrum
[y_m,Y_m, YA_m, YG_m] = spec('../dt/male.wav'); % Read audio of the male
[y_f,Y_f, YA_f, YG_f] = spec('../dt/female.wav'); % Read audio of the female
figure % Figure 1
plot (y_m);
figure % Figure 2
plot (y_f);
figure % Figure 3
imshow(YA_m);
figure % Figure 4
imshow(YA_f);
y_m=synth(Y_m);
%sound(y_m,16000); % sound the re-synthesized audio
%% 2.1 NMF traning
[W_m,H_m]=cnmf(YA_m,20,500); % compute base matrix W; rr = 20; it = 500
figure % Figure 5
show_W(W_m);
save ('W_m_20.mat','W_m');
%% 2.4 Getting resynthesized audio signal in time domain by Base1
[Y1_m]=maskspec(W_m,H_m,1,1);
y1_m=synth(Y1_m.*YG_m);
%sound(y1_m,16000); % sound the re-synthesized audio
wavwrite(y1_m,16000,'base1_m.wav');
%% 2.5 Getting resynthesized audio signal in time domain by Base4 and Base8
[Y4_m]=maskspec(W_m,H_m,4,4);
y4_m=synth(Y4_m.*YG_m);
%sound(y4_m,16000); % sound the re-synthesized audio
wavwrite(y4_m,16000,'base4_m.wav');
[Y8_m]=maskspec(W_m,H_m,8,8);
y8_m=synth(Y8_m.*YG_m);
%sound(y8_m,16000); % sound the re-synthesized audio
wavwrite(y8_m,16000,'base8_m.wav');
%% 2.6 subplot and plot speech waveforms
subplot(3,1,1); plot(y1_m);
subplot(3,1,2); plot(y4_m);
subplot(3,1,3); plot(y8_m);
%% 2.7 try all the bases via different base number.
Y_m_all=maskspec(W_m,H_m,1,20);
y_m_all=synth(Y_m_all.*YG_m);
%sound(y1_m,16000); % sound the re-synthesized audio
wavwrite(y_m_all,16000,'base_20_m.wav');
[W_m_40,H_m_40]=cnmf(YA_m,40,500); % compute base matrix W; rr = 40; it = 500
figure % Figure 5
show_W(W_m_40);
save ('W_m_40.mat','W_m_40');
Y_m_40=maskspec(W_m_40,H_m_40,1,40);
y_m_40=synth(Y_m_40.*YG_m);
%sound(y1_m,16000); % sound the re-synthesized audio
wavwrite(y_m_40,16000,'base_40_m.wav');
[W_m_10,H_m_10]=cnmf(YA_m,10,500); % compute base matrix W; rr = 10; it = 500
figure % Figure 5
show_W(W_m_10);
save ('W_m_10.mat','W_m_10');
Y_m_10=maskspec(W_m_10,H_m_10,1,10);
y_m_10=synth(Y_m_10.*YG_m);
%sound(y1_m,16000); % sound the re-synthesized audio
wavwrite(y_m_10,16000,'base_10_m.wav');
[W_m_2000,H_m_2000]=cnmf(YA_m,2000,500); % compute base matrix W; rr = 10; it = 500
figure % Figure 5
show_W(W_m_2000);
save ('W_m_2000.mat','W_m_2000');
Y_m_2000=maskspec(W_m_2000,H_m_2000,1,2000);
y_m_2000=synth(Y_m_2000.*YG_m);
%sound(y1_m,16000); % sound the re-synthesized audio
wavwrite(y_m_10,16000,'base_10_m.wav');
%% 2.8 female video training
[W_f,H_f]=cnmf(YA_f,20,500); % compute base matrix W; rr = 20; it = 500
figure % Figure 5
show_W(W_f);
save ('W_f_20.mat','W_f');
%% Getting resynthesized audio signal in time domain by Base1
[Y1_f]=maskspec(W_f,H_f,1,1);
y1_f=synth(Y1_f.*YG_f);
%sound(y1_f,16000); % sound the re-synthesized audio
wavwrite(y1_f,16000,'base1_f.wav');
%% Getting resynthesized audio signal in time domain by Base4 and Base8
[Y4_f]=maskspec(W_f,H_f,4,4);
y4_f=synth(Y4_f.*YG_f);
%sound(y4_f,16000); % sound the re-synthesized audio
wavwrite(y4_f,16000,'base4_f.wav');
[Y8_f]=maskspec(W_f,H_f,8,8);
y8_f=synth(Y8_f.*YG_f);
%sound(y8_f,16000); % sound the re-synthesized audio
wavwrite(y8_f,16000,'base8_f.wav');
%% subplot and plot speech waveforms
subplot(3,1,1); plot(y1_f);
subplot(3,1,2); plot(y4_f);
subplot(3,1,3); plot(y8_f);
%% try all the bases via different base number.
Y_f_all=maskspec(W_f,H_f,1,20);
y_f_all=synth(Y_f_all.*YG_f);
%sound(y1_f,16000); % sound the re-synthesized audio
wavwrite(y_f_all,16000,'base_20_f.wav');
[W_f_40,H_f_40]=cnmf(YA_f,40,500); % compute base matrix W; rr = 40; it = 500
figure % Figure 5
show_W(W_f_40);
save ('W_f_40.mat','W_f_40');
Y_f_40=maskspec(W_f_40,H_f_40,1,40);
y_f_40=synth(Y_f_40.*YG_f);
%sound(y1_f,16000); % sound the re-synthesized audio
wavwrite(y_f_40,16000,'base_40_f.wav');
[W_f_10,H_f_10]=cnmf(YA_f,10,500); % compute base matrix W; rr = 10; it = 500
figure % Figure 5
show_W(W_f_10);
save ('W_f_10.mat','W_f_10');
Y_f_10=maskspec(W_f_10,H_f_10,1,10);
y_f_10=synth(Y_f_10.*YG_f);
%sound(y1_f,16000); % sound the re-synthesized audio
wavwrite(y_f_10,16000,'base_10_f.wav');
[W_f_2000,H_f_2000]=cnmf(YA_f,2000,500); % compute base matrix W; rr = 10; it = 500
figure % Figure 5
show_W(W_f_2000);
save ('W_f_2000.mat','W_f_2000');
Y_f_2000=maskspec(W_f_2000,H_f_2000,1,2000);
y_f_2000=synth(Y_f_2000.*YG_f);
%sound(y1_f,16000); % sound the re-synthesized audio
wavwrite(y_f_2000,16000,'base_2000_f.wav');
%% 3.1 Clear the workspace
clear all;
clc;
%% 3.2 Load base matrices
load ('W_m_2000.mat');
load ('W_f_2000.mat');
%% 3.3 Load base matrices
[y_mix,Y_mix, YA_mix, YG_mix] = spec('../dt/mix.wav'); % Read audio of the mix
%% 3.4 get W matrics of W
W_mix_2000 = [W_m_2000, W_f_2000];
[W_mix,H_mix]=cnmf(YA_mix,2000,500,false,W_mix_2000);
%% 3.5 Compute YA_mix and separate speech
[YA_m_from_mix]=maskspec(W_mix,H_mix,1,2000);
y_m_from_mix=synth(YA_m_from_mix.*YG_mix);
[YA_f_from_mix]=maskspec(W_mix,H_mix,2001,4000);
y_f_from_mix=synth(YA_f_from_mix.*YG_mix);
subplot(3,1,1); plot(y_mix);
subplot(3,1,2); plot(y_m_from_mix);
subplot(3,1,3); plot(y_f_from_mix);
wavwrite(y_f_from_mix,16000,'f_speech_separated2000.wav');
wavwrite(y_m_from_mix,16000,'m_speech_separated2000.wav');
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
基于MATLAB的男女声音分离源码.zip (13个子文件)
基于MATLAB的男女生分离源码
dt
female.wav 1.09MB
male.wav 1.02MB
mix.wav 1.09MB
code
cnmf.m 1KB
spec.m 1KB
60.m 5KB
I.asv 5KB
maskspec.m 474B
show_W.m 490B
3.m 600B
shifting.m 125B
synth.m 555B
I.m 5KB
共 13 条
- 1
资源评论
- TR08142020-12-07为什么代码运行显示好多文件找不到
YJThuicheng
- 粉丝: 29
- 资源: 15
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功