这个问题是课程介绍时候,Andrew Ng使用MATLAB ICA 实现了语音的分离(鸡尾酒会额外难题),ppt上面写着这行代码:
[W,s,v]=svd((repmat(sum(x.*x,1),size(x,1),1).*x)*x');
下面的代码是使用网上的人回答的代码:
[x1, Fs1] = audioread('E:\sounds\first.wav');
[x2, Fs2] = audioread('E:\sounds\second.wav');
xx = [x1, x2]';
yy = sqrtm(inv(cov(xx')))*(xx-repmat(mean(xx,2),1,size(xx,2)));
[W,s,v] = svd((repmat(sum(yy.*yy,1),size(yy,1),1).*yy)*yy');
a = W*xx; %W is unmixing matrix
subplot(2,2,1); plot(x1); title('mixed audio - mic 1');
subplot(2,2,2); plot(x2); title('mixed audio - mic 2');
subplot(2,2,3); plot(a(1,:), 'g'); title('unmixed wave 1');
subplot(2,2,4); plot(a(2,:),'r'); title('unmixed wave 2');
audiowrite('unmixed1.wav', a(1,:), Fs1);
audiowrite('unmixed2.wav', a(2,:), Fs1);