• 大小: 2.19MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-08-10
  • 语言: Matlab
  • 标签: 语音信号  

资源简介

语音信号盲分离,应用程序FastICA,可以应用matlab直接运行,并且文件夹内包含语音信号,无需另外下载

资源截图

代码片段和文件信息


%%%%%%%%%%%%%%%%%%%%%%%%%%  初始化  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

clc;clear all;close all;

%%%%%%%%%%%%%%  读入原始图像,混合,并输出混合图像  %%%%%%%%%%%%%%%%%%

% 读入混合前的原始图片并显示
I1=wavread (‘man.wav‘)‘;         
I2=wavread (‘dragen.wav‘)‘;
I3=wavread (‘music.wav‘)‘;
subplot(431)plot(I1)title(‘输入声音1‘)
subplot(432)plot(I2)title(‘输入声音2‘)
subplot(433)plot(I3)title(‘输入声音3‘)

% 将其组成矩阵
S=[I1;I2;I3];                          % 图片个数即为变量数,图片的像素数即为采样数
                                       % 因此S_all是一个变量个数*采样个数的矩阵
Sweight=rand(size(S1));               % 取一随机矩阵,作为信号混合的权矩阵
MixedS=Sweight*S;                      % 得到三个图像的混合信号矩阵

% 将混合矩阵重新排列并输出
subplot(434)plot(MixedS(1:))title(‘混合声音1‘)
subplot(435)plot(MixedS(2:))title(‘混合声音2‘)
subplot(436)plot(MixedS(3:))title(‘混合声音3‘)

MixedS_bak=MixedS;                         % 将混合后的数据备份,以便在恢复时直接调用
%%%%%%%%%%%%%%%%%%%%%%%%%%  标准化  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MixedS_mean=zeros(31);
for i=1:3
    MixedS_mean(i)=mean(MixedS(i:));
end                                        % 计算MixedS的均值

for i=1:3
    for j=1:size(MixedS2)
        MixedS(ij)=MixedS(ij)-MixedS_mean(i);
    end
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%  白化  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

MixedS_cov=cov(MixedS‘);                    % cov为求协方差的函数
[ED]=eig(MixedS_cov);                      % 对图片矩阵的协方差函数进行特征值分解
Q=inv(sqrt(D))*(E)‘;                        % Q为白化矩阵
MixedS_white=Q*MixedS;                      % MixedS_white为白化后的图片矩阵
IsI=cov(MixedS_white‘);                     % IsI应为单位阵            

%%%%%%%%%%%%%%%%%%%%%%%% FASTICA算法  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
X=MixedS_white;                            % 以下算法将对X进行操作
[VariableNumSampleNum]=size(X);
numofIC=VariableNum;                       % 在此应用中,独立元个数等于变量个数
B=zeros(numofICVariableNum);              % 初始化列向量w的寄存矩阵B=[b1  b2  ...   bd]
for r=1:numofIC
    i=1;maxIterationsNum=100;               % 设置最大迭代次数(即对于每个独立分量而言迭代均不超过此次数)
    IterationsNum=0;
    b=rand(numofIC1)-.5;                  % 随机设置b初值
    b=b/norm(b);                           % 对b标准化 norm(b):向量元素平方和开根号
    while i<=maxIterationsNum+1
        if i == maxIterationsNum           % 循环结束处理
            fprintf(‘\n第%d分量在%d次迭代内并不收敛。‘ rmaxIterationsNum);
            break;
        end
        bOld=b;                          
        a2=1;
        u=1;
        t=X‘*b;
        g=t.*exp(-a2*t.^2/2);
        dg=(1-a2*t.^2).*exp(-a2*t.^2/2);
        b=((1-u)*t‘*g*b+u*X*g)/SampleNum-mean(dg)*b;
                                           % 核心公式,参见理论部分公式2.52
        b=b-B*B‘*b;                        % 对b正交化
        b=b/norm(b); 
        if abs(abs(b‘*bOld)-1)<1e-9        % 如果收敛,则
             B(:r)=b;                     % 保存所得向量b
             break;
         end
        i=i+1;        
    end
%    B(:r)=b;                                % 保存所得向量b
end

%%%%%%%%%%%%%%%%%%%%%%%%%%  ICA计算的数据复原并构图  %%%%%%%%%%%%%%%%%%%%%%%%%
ICAedS=B‘*Q*Mixed

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     文件      882138  2006-05-28 15:32  Fast ICA\dragen.wav
     文件      882044  2006-05-28 15:31  Fast ICA\man.wav
     文件      882142  2006-05-28 15:32  Fast ICA\music.wav
     文件        4373  2009-04-08 19:55  Fast ICA\soundOK.asv
     文件        4373  2009-04-08 19:57  Fast ICA\soundOK.m
     目录           0  2018-04-28 10:51  Fast ICA\

评论

共有 条评论