class_docstr: Test emEeddingManager for loading embedding files and computing embeddings from waveforms
class_docstr_tok: ["Test","emEeddingManager","for","loading","embedding","files","and","computing","embeddings","from","waveforms"]
code: def test_speaker_embedding():
      # load config
      config = load_config(encoder_config_path)
      config.audio.resample = True
  
      # create a dummy speaker encoder
      model = setup_encoder_model(config)
      save_checkpoint(
          config, model, None, None, 0, 0, get_tests_input_path()
      )
  
      # load audio processor and speaker encoder
      manager = EmbeddingManager(
          encoder_model_path=encoder_model_path,
          encoder_config_path=encoder_config_path,
      )
  
      # load a sample audio and compute embedding
      ap = AudioProcessor(**config.audio)
      waveform = ap.load_wav(sample_wav_path)
      mel = ap.melspectrogram(waveform)
      embedding = manager.compute_embeddings(mel)
      assert embedding.shape[1] == 256
  
      # compute embedding directly from an input file
      embedding = manager.compute_embedding_from_clip(sample_wav_path)
      embedding2 = manager.compute_embedding_from_clip(sample_wav_path)
      embedding = torch.FloatTensor(embedding)
      embedding2 = torch.FloatTensor(embedding2)
      assert embedding.shape[0] == 256
      assert (embedding - embedding2).sum() == 0.0
  
      # compute embedding from a list of wav files.
      embedding3 = manager.compute_embedding_from_clip(
          [sample_wav_path, sample_wav_path2]
      )
      embedding3 = torch.FloatTensor(embedding3)
      assert embedding3.shape[0] == 256
      assert (embedding - embedding3).sum() != 0.0
  
      # remove dummy model
      os.remove(encoder_model_path)
  
file_path: TTS/tests/aux_tests/test_embedding_manager.py
imports: import os
  import unittest
  import numpy
  import torch
  from trainer.io import save_checkpoint
  from tests import get_tests_input_path
  from TTS.config import load_config
  from TTS.encoder.utils.generic_utils import setup_encoder_model
  from TTS.tts.utils.managers import EmbeddingManager
  from TTS.utils.audio import AudioProcessor
label_desc: Use image node_id 1 for calling the EmbeddingManagerTest obj's underlying member method code with example usage: obj.test_speaker_embedding() without return types