Skip to content

Commit

Permalink
Fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
erogol committed May 19, 2022
1 parent b49d65c commit 4c9b101
Showing 1 changed file with 30 additions and 30 deletions.
60 changes: 30 additions & 30 deletions tests/aux_tests/test_speaker_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,42 +22,42 @@
class SpeakerManagerTest(unittest.TestCase):
"""Test SpeakerManager for loading embedding files and computing d_vectors from waveforms"""

# @staticmethod
# def test_speaker_embedding():
# # load config
# config = load_config(encoder_config_path)
# config.audio.resample = True
@staticmethod
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(model, None, None, get_tests_input_path(), 0)
# create a dummy speaker encoder
model = setup_encoder_model(config)
save_checkpoint(model, None, None, get_tests_input_path(), 0)

# # load audio processor and speaker encoder
# ap = AudioProcessor(**config.audio)
# manager = SpeakerManager(encoder_model_path=encoder_model_path, encoder_config_path=encoder_config_path)
# load audio processor and speaker encoder
ap = AudioProcessor(**config.audio)
manager = SpeakerManager(encoder_model_path=encoder_model_path, encoder_config_path=encoder_config_path)

# # load a sample audio and compute embedding
# waveform = ap.load_wav(sample_wav_path)
# mel = ap.melspectrogram(waveform)
# d_vector = manager.compute_embeddings(mel)
# assert d_vector.shape[1] == 256
# load a sample audio and compute embedding
waveform = ap.load_wav(sample_wav_path)
mel = ap.melspectrogram(waveform)
d_vector = manager.compute_embeddings(mel)
assert d_vector.shape[1] == 256

# # compute d_vector directly from an input file
# d_vector = manager.compute_embedding_from_clip(sample_wav_path)
# d_vector2 = manager.compute_embedding_from_clip(sample_wav_path)
# d_vector = torch.FloatTensor(d_vector)
# d_vector2 = torch.FloatTensor(d_vector2)
# assert d_vector.shape[0] == 256
# assert (d_vector - d_vector2).sum() == 0.0
# compute d_vector directly from an input file
d_vector = manager.compute_embedding_from_clip(sample_wav_path)
d_vector2 = manager.compute_embedding_from_clip(sample_wav_path)
d_vector = torch.FloatTensor(d_vector)
d_vector2 = torch.FloatTensor(d_vector2)
assert d_vector.shape[0] == 256
assert (d_vector - d_vector2).sum() == 0.0

# # compute d_vector from a list of wav files.
# d_vector3 = manager.compute_embedding_from_clip([sample_wav_path, sample_wav_path2])
# d_vector3 = torch.FloatTensor(d_vector3)
# assert d_vector3.shape[0] == 256
# assert (d_vector - d_vector3).sum() != 0.0
# compute d_vector from a list of wav files.
d_vector3 = manager.compute_embedding_from_clip([sample_wav_path, sample_wav_path2])
d_vector3 = torch.FloatTensor(d_vector3)
assert d_vector3.shape[0] == 256
assert (d_vector - d_vector3).sum() != 0.0

# # remove dummy model
# os.remove(encoder_model_path)
# remove dummy model
os.remove(encoder_model_path)

def test_speakers_file_processing(self):
manager = SpeakerManager(d_vectors_file_path=d_vectors_file_path)
Expand Down

0 comments on commit 4c9b101

Please sign in to comment.