code: def compute_embeddings(params, wav_scp, outdir):
      """Compute speaker embeddings.
  
      Arguments
      ---------
      params: dict
          The parameter files storing info about model, data, etc
      wav_scp : str
          The wav.scp file in Kaldi, in the form of "$utt $wav_path"
      outdir: str
          The output directory where we store the embeddings in per-
          numpy manner.
      """
      with torch.no_grad():
          with open(wav_scp, "r") as wavscp:
              for line in wavscp:
                  utt, wav_path = line.split()
                  out_file = "{}/{}.npy".format(outdir, utt)
                  wav, _ = torchaudio.load(wav_path)
                  data = wav.transpose(0, 1).squeeze(1).unsqueeze(0)
                  lens = torch.Tensor([data.shape[1]])
                  data, lens = (
                      data.to(run_opts["device"]),
                      lens.to(run_opts["device"]),
                  )
                  embedding = compute_embeddings_single(
                      data, lens, params
                  ).squeeze()
  
                  out_embedding = embedding.detach().cpu().numpy()
                  np.save(out_file, out_embedding)
                  del out_embedding, wav, data
  
file_path: speechbrain/recipes/VoxCeleb/SpeakerRec/extract_speaker_embeddings.py
imports: import os
  import sys
  import numpy
  import torch
  import logging
  import torchaudio
  import speechbrain
  from hyperpyyaml import load_hyperpyyaml
  from speechbrain.utils.distributed import run_on_main
  from speechbrain.utils.data_utils import download_file
label_desc: Use image node_id 2 for calling a global function with example usage: compute_embeddings(params, wav_scp, outdir) without return types