主要内容

鸡尾酒会使用深度学习网络的源分离

这个例子显示了如何分离语音信号使用深度学习网络。

介绍

鸡尾酒会效应是指大脑的能力集中在单个扬声器而过滤掉其他声音和背景噪音。人类在鸡尾酒会问题表现很好。这个例子展示了如何使用一个深入学习网络分离单个扬声器演讲混合,一男一女同时说话。

下载所需的文件

在进入详细例子之前,你会下载一个pre-trained网络和4个音频文件。

downloadFolder = matlab.internal.examples.download万博1manbetxSupportFile (“音频”,“CocktailPartySourceSeparation.zip”);dataFolder = tempdir;解压缩数据集(downloadFolder dataFolder) = fullfile (dataFolder,“CocktailPartySourceSeparation”);

问题总结

加载音频文件包含男性和女性演讲4千赫采样。听音频文件单独供参考。

[mSpeech, Fs] = audioread (fullfile(数据集,“MaleSpeech-16-4-mono-20secs.wav”));声音(mSpeech Fs)
[fSpeech] = audioread (fullfile(数据集,“FemaleSpeech-16-4-mono-20secs.wav”));声音(fSpeech Fs)

结合这两个演讲来源。确保有平等的权力来源。规模的混合,使其最大振幅就是其中之一。

mSpeech = mSpeech /规范(mSpeech);fSpeech = fSpeech /规范(fSpeech);ampAdj = max (abs ([mSpeech; fSpeech]));mSpeech = mSpeech / ampAdj;fSpeech = fSpeech / ampAdj;混合= mSpeech + fSpeech;混合= mix. / max (abs(混合));

原始和混合信号的可视化。听混合语音信号。这个例子显示了一个源分离方案,提取男性和女性从语音混合来源。

t =(0:元素个数(混合)1)* (1 / Fs);图(1)tiledlayout (3,1) nexttile情节(t, mSpeech)标题(“男性演讲》网格)fSpeech nexttile情节(t)标题(“女性语言”网格)nexttile情节(t,混合)标题(“语音组合”)包含(“时间(s)”网格)

听音频混合。

声音(混合,Fs)

时频表示

使用stft可视化的时频(TF)表示男性,女性,混合语音信号。使用一个损害窗口长度128,一个FFT长度为128,和一个重叠长度为96。

windowLength = 128;fftLength = 128;overlapLength = 96;赢得=损害(windowLength,“周期”);图(2)tiledlayout (3,1) nexttile stft (Fs, mSpeech窗口=赢,OverlapLength = OverlapLength FFTLength = FFTLength FrequencyRange =“单向的”);标题(“男性演讲》)nexttile stft (fSpeech Fs,窗口=赢,OverlapLength = OverlapLength FFTLength = FFTLength FrequencyRange =“单向的”);标题(“女性语言”(混合)nexttile stft, Fs,窗口=赢,OverlapLength = OverlapLength FFTLength = FFTLength FrequencyRange =“单向的”);标题(“混合”演讲)

源分离使用理想的时频面具

TF面具的应用已被证明是一种有效的方法分离所需的音频信号与竞争的声音。TF面具是一个相同大小的矩阵作为底层STFT。面具乘以中的元素与底层STFT分离所需的源。TF面具可以二进制或柔软。

源分离使用理想的二进制面具

在一个理想的二进制面具,面具细胞值是0或1。如果所需的源的力量大于其他来源结合起来的能力在一个特定的TF细胞,然后那个单元格设置为1。否则,单元格设置为0。

计算的理想二元掩模男性演讲者然后想象它。

P_M = stft (mSpeech窗口=赢,OverlapLength = OverlapLength FFTLength = FFTLength FrequencyRange =“单向的”);P_F = stft (fSpeech窗口=赢,OverlapLength = OverlapLength FFTLength = FFTLength FrequencyRange =“单向的”);[P_mix F] = stft(混合,窗口=赢,OverlapLength = OverlapLength FFTLength = FFTLength FrequencyRange =“单向的”);binaryMask = abs (P_M) > = abs (P_F);图(3)plotMask (binaryMask windowLength overlapLength, F, F)

估计男性演讲STFT乘以混合STFT男性演讲者的二进制面具。估计女演讲STFT乘以逆混合STFT的男性演讲者的二进制面具。

P_M_Hard = P_mix。* binaryMask;P_F_Hard = P_mix。* (1-binaryMask);

估计男性和女性使用逆短时音频信号FFT (ISTFT)。可视化估计和原始信号。听估计男性和女性的语音信号。

mSpeech_Hard = istft (P_M_Hard窗口=赢,OverlapLength = OverlapLength FFTLength = FFTLength FrequencyRange =“单向的”);fSpeech_Hard = istft (P_F_Hard窗口=赢,OverlapLength = OverlapLength FFTLength = FFTLength FrequencyRange =“单向的”);图(4)tiledlayout (2, 2) nexttile情节(t, mSpeech)轴(t (t)(1)(1) 1])标题(“原来男性演讲》网格)mSpeech_Hard nexttile情节(t)轴([t t(结束)1(1)1])包含(“时间(s)”)标题(“估计男性演讲》网格)fSpeech nexttile情节(t)轴([t t(结束)1(1)1])标题(“原始女性讲话”网格)fSpeech_Hard nexttile情节(t)轴([t t(结束)1(1)1])标题(“估计女性演讲》)包含(“时间(s)”网格)

声音(mSpeech_Hard Fs)
声音(fSpeech_Hard Fs)

源分离使用理想的软面具

柔软的面具,面具特遣部队细胞值之比等于权力总混合所需的电源。TF细胞中的值区间[0,1]。

计算的软面具男发言人。估计男性演讲者的STFT乘以混合STFT的男性演讲者的软面具。估计女发言人的STFT乘以混合STFT的女发言人的软面具。

估计男性和女性使用ISTFT音频信号。

softMask = abs (P_M)。/ (abs (P_F) + abs (P_M) + eps);P_M_Soft = P_mix。* softMask;P_F_Soft = P_mix。* (1-softMask);mSpeech_Soft = istft (P_M_Soft窗口=赢,OverlapLength = OverlapLength FFTLength = FFTLength FrequencyRange =“单向的”);fSpeech_Soft = istft (P_F_Soft窗口=赢,OverlapLength = OverlapLength FFTLength = FFTLength FrequencyRange =“单向的”);

可视化估计和原始信号。听估计男性和女性的语音信号。注意,结果很好,因为面具创建完整的知识男性和女性分开的信号。

图(5)tiledlayout (2, 2) nexttile情节(t, mSpeech)轴(t (t)(1)(1) 1])标题(“原来男性演讲》网格)mSpeech_Soft nexttile情节(t)轴([t t(结束)1(1)1])标题(“估计男性演讲》网格)fSpeech nexttile情节(t)轴([t t(结束)1(1)1])包含(“时间(s)”)标题(“原始女性讲话”网格)fSpeech_Soft nexttile情节(t)轴([t t(结束)1(1)1])包含(“时间(s)”)标题(“估计女性演讲》网格)

声音(mSpeech_Soft Fs)
声音(fSpeech_Soft Fs)

面具估计使用深度学习

深入学习网络的目标在这个例子中是估计上述理想软面具。相对应的网络估计面具男发言人。女发言人直接从面具男面具派生。

基本的深度学习培训计划如下所示。预测是级光谱混合(男+女)的音频。相对应的目标是理想的软面具男发言人。回归网络使用的预测均方误差最小化的输入输出和输入之间的目标。在音频输出,STFT转换回时域使用混合信号的输出幅度谱和相位。

你变换频域的音频使用短时傅里叶变换(STFT),窗口长度为128样本,127年重叠,损害窗口。你减少光谱向量的大小65年下降相对应的频率样本负频率(因为时域语音信号是真实的,这不会导致任何信息丢失)。预测的输入由连续20 STFT向量。输出是由- 20 65 -软面具。

你使用训练网络估计男性讲话。训练网络的输入是混合物(男+女)演讲音频。

STFT的目标和预测

本节说明如何生成目标和预测信号的训练数据集。

阅读训练信号由400秒左右的男性和女性演讲者的演讲,分别在4千赫采样。较低的采样率是用来加快培训。修剪的训练信号,这样他们是相同的长度。

mSpeechTrain = audioread (fullfile(数据集,“malespeech - 16 - 4 - mono - 405 secs.wav”));fSpeechTrain = audioread (fullfile(数据集,“femalespeech - 16 - 4 - mono - 405 secs.wav”));L = min(长度(mSpeechTrain), (fSpeechTrain));mSpeechTrain = mSpeechTrain (1: L);fSpeechTrain = fSpeechTrain (1: L);

读取验证信号组成的大约20秒的演讲从男性和女性的扬声器,分别在4千赫采样。修剪验证信号,这样他们是相同的长度。

mSpeechValidate = audioread (fullfile(数据集,“MaleSpeech-16-4-mono-20secs.wav”));fSpeechValidate = audioread (fullfile(数据集,“FemaleSpeech-16-4-mono-20secs.wav”));L = min(长度(mSpeechValidate), (fSpeechValidate));mSpeechValidate = mSpeechValidate (1: L);fSpeechValidate = fSpeechValidate (1: L);

规模的训练信号相同的权力。规模验证信号相同的权力。

mSpeechTrain = mSpeechTrain /规范(mSpeechTrain);fSpeechTrain = fSpeechTrain /规范(fSpeechTrain);ampAdj = max (abs ([mSpeechTrain; fSpeechTrain]));mSpeechTrain = mSpeechTrain / ampAdj;fSpeechTrain = fSpeechTrain / ampAdj;mSpeechValidate = mSpeechValidate /规范(mSpeechValidate);fSpeechValidate = fSpeechValidate /规范(fSpeechValidate);ampAdj = max (abs ([mSpeechValidate; fSpeechValidate]));mSpeechValidate = mSpeechValidate / ampAdj;fSpeechValidate = fSpeechValidate / ampAdj;

创建“鸡尾酒会”混合训练和验证。

mixTrain = mSpeechTrain + fSpeechTrain;mixTrain = mixTrain / max (mixTrain);mixValidate = mSpeechValidate + fSpeechValidate;mixValidate = mixValidate / max (mixValidate);

STFTs生成培训。

windowLength = 128;fftLength = 128;overlapLength = 128 - 1;Fs = 4000;赢得=损害(windowLength,“周期”);P_mix0 = abs (stft (mixTrain窗口=赢,OverlapLength = OverlapLength FFTLength = FFTLength FrequencyRange =“单向的”));P_M = abs (stft (mSpeechTrain窗口=赢,OverlapLength = OverlapLength FFTLength = FFTLength FrequencyRange =“单向的”));P_F = abs (stft (fSpeechTrain窗口=赢,OverlapLength = OverlapLength FFTLength = FFTLength FrequencyRange =“单向的”));

采取混合STFT的日志。标准化值的平均值和标准偏差。

P_mix =日志(P_mix0 + eps);议员=意味着(P_mix (:));SP =性病(P_mix (:));P_mix = (P_mix - MP) / SP;

生成验证STFTs。采取混合STFT的日志。标准化值的平均值和标准偏差。

P_Val_mix0 = stft (mixValidate窗口=赢,OverlapLength = OverlapLength FFTLength = FFTLength FrequencyRange =“单向的”);P_Val_M = abs (stft (mSpeechValidate窗口=赢,OverlapLength = OverlapLength FFTLength = FFTLength FrequencyRange =“单向的”));P_Val_F = abs (stft (fSpeechValidate窗口=赢,OverlapLength = OverlapLength FFTLength = FFTLength FrequencyRange =“单向的”));P_Val_mix =日志(abs (P_Val_mix0) + eps);议员=意味着(P_Val_mix (:));SP =性病(P_Val_mix (:));P_Val_mix = (P_Val_mix - MP) / SP;

训练神经网络时简单的输入到网络有相当平稳分布和规范化。检查数据分布是光滑的,情节的直方图STFT训练数据的值。

图(6)直方图(P_mix EdgeColor =“没有”归一化=“pdf”)包含(“输入值”)ylabel (“概率密度”)

计算训练软面具。使用这个面具作为目标训练网络时的信号。

maskTrain = P_M。/ (P_M + P_F + eps);

计算验证软面具。使用这个面具来评估培训网络发出的面具。

maskValidate = P_Val_M。/ (P_Val_M + P_Val_F + eps);

检查目标数据分布平滑,画一个面具的训练数据值的直方图。

图(7)直方图(maskTrain EdgeColor =“没有”归一化=“pdf”)包含(“输入值”)ylabel (“概率密度”)

创建块大小(65年,20)的预测和目标信号。为了得到更多的训练样本,利用10段连续块之间的重叠。

seqLen = 20;seqOverlap = 10;mixSequences = 0 (1 + fftLength / 2, seqLen 1 0);maskSequences = 0 (1 + fftLength / 2, seqLen 1 0);loc = 1;loc <大小(P_mix 2)——seqLen mixSequences(::,:,结束+ 1)= P_mix (:, loc: loc + seqLen-1);maskSequences(:,:,:,结束+ 1)= maskTrain (:, loc: loc + seqLen-1);loc = loc + seqOverlap;结束

创建块大小(65年,20)验证的预测和目标信号。

mixValSequences = 0 (1 + fftLength / 2, seqLen 1 0);maskValSequences = 0 (1 + fftLength / 2, seqLen 1 0);seqOverlap = seqLen;loc = 1;loc <大小(P_Val_mix 2)——seqLen mixValSequences(::,:,结束+ 1)= P_Val_mix (:, loc: loc + seqLen-1);maskValSequences(:,:,:,结束+ 1)= maskValidate (:, loc: loc + seqLen-1);loc = loc + seqOverlap;结束

重塑训练和验证信号。

mixSequencesT =重塑(mixSequences [1 1 (1 + fftLength / 2) * seqLen大小(mixSequences 4)]);mixSequencesV =重塑(mixValSequences [1 1 (1 + fftLength / 2) * seqLen大小(mixValSequences 4)]);maskSequencesT =重塑(maskSequences [1 1 (1 + fftLength / 2) * seqLen大小(maskSequences 4)]);maskSequencesV =重塑(maskValSequences [1 1 (1 + fftLength / 2) * seqLen大小(maskValSequences 4)]);

定义深入学习网络

定义网络的层。指定输入大小的图像大小1 - - 1 - 1300。定义两个隐藏的完全连接层,每1300个神经元。遵循每个隐藏完全连接层与乙状结肠层。批均值和标准差标准化层规范化的输出。添加一个完全连接层有1300个神经元,紧随其后的是一个回归层。

numNodes = (1 + fftLength / 2) * seqLen;层= [imageInputLayer ([1 1 (1 + fftLength / 2) * seqLen],标准化=“没有”)fullyConnectedLayer (numNodes) BiasedSigmoidLayer (6) batchNormalizationLayer dropoutLayer (0.1) fullyConnectedLayer (numNodes) BiasedSigmoidLayer (6) batchNormalizationLayer dropoutLayer (0.1) fullyConnectedLayer (numNodes) BiasedSigmoidLayer (0) regressionLayer];

指定的培训选项网络。集MaxEpochs3所以网络三个通过训练数据。集MiniBatchSize64年看着这网络64年一次训练信号。集情节训练进步生成块显示培训进展随着迭代次数的增加。集详细的禁用打印表输出对应于数据图中所示的命令行窗口。集洗牌every-epoch洗牌训练序列,每一个时代的开始。集LearnRateSchedule分段减少指定的学习速率的因素(0.1)每次一定数量的时代(1)已经过去了。集ValidationData验证预测和目标。集ValidationFrequency这样,验证每个时期均方误差计算一次。下面的例子使用了自适应时刻估计(亚当)解算器。

maxEpochs = 3;miniBatchSize = 64;选择= trainingOptions (“亚当”,MaxEpochs = MaxEpochs,MiniBatchSize = MiniBatchSize,SequenceLength =“最长”,洗牌=“every-epoch”,Verbose = 0,情节=“训练进步”,ValidationFrequency =地板(大小(mixSequencesT 4) / miniBatchSize),ValidationData = {mixSequencesV, maskSequencesV},LearnRateSchedule =“分段”,LearnRateDropFactor = 0.9,LearnRateDropPeriod = 1);

深入学习网络训练

列车网络与指定的培训选项和层体系结构使用trainNetwork。因为训练集很大,培训过程可能需要几分钟时间。加载一个pre-trained网络,集speedupExample真正的

speedupExample =;如果speedupExample CocktailPartyNet = trainNetwork (mixSequencesT、maskSequencesT层,选择);其他的s =负载(fullfile(数据集,“CocktailPartyNet.mat”));CocktailPartyNet = s.CocktailPartyNet;结束

通过验证预测网络。输出是估计的面具。重塑估计面具。

estimatedMasks0 =预测(CocktailPartyNet mixSequencesV);estimatedMasks0 = estimatedMasks0。”;estimatedMasks0 =重塑(estimatedMasks0 1 + fftLength / 2元素个数(estimatedMasks0) / (1 + fftLength / 2));

评估深度学习网络

画一个柱状图之间的误差的实际和预期的面具。

图(8)直方图(maskValSequences (:)——estimatedMasks0 (:), EdgeColor =“没有”归一化=“pdf”)包含(“面具错误”)ylabel (“概率密度”)

评估软面具估计

估计男性和女性柔软的面具。阈值估计男性和女性二进制面具的面具。

SoftMaleMask = estimatedMasks0;SoftFemaleMask = 1 - SoftMaleMask;

缩短混合STFT估计面具的大小相匹配。

P_Val_mix0 = P_Val_mix0(:, 1:尺寸(SoftMaleMask 2));

混合STFT乘以男性软面具估计男性STFT的演讲。

P_Male = P_Val_mix0。* SoftMaleMask;

使用ISTFT估计男性音频信号。音频。

maleSpeech_est_soft = istft (P_Male窗口=赢,OverlapLength = OverlapLength FFTLength = FFTLength FrequencyRange =“单向的”,ConjugateSymmetric = true);maleSpeech_est_soft = maleSpeech_est_soft / max (abs (maleSpeech_est_soft));

确定一系列分析和相关时间向量。

范围= windowLength:元素个数(maleSpeech_est_soft) -windowLength;t = * (1 / Fs);

可视化估计和男性原始语音信号。听估计软面具男讲话。

声音(maleSpeech_est_soft(范围)、Fs)图(9)tiledlayout (2, 1) nexttile情节(t, mSpeechValidate(范围)标题(“原来男性演讲》)包含(“时间(s)”网格)nexttile情节(t, maleSpeech_est_soft(范围)包含(“时间(s)”)标题(“估计男性演讲(软面具)”网格)

用混合STFT的女性柔软的面具来估计女性STFT的演讲。使用ISTFT估计男性音频信号。音频。

P_Female = P_Val_mix0。* SoftFemaleMask;femaleSpeech_est_soft = istft (P_Female窗口=赢,OverlapLength = OverlapLength FFTLength = FFTLength FrequencyRange =“单向的”,ConjugateSymmetric = true);femaleSpeech_est_soft = femaleSpeech_est_soft / max (femaleSpeech_est_soft);

可视化估计和原始女性信号。听估计女性讲话。

声音(femaleSpeech_est_soft(范围)、Fs)图(10)tiledlayout (2, 1) nexttile情节(t, fSpeechValidate(范围)标题(“原始女性讲话”网格)nexttile情节(t, femaleSpeech_est_soft(范围)包含(“时间(s)”)标题(“估计女性讲话(软面具)”网格)

评价二元掩模估计

阈值估计男性和女性二进制面具的面具。

HardMaleMask = SoftMaleMask > = 0.5;HardFemaleMask = SoftMaleMask < 0.5;

用混合STFT的男二元掩模的估计男STFT的演讲。使用ISTFT估计男性音频信号。音频。

P_Male = P_Val_mix0。* HardMaleMask;maleSpeech_est_hard = istft (P_Male窗口=赢,OverlapLength = OverlapLength FFTLength = FFTLength FrequencyRange =“单向的”,ConjugateSymmetric = true);maleSpeech_est_hard = maleSpeech_est_hard / max (maleSpeech_est_hard);

可视化估计和男性原始语音信号。听估计二进制面具男讲话。

声音(maleSpeech_est_hard(范围)、Fs)图(11)tiledlayout (2, 1) nexttile情节(t, mSpeechValidate(范围)标题(“原来男性演讲》网格)nexttile情节(t, maleSpeech_est_hard(范围)包含(“时间(s)”)标题(“估计男性演讲(二进制掩码)"网格)

用混合STFT的女性二元掩模的估计男性STFT的演讲。使用ISTFT估计男性音频信号。音频。

P_Female = P_Val_mix0。* HardFemaleMask;femaleSpeech_est_hard = istft (P_Female窗口=赢,OverlapLength = OverlapLength FFTLength = FFTLength FrequencyRange =“单向的”,ConjugateSymmetric = true);femaleSpeech_est_hard = femaleSpeech_est_hard / max (femaleSpeech_est_hard);

可视化估计和原始女性语音信号。听估计女性讲话。

声音(femaleSpeech_est_hard(范围)、Fs)图(12)tiledlayout (2, 1) nexttile情节(t, fSpeechValidate(范围)标题(“原始女性讲话”网格)nexttile情节(t, femaleSpeech_est_hard(范围)标题(“估计女性讲话(二进制掩码)”网格)

比较STFTs一秒钟的混合段,原始的男性和女性,分别和估算的男性和女性。

= 7 e4:7.4e4范围;图(13)stft (mixValidate(范围),Fs,窗口=赢,OverlapLength = 64, FFTLength = FFTLength FrequencyRange =“单向的”);标题(“混合STFT”)

图(14)tiledlayout (3,1) nexttile stft (mSpeechValidate(范围),Fs,窗口=赢,OverlapLength = 64, FFTLength = FFTLength FrequencyRange =“单向的”);标题(“男性STFT(实际)”)nexttile stft (maleSpeech_est_soft(范围),Fs,窗口=赢,OverlapLength = 64, FFTLength = FFTLength FrequencyRange =“单向的”);标题(“男性STFT(估计-软面具)”)nexttile stft (maleSpeech_est_hard(范围),Fs,窗口=赢,OverlapLength = 64, FFTLength = FFTLength FrequencyRange =“单向的”);标题(“男性STFT(估计-二进制掩码)”);

图(15)tiledlayout (3,1) nexttile stft (fSpeechValidate(范围),Fs,窗口=赢,OverlapLength = 64, FFTLength = FFTLength FrequencyRange =“单向的”);标题(“女性STFT(实际)”)nexttile stft (femaleSpeech_est_soft(范围),Fs,窗口=赢,OverlapLength = 64, FFTLength = FFTLength FrequencyRange =“单向的”);标题(“女性STFT(估计-软面具)”)nexttile stft (femaleSpeech_est_hard(范围),Fs,窗口=赢,OverlapLength = 64, FFTLength = FFTLength FrequencyRange =“单向的”);标题(“女性STFT(估计-二进制掩码)”)

引用

[1]“概率Binary-Mask鸡尾酒会源分离卷积深层神经网络”,2015年安德鲁·辛普森jr。

相关的话题