【语音增强】基于matlab Coherence-based语音反混响【含Matlab源码 1026期】

举报
海神之光 发表于 2022/05/29 00:59:48 2022/05/29
【摘要】 一、获取代码方式 获取代码方式1: 完整代码已上传我的资源:【语音增强】基于matlab Coherence-based语音反混响【含Matlab源码 1026期】 获取代码方式2: 通过订阅紫极神光...

一、获取代码方式

获取代码方式1:
完整代码已上传我的资源:【语音增强】基于matlab Coherence-based语音反混响【含Matlab源码 1026期】

获取代码方式2:
通过订阅紫极神光博客付费专栏,凭支付凭证,私信博主,可获得此代码。

备注:
订阅紫极神光博客付费专栏,可免费获得1份代码(有效期为订阅日起,三天内有效);

二、部分源代码

%DEMO_CDR_DEREVERB
%
% Demonstration of CDR-based noise and reverberation suppression.
%演示CDR-based噪声和混响抑制
% To use this with your own recordings:
% 1. Change wave filename
% 2. Adapt microphone spacing (cfg.d)
% 2. Adapt cfg.TDOA, or use the DOA-independent estimator (estimate_cdr_nodoa)
%
% Reference:
% Andreas Schwarz, Walter Kellermann, "Coherent-to-Diffuse Power Ratio
% Estimation for Dereverberation", IEEE/ACM Trans. on Audio, Speech and
% Lang. Proc., 2015 (under review); preprint available: arXiv:1502.03784
% PDF: http://arxiv.org/pdf/1502.03784
%
% Andreas Schwarz (schwarz@lnt.de)
% Multimedia Communications and Signal Processing
% Friedrich-Alexander-Universitaet Erlangen-Nuernberg (FAU)
% Cauerstr. 7, 91058 Erlangen, Germany

addpath(genpath('lib'));

%% filterbank initialization
cfg.K = 512; % FFT size
cfg.N = 128; % frame shift
cfg.Lp = 1024; % prototype filter length
%p=IterLSDesign(cfg.Lp,cfg.K,cfg.N);
load('lib/filterbank/prototype_K512_N128_Lp1024.mat');

%% algorithm and scenario configuration
cfg.fs = 16000;      % sampling rate [Hz]
cfg.c = 342;         % speed of sound [m/s]
cfg.d_mic = 0.08;   % mic spacing [m]

% all estimators except estimate_cdr_nodoa require the TDOA of the signal; make sure
% to adapt this when loading another wave file
cfg.TDOA = 2.15e-04; % ground truth for wav/roomC-2m-75deg.wav

cfg.nr.lambda = 0.68; % smoothing factor for PSD estimation
cfg.nr.mu = 1.3;     % noise overestimation factor
cfg.nr.floor = 0.1;  % minimum gain
%cfg.nr.alpha = 1; cfg.nr.beta = 1; % power subtraction
cfg.nr.alpha = 2; cfg.nr.beta = 0.5; % magnitude subtraction
%cfg.nr.alpha = 2; cfg.nr.beta = 1; % Wiener filter

%cfg.estimator = @estimate_cdr_unbiased;           % unbiased estimator (CDRprop1)
cfg.estimator = @estimate_cdr_robust_unbiased;    % unbiased, "robust" estimator (CDRprop2)
%cfg.estimator = @estimate_cdr_nodoa;              % DOA-independent estimator (CDRprop3)
%cfg.estimator = @estimate_cdr_nodiffuse;          % noise coherence-independent estimator (CDRprop4; does not work for TDOA -> 0!)

%% preparation
[x,fs_in] = audioread('wav/roomC-2m-75deg.wav');
x = resample(x,cfg.fs,fs_in);

%% Signal processing
% The algorithm itself is real-time capable, i.e., no processing of the entire
% utterance is necessary. Here however, for efficiency of the MATLAB implementation,
% the entire signal is processed at once.

fprintf('Performing signal enhancement... ');tic;

% analysis filterbank
X=DFTAnaRealEntireSignal(x,cfg.K,cfg.N,p);

% estimate PSD and coherence
Pxx = estimate_psd(X,cfg.nr.lambda);
Cxx = estimate_cpsd(X(:,:,1),X(:,:,2),cfg.nr.lambda)./sqrt(Pxx(:,:,1).*Pxx(:,:,2));

frequency = linspace(0,cfg.fs/2,cfg.K/2+1)'; % frequency axis

% define coherence models
Css = exp(1j * 2 * pi * frequency * cfg.TDOA);              % target signal coherence; not required for estimate_cdr_nodoa
Cnn = sinc(2 * frequency * cfg.d_mic/cfg.c); % diffuse noise coherence; not required for estimate_cdr_nodiffuse

% apply CDR estimator (=SNR)
 

 
weights = min(weights,1);

% postfilter input is computed from averaged PSDs of both microphones
Postfilter_input = sqrt(mean(abs(X).^2,3)) .* exp(1j*angle(X(:,:,1)));

% apply postfilter
Processed = weights .* Postfilter_input;

% synthesis filterbank
y = DFTSynRealEntireSignal(Processed,cfg.K,cfg.N,p);
fprintf('done (%.2fs).\n', toc);

%% output
% write output file
audiowrite('wav/out.wav',y,cfg.fs);

%% visualization
figure(1)
subplot(211)
imagesc(10*log10(SNR))
set(gca,'YDir','normal')
caxis([-15 15])
colorbar
title('Estimated CDR (=SNR) [dB]')
xlabel('frame index')
ylabel('subband index')
subplot(212)
imagesc(weights)
set(gca,'YDir','normal')
caxis([0 1])
colorbar
title('Filter gain')
xlabel('frame index')
ylabel('subband index')


  
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113

三、运行结果

在这里插入图片描述

四、matlab版本及参考文献

1 matlab版本
2014a

2 参考文献
[1]韩纪庆,张磊,郑铁然.语音信号处理(第3版)[M].清华大学出版社,2019.
[2]柳若边.深度学习:语音识别技术实践[M].清华大学出版社,2019.

文章来源: qq912100926.blog.csdn.net,作者:海神之光,版权归原作者所有,如需转载,请联系作者。

原文链接:qq912100926.blog.csdn.net/article/details/118034635

【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。