audio_zen/acoustics/beamforming.py
def estimate_psd(mask: torch.Tensor, complex_matrix: ComplexTensor, eps: float = 1e-5) -> ComplexTensor:
        """
        Power Spectral Density Covariance (PSD) estimation

        Args:
            mask: [B, F, T], TF-masks (real)
            complex_matrix: [B, C, F, T], complex-valued matrix of short-term Fourier transform coefficients
            eps:

        Return:
            [B, F, C, C]
        """
        # [B, C, F, T] => [B, F, C, T]
        complex_matrix = complex_matrix.transpose(1, 2)
        # [B, F, T] => [B, F, 1, T]
        mask = mask.unsqueeze(-2)
        # [B, F, C, C]: einsum("...it,...jt->...ij", spec * mask, spec.conj())
        nominator = (complex_matrix * mask) @ complex_matrix.conj_transpose(-1, -2)
        # [B, F, 1, T] => [B, F, 1, 1]
        denominator = torch.clamp(mask.sum(-1, keepdims=True), min=eps)
        # [B, F, C, C]
        psd = nominator / denominator
        # stabilize
        return ComplexTensor(psd.real, psd.imag + torch.tensor(eps))

        Power Spectral Density Covariance (PSD) estimation

        Args:
            mask: [B, F, T], TF-masks (real)
            complex_matrix: [B, C, F, T], complex-valued matrix of short-term Fourier transform coefficients
            eps:

        Return:
            [B, F, C, C]
        
Power Spectral Density Covariance (PSD) estimation
Power Spectral Density Covariance ( PSD ) estimation
def estimate_psd(mask: torch.Tensor, complex_matrix: ComplexTensor, eps: float = 1e-5) -> ComplexTensor:
        complex_matrix = complex_matrix.transpose(1, 2)
        mask = mask.unsqueeze(-2)
        nominator = (complex_matrix * mask) @ complex_matrix.conj_transpose(-1, -2)
        denominator = torch.clamp(mask.sum(-1, keepdims=True), min=eps)
        psd = nominator / denominator
        return ComplexTensor(psd.real, psd.imag + torch.tensor(eps))
def estimate_psd ( mask : torch . Tensor , complex_matrix : ComplexTensor , eps : float = 1e-5 ) -> ComplexTensor : complex_matrix = complex_matrix . transpose ( 1 , 2 ) mask = mask . unsqueeze ( - 2 ) nominator = ( complex_matrix * mask ) @ complex_matrix . conj_transpose ( - 1 , - 2 ) denominator = torch . clamp ( mask . sum ( - 1 , keepdims = True ) , min = eps ) psd = nominator / denominator return ComplexTensor ( psd . real , psd . imag + torch . tensor ( eps ) )
Power Spectral Density Covariance (PSD) estimation
Power Spectral Density Covariance ( PSD ) estimation
"""
        Power Spectral Density Covariance (PSD) estimation

        Args:
            mask: [B, F, T], TF-masks (real)
            complex_matrix: [B, C, F, T], complex-valued matrix of short-term Fourier transform coefficients
            eps:

        Return:
            [B, F, C, C]
        """ # [B, C, F, T] => [B, F, C, T] # [B, F, T] => [B, F, 1, T] # [B, F, C, C]: einsum("...it,...jt->...ij", spec * mask, spec.conj()) # [B, F, 1, T] => [B, F, 1, 1] # [B, F, C, C] # stabilize
mask
torch.Tensor
None
complex_matrix
ComplexTensor
[B, C, F, T], complex-valued matrix of short-term Fourier transform coefficients
[ B C F T ] complex - valued matrix of short - term Fourier transform coefficients
eps
float
None