MCPcopy
hub / github.com/babysor/MockingBird / embed_frames_batch

Function embed_frames_batch

encoder/inference.py:43–56  ·  view source on GitHub ↗

Computes embeddings for a batch of mel spectrogram. :param frames_batch: a batch mel of spectrogram as a numpy array of float32 of shape (batch_size, n_frames, n_channels) :return: the embeddings as a numpy array of float32 of shape (batch_size, model_embedding_size)

(frames_batch)

Source from the content-addressed store, hash-verified

41
42
43def embed_frames_batch(frames_batch):
44 """
45 Computes embeddings for a batch of mel spectrogram.
46
47 :param frames_batch: a batch mel of spectrogram as a numpy array of float32 of shape
48 (batch_size, n_frames, n_channels)
49 :return: the embeddings as a numpy array of float32 of shape (batch_size, model_embedding_size)
50 """
51 if _model is None:
52 raise Exception("Model was not loaded. Call load_model() before inference.")
53
54 frames = torch.from_numpy(frames_batch).to(_device)
55 embed = _model.forward(frames).detach().cpu().numpy()
56 return embed
57
58
59def compute_partial_slices(n_samples, partial_utterance_n_frames=partials_n_frames,

Callers 1

embed_utteranceFunction · 0.85

Calls 1

forwardMethod · 0.45

Tested by

no test coverage detected