code: def main(argv):
      """Load the model, generate kernel and bandpass plots."""
      parser = get_parser()
      args = parser.parse_args(argv)
  
      if args.verbose > 0:
          logging.basicConfig(
              level=logging.INFO,
              format="%(asctime)s (%(module)s:%(lineno)d) %(levelname)s: %(message)s",
          )
      else:
          logging.basicConfig(
              level=logging.WARN,
              format="%(asctime)s (%(module)s:%(lineno)d) %(levelname)s: %(message)s",
          )
          logging.warning("Skip DEBUG/INFO messages")
  
      if torch.cuda.is_available() and ("cuda" in args.device):
          device = args.device
      else:
          device = "cpu"
  
      if args.toolkit in ("speechbrain", "rawnet", "espnet"):
          # Prepare spk2utt for mean x-vector
          spk2utt = dict()
          with open(
              os.path.join(args.in_folder, "spk2utt"), "r"
          ) as reader:
              for line in reader:
                  details = line.split()
                  spk2utt[details[0]] = details[1:]
  
          wav_scp = SoundScpReader(
              os.path.join(args.in_folder, "wav.scp"), np.float32
          )
          os.makedirs(args.out_folder, exist_ok=True)
          writer_utt = kaldiio.WriteHelper(
              "ark,scp:{0}/{1}.ark,{0}/{1}.scp".format(
                  args.out_folder, args.spk_embed_tag
              )
          )
          writer_spk = kaldiio.WriteHelper(
              "ark,scp:{0}/spk_{1}.ark,{0}/spk_{1}.scp".format(
                  args.out_folder, args.spk_embed_tag
              )
          )
  
          spk_embed_extractor = SpkEmbedExtractor(args, device)
  
          for speaker in tqdm(spk2utt):
              spk_embeddings = list()
              for utt in spk2utt[speaker]:
                  in_sr, wav = wav_scp[utt]
                  # Speaker Embedding
                  embeds = spk_embed_extractor(wav, in_sr)
                  writer_utt[utt] = np.squeeze(embeds)
                  spk_embeddings.append(embeds)
  
              # Speaker Normalization
              embeds = np.mean(np.stack(spk_embeddings, 0), 0)
              writer_spk[speaker] = embeds
          writer_utt.close()
          writer_spk.close()
  
      else:
          raise ValueError(
              "Unkown type of toolkit. Only supported: speechbrain, rawnet, espnet, kaldi"
          )
  
file_path: espnet/egs2/mini_an4/enh_asr1/pyscripts/utils/extract_spk_embed.py
imports: import argparse
  import logging
  import os
  import sys
  from pathlib import Path
  import kaldiio
  import librosa
  import numpy
  import torch
  from tqdm.contrib import tqdm
  from espnet2.fileio.sound_scp import SoundScpReader
label_desc: Use image node_id 2 for calling a global function with example usage: main(argv) without return types