class_docstr: Steered-Response Power with Phase Transform Localization.
  
  Arguments
  ---------
  mics : tensor
      The cartesian coordinates (xyz) in meters of each microphone.
      The tensor must have the following format (n_mics, 3).
  space : string
      If this parameter is set to 'sphere', the localization will
      be done in 3D by searching in a sphere of possible doas. If
      it set to 'circle', the search will be done in 2D by searching
      in a circle. By default, this parameter is set to 'sphere'.
      Note: The 'circle' option isn't implemented yet.
  sample_rate : int
      The sample rate in Hertz of the signals to perform SRP-PHAT on.
      By default, this parameter is set to 16000 Hz.
  speed_sound : float
      The speed of sound in the medium. The speed is expressed in meters
      per second and the default value of this parameter is 343 m/s.
  eps : float
      A small value to avoid errors like division by 0. The default value
      of this parameter is 1e-20.
  
  Example
  -------
  >>> import torch
  
  >>> from speechbrain.dataio.dataio import read_audio
  >>> from speechbrain.processing.features import STFT
  >>> from speechbrain.processing.multi_mic import Covariance
  >>> from speechbrain.processing.multi_mic import SrpPhat
  
  >>> xs_speech = read_audio('tests/samples/multi-mic/speech_-0.82918_0.55279_-0.082918.flac')
  >>> xs_noise = read_audio('tests/samples/multi-mic/noise_diffuse.flac')
  >>> fs = 16000
  
  >>> xs_speech = xs_speech.unsqueeze(0) # [batch, time, channels]
  >>> xs_noise = xs_noise.unsqueeze(0)
  
  >>> ss1 = xs_speech
  >>> ns1 = 0.05 * xs_noise
  >>> xs1 = ss1 + ns1
  
  >>> ss2 = xs_speech
  >>> ns2 = 0.20 * xs_noise
  >>> xs2 = ss2 + ns2
  
  >>> ss = torch.cat((ss1,ss2), dim=0)
  >>> ns = torch.cat((ns1,ns2), dim=0)
  >>> xs = torch.cat((xs1,xs2), dim=0)
  
  >>> mics = torch.zeros((4,3), dtype=torch.float)
  >>> mics[0,:] = torch.FloatTensor([-0.05, -0.05, +0.00])
  >>> mics[1,:] = torch.FloatTensor([-0.05, +0.05, +0.00])
  >>> mics[2,:] = torch.FloatTensor([+0.05, +0.05, +0.00])
  >>> mics[3,:] = torch.FloatTensor([+0.05, +0.05, +0.00])
  
  >>> stft = STFT(sample_rate=fs)
  >>> cov = Covariance()
  >>> srpphat = SrpPhat(mics=mics)
  
  >>> Xs = stft(xs)
  >>> XXs = cov(Xs)
  >>> doas = srpphat(XXs)
class_docstr_tok: ["Steered-Response","Power","with","Phase","Transform","Localization",".","Arguments","--","--","--","--","-","mics",":","tensor","The","cartesian","coordinates","(","xyz",")","in","meters","of","each","microphone",".","The","tensor","must","have","the","following","format","(","n_mics",",","3",")",".","space",":","string","If","this","parameter","is","set","to","'sphere","'",",","the","localization","will","be","done","in","3D","by","searching","in","a","sphere","of","possible","doas",".","If","it","set","to","'circle","'",",","the","search","will","be","done","in","2D","by","searching","in","a","circle",".","By","default",",","this","parameter","is","set","to","'sphere","'",".","Note",":","The","'circle","'","option","is","n't","implemented","yet",".","sample_rate",":","int","The","sample","rate","in","Hertz","of","the","signals","to","perform","SRP-PHAT","on",".","By","default",",","this","parameter","is","set","to","16000","Hz",".","speed_sound",":","float","The","speed","of","sound","in","the","medium",".","The","speed","is","expressed","in","meters","per","second","and","the","default","value","of","this","parameter","is","343","m\/s",".","eps",":","float","A","small","value","to","avoid","errors","like","division","by","0",".","The","default","value","of","this","parameter","is","1e-20",".","Example","--","--","--","-",">",">",">","import","torch",">",">",">","from","speechbrain.dataio.dataio","import","read_audio",">",">",">","from","speechbrain.processing.features","import","STFT",">",">",">","from","speechbrain.processing.multi_mic","import","Covariance",">",">",">","from","speechbrain.processing.multi_mic","import","SrpPhat",">",">",">","xs_speech","=","read_audio","(","'tests\/samples\/multi-mic\/speech_-0.82918_0.55279_-0.082918.flac","'",")",">",">",">","xs_noise","=","read_audio","(","'tests\/samples\/multi-mic\/noise_diffuse.flac","'",")",">",">",">","fs","=","16000",">",">",">","xs_speech","=","xs_speech.unsqueeze","(","0",")","#","[","batch",",","time",",","channels","]",">",">",">","xs_noise","=","xs_noise.unsqueeze","(","0",")",">",">",">","ss1","=","xs_speech",">",">",">","ns1","=","0.05","*","xs_noise",">",">",">","xs1","=","ss1","+","ns1",">",">",">","ss2","=","xs_speech",">",">",">","ns2","=","0.20","*","xs_noise",">",">",">","xs2","=","ss2","+","ns2",">",">",">","ss","=","torch.cat","(","(","ss1",",","ss2",")",",","dim=0",")",">",">",">","ns","=","torch.cat","(","(","ns1",",","ns2",")",",","dim=0",")",">",">",">","xs","=","torch.cat","(","(","xs1",",","xs2",")",",","dim=0",")",">",">",">","mics","=","torch.zeros","(","(","4,3",")",",","dtype=torch.float",")",">",">",">","mics","[","0",",",":","]","=","torch.FloatTensor","(","[","-0.05",",","-0.05",",","+0.00","]",")",">",">",">","mics","[","1",",",":","]","=","torch.FloatTensor","(","[","-0.05",",","+0.05",",","+0.00","]",")",">",">",">","mics","[","2",",",":","]","=","torch.FloatTensor","(","[","+0.05",",","+0.05",",","+0.00","]",")",">",">",">","mics","[","3",",",":","]","=","torch.FloatTensor","(","[","+0.05",",","+0.05",",","+0.00","]",")",">",">",">","stft","=","STFT","(","sample_rate=fs",")",">",">",">","cov","=","Covariance","(",")",">",">",">","srpphat","=","SrpPhat","(","mics=mics",")",">",">",">","Xs","=","stft","(","xs",")",">",">",">","XXs","=","cov","(","Xs",")",">",">",">","doas","=","srpphat","(","XXs",")"]
docstr: Perform srp-phat to find the direction of arrival
  of the sound source. The result is a tensor containing the directions
  of arrival (xyz coordinates (in meters) in the direction of the sound source).
  The output tensor has the format: (batch, time_steps, 3).
  
  Arguments
  ---------
  XXs : tensor
      The covariance matrices of the input signal. The tensor must
      have the format (batch, time_steps, n_fft/2 + 1, 2, n_mics + n_pairs).
  As : tensor
      The steering vector that cover the all the potential directions
      of arrival. The tensor must have the format
      (n_doas, n_fft/2 + 1, 2, n_mics).
  doas : tensor
      All the possible directions of arrival that will be scanned. The
      tensor must have the format (n_doas, 3).
code: def _srp_phat(XXs, As, doas, eps=1e-20):
      """Perform srp-phat to find the direction of arrival
      of the sound source. The result is a tensor containing the directions
      of arrival (xyz coordinates (in meters) in the direction of the sound source).
      The output tensor has the format: (batch, time_steps, 3).
  
      Arguments
      ---------
      XXs : tensor
          The covariance matrices of the input signal. The tensor must
          have the format (batch, time_steps, n_fft/2 + 1, 2, n_mics + n_pairs).
      As : tensor
          The steering vector that cover the all the potential directions
          of arrival. The tensor must have the format
          (n_doas, n_fft/2 + 1, 2, n_mics).
      doas : tensor
          All the possible directions of arrival that will be scanned. The
          tensor must have the format (n_doas, 3).
      """
  
      # Putting on the right device
      As = As.to(XXs.device)
      doas = doas.to(XXs.device)
  
      # Get useful dimensions
      n_mics = As.shape[3]
  
      # Get the indices for the pairs of microphones
      idx = torch.triu_indices(n_mics, n_mics)
  
      # Generate the demixing vector from the steering vector
      As_1_re = As[:, :, 0, idx[0, :]]
      As_1_im = As[:, :, 1, idx[0, :]]
      As_2_re = As[:, :, 0, idx[1, :]]
      As_2_im = As[:, :, 1, idx[1, :]]
      Ws_re = As_1_re * As_2_re + As_1_im * As_2_im
      Ws_im = As_1_re * As_2_im - As_1_im * As_2_re
      Ws_re = Ws_re.reshape(Ws_re.shape[0], -1)
      Ws_im = Ws_im.reshape(Ws_im.shape[0], -1)
  
      # Get unique covariance values to reduce the number of computations
      XXs_val, XXs_idx = torch.unique(XXs, return_inverse=True, dim=1)
  
      # Perform the phase transform
      XXs_re = XXs_val[:, :, :, 0, :]
      XXs_im = XXs_val[:, :, :, 1, :]
      XXs_re = XXs_re.reshape((XXs_re.shape[0], XXs_re.shape[1], -1))
      XXs_im = XXs_im.reshape((XXs_im.shape[0], XXs_im.shape[1], -1))
      XXs_abs = torch.sqrt(XXs_re**2 + XXs_im**2) + eps
      XXs_re_norm = XXs_re / XXs_abs
      XXs_im_norm = XXs_im / XXs_abs
  
      # Project on the demixing vectors, and keep only real part
      Ys_A = torch.matmul(XXs_re_norm, Ws_re.transpose(0, 1))
      Ys_B = torch.matmul(XXs_im_norm, Ws_im.transpose(0, 1))
      Ys = Ys_A - Ys_B
  
      # Get maximum points
      _, doas_idx = torch.max(Ys, dim=2)
  
      # Repeat for each frame
      doas = (doas[doas_idx, :])[:, XXs_idx, :]
  
      return doas
  
imports: import torch
  from packaging import version
  import speechbrain.processing.decomposition
label_desc: Use image node_id 3 for calling the SrpPhat obj's underlying member method code with example usage: obj._srp_phat(XXs, As, doas, eps) and returns: doas