code: def get_speaker_embedding(
      ssl_model,
      wav_featurizer,
      audio_paths,
      duration=None,
      device="cpu",
  ):
      all_segments = []
      all_wavs = []
      for audio_path in audio_paths:
          wav = load_wav(audio_path, wav_featurizer)
          segments = segment_wav(wav)
          all_segments += segments
          all_wavs.append(wav)
          if duration is not None and len(all_segments) >= duration:
              # each segment is 2 seconds with one second overlap.
              # so 10 segments would mean 0 to 2, 1 to 3.. 9 to 11 (11 seconds.)
              all_segments = all_segments[: int(duration)]
              break
  
      signal_batch = torch.stack(all_segments)
      signal_length_batch = torch.stack(
          [
              torch.tensor(signal_batch.shape[1])
              for _ in range(len(all_segments))
          ]
      )
      signal_batch = signal_batch.to(device)
      signal_length_batch = signal_length_batch.to(device)
      _, speaker_embeddings, _, _, _ = ssl_model.forward_for_export(
          input_signal=signal_batch,
          input_signal_length=signal_length_batch,
          normalize_content=True,
      )
  
      speaker_embedding = torch.mean(speaker_embeddings, dim=0)
      l2_norm = torch.norm(speaker_embedding, p=2)
      speaker_embedding = speaker_embedding / l2_norm
  
      return speaker_embedding[None]
  
file_path: NeMo/scripts/ssl_tts/ssl_tts_vc.py
imports: import argparse
  import os
  import librosa
  import soundfile
  import torch
  from nemo.collections.asr.parts.preprocessing.features import WaveformFeaturizer
  from nemo.collections.tts.models import fastpitch_ssl, hifigan, ssl_tts
  from nemo.collections.tts.parts.utils.tts_dataset_utils import get_base_dir
label_desc: Use image node_id 4 for calling a global function with example usage: get_speaker_embedding(ssl_model, wav_featurizer, audio_paths, duration, device) and returns: speaker_embedding