code: def __init__(self, args, device):
      self.toolkit = args.toolkit
      self.device = device
      self.tgt_sr = 16000  # NOTE(jiatong): following 16khz convetion
  
      if self.toolkit == "speechbrain":
          from speechbrain.dataio.preprocess import AudioNormalizer
          from speechbrain.pretrained import EncoderClassifier
  
          self.audio_norm = AudioNormalizer()
          self.model = EncoderClassifier.from_hparams(
              source=args.pretrained_model, run_opts={"device": device}
          )
      elif self.toolkit == "rawnet":
          from RawNet3 import RawNet3
          from RawNetBasicBlock import Bottle2neck
  
          self.model = RawNet3(
              Bottle2neck,
              model_scale=8,
              context=True,
              summed=True,
              encoder_type="ECA",
              nOut=256,
              out_bn=False,
              sinc_stride=10,
              log_sinc=True,
              norm_sinc="mean",
              grad_mult=1,
          )
          tools_dir = Path(os.getcwd()).parent.parent.parent / "tools"
          self.model.load_state_dict(
              torch.load(
                  tools_dir
                  / "RawNet/python/RawNet3/models/weights/model.pt",
                  map_location=lambda storage, loc: storage,
              )["model"]
          )
          self.model.to(device).eval()
      elif self.toolkit == "espnet":
          from espnet2.bin.spk_inference import Speech2Embedding
  
          # NOTE(jiatong): set default config file as None
          # assume config is the same path as the model file
          speech2embedding_kwargs = dict(
              batch_size=1,
              dtype="float32",
              train_config=None,
              model_file=args.pretrained_model,
          )
  
          if args.pretrained_model.endswith("pth"):
              logging.info(
                  "the provided model path is end with pth,"
                  "assume it not a huggingface model"
              )
              model_tag = None
          else:
              logging.info(
                  "the provided model path is not end with pth,"
                  "assume use huggingface model"
              )
              model_tag = args.pretrained_model
  
          self.speech2embedding = Speech2Embedding.from_pretrained(
              model_tag=model_tag,
              **speech2embedding_kwargs,
          )
  
file_path: espnet/egs2/libritts/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 1 to create a new SpkEmbedExtractor object  with example: obj = SpkEmbedExtractor(args, device)