3636>>> istft = ISTFT(sample_rate=fs)
3737
3838>>> Xs = stft(xs_diffused_noise)
39+ >>> Ns = stft(nn_diff)
3940>>> XXs = cov(Xs)
41+ >>> NNs = cov(Ns)
4042>>> tdoas = gccphat(XXs)
4143>>> Ys_ds = delaysum(Xs, tdoas)
4244>>> ys_ds = istft(Ys_ds)
5052>>> mics[3,:] = torch.FloatTensor([+0.05, +0.05, +0.00])
5153>>> srpphat = SrpPhat(mics=mics)
5254>>> doas = srpphat(XXs)
53- >>> Ys_mvdr = mvdr(Xs, XXs , doas, doa_mode=True, mics=mics, fs=fs)
55+ >>> Ys_mvdr = mvdr(Xs, NNs , doas, doa_mode=True, mics=mics, fs=fs)
5456>>> ys_mvdr = istft(Ys_mvdr)
5557
5658>>> # Mvdr Beamforming with MUSIC localization
5759>>> music = Music(mics=mics)
5860>>> doas = music(XXs)
59- >>> Ys_mvdr2 = mvdr(Xs, XXs , doas, doa_mode=True, mics=mics, fs=fs)
61+ >>> Ys_mvdr2 = mvdr(Xs, NNs , doas, doa_mode=True, mics=mics, fs=fs)
6062>>> ys_mvdr2 = istft(Ys_mvdr2)
6163
6264>>> # GeV Beamforming
6365>>> gev = Gev()
6466>>> Xs = stft(xs_localized_noise)
6567>>> Ss = stft(ss)
66- >>> Nn = stft(nn_loc)
68+ >>> Ns = stft(nn_loc)
6769>>> SSs = cov(Ss)
68- >>> NNs = cov(Nn )
70+ >>> NNs = cov(Ns )
6971>>> Ys_gev = gev(Xs, SSs, NNs)
7072>>> ys_gev = istft(Ys_gev)
7173
@@ -361,9 +363,11 @@ class Mvdr(torch.nn.Module):
361363 >>> istft = ISTFT(sample_rate=fs)
362364 >>>
363365 >>> Xs = stft(xs)
366+ >>> Ns = stft(xs_noise)
364367 >>> XXs = cov(Xs)
368+ >>> NNs = cov(Ns)
365369 >>> tdoas = gccphat(XXs)
366- >>> Ys = mvdr(Xs, XXs , tdoas)
370+ >>> Ys = mvdr(Xs, NNs , tdoas)
367371 >>> ys = istft(Ys)
368372 """
369373
@@ -376,7 +380,7 @@ def __init__(self, eps=1e-20):
376380 def forward (
377381 self ,
378382 Xs ,
379- XXs ,
383+ NNs ,
380384 localization_tensor ,
381385 doa_mode = False ,
382386 mics = None ,
@@ -393,8 +397,8 @@ def forward(
393397 A batch of audio signals in the frequency domain.
394398 The tensor must have the following format:
395399 (batch, time_step, n_fft/2 + 1, 2, n_mics)
396- XXs : tensor
397- The covariance matrices of the input signal. The tensor must
400+ NNs : tensor
401+ The covariance matrices of the noise signal. The tensor must
398402 have the format (batch, time_steps, n_fft/2 + 1, 2, n_mics + n_pairs)
399403 localization_tensor : tensor
400404 A tensor containing either time differences of arrival (TDOAs)
@@ -433,12 +437,12 @@ def forward(
433437 As = steering (taus = taus , n_fft = n_fft )
434438
435439 # Perform mvdr
436- Ys = Mvdr ._mvdr (Xs = Xs , XXs = XXs , As = As )
440+ Ys = Mvdr ._mvdr (Xs = Xs , NNs = NNs , As = As )
437441
438442 return Ys
439443
440444 @staticmethod
441- def _mvdr (Xs , XXs , As , eps = 1e-20 ):
445+ def _mvdr (Xs , NNs , As , eps = 1e-20 ):
442446 """Perform minimum variance distortionless response beamforming.
443447
444448 Arguments
@@ -447,8 +451,8 @@ def _mvdr(Xs, XXs, As, eps=1e-20):
447451 A batch of audio signals in the frequency domain.
448452 The tensor must have the following format:
449453 (batch, time_step, n_fft/2 + 1, 2, n_mics).
450- XXs : tensor
451- The covariance matrices of the input signal. The tensor must
454+ NNs : tensor
455+ The covariance matrices of the noise signal. The tensor must
452456 have the format (batch, time_steps, n_fft/2 + 1, 2, n_mics + n_pairs).
453457 As : tensor
454458 The steering vector to point in the direction of
@@ -457,14 +461,14 @@ def _mvdr(Xs, XXs, As, eps=1e-20):
457461 """
458462
459463 # Get unique covariance values to reduce the number of computations
460- XXs_val , XXs_idx = torch .unique (XXs , return_inverse = True , dim = 1 )
464+ NNs_val , NNs_idx = torch .unique (NNs , return_inverse = True , dim = 1 )
461465
462466 # Inverse covariance matrices
463- XXs_inv = eig .inv (XXs_val )
467+ NNs_inv = eig .inv (NNs_val )
464468
465469 # Capture real and imaginary parts, and restore time steps
466- XXs_inv_re = XXs_inv [..., 0 ][:, XXs_idx ]
467- XXs_inv_im = XXs_inv [..., 1 ][:, XXs_idx ]
470+ NNs_inv_re = NNs_inv [..., 0 ][:, NNs_idx ]
471+ NNs_inv_im = NNs_inv [..., 1 ][:, NNs_idx ]
468472
469473 # Decompose steering vector
470474 AsC_re = As [..., 0 , :].unsqueeze (4 )
@@ -473,22 +477,22 @@ def _mvdr(Xs, XXs, As, eps=1e-20):
473477 AsT_im = - 1.0 * AsC_im .transpose (3 , 4 )
474478
475479 # Project
476- XXs_inv_AsC_re = torch .matmul (XXs_inv_re , AsC_re ) - torch .matmul (
477- XXs_inv_im , AsC_im
480+ NNs_inv_AsC_re = torch .matmul (NNs_inv_re , AsC_re ) - torch .matmul (
481+ NNs_inv_im , AsC_im
478482 )
479- XXs_inv_AsC_im = torch .matmul (XXs_inv_re , AsC_im ) + torch .matmul (
480- XXs_inv_im , AsC_re
483+ NNs_inv_AsC_im = torch .matmul (NNs_inv_re , AsC_im ) + torch .matmul (
484+ NNs_inv_im , AsC_re
481485 )
482486
483487 # Compute the gain
484488 alpha = 1.0 / (
485- torch .matmul (AsT_re , XXs_inv_AsC_re )
486- - torch .matmul (AsT_im , XXs_inv_AsC_im )
489+ torch .matmul (AsT_re , NNs_inv_AsC_re )
490+ - torch .matmul (AsT_im , NNs_inv_AsC_im )
487491 )
488492
489493 # Get the unmixing coefficients
490- Ws_re = torch .matmul (XXs_inv_AsC_re , alpha ).squeeze (4 )
491- Ws_im = - torch .matmul (XXs_inv_AsC_im , alpha ).squeeze (4 )
494+ Ws_re = torch .matmul (NNs_inv_AsC_re , alpha ).squeeze (4 )
495+ Ws_im = - torch .matmul (NNs_inv_AsC_im , alpha ).squeeze (4 )
492496
493497 # Applying MVDR
494498 Xs_re = Xs [..., 0 , :]
0 commit comments