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)
| 41 | |
| 42 | |
| 43 | def 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 | |
| 59 | def compute_partial_slices(n_samples, partial_utterance_n_frames=partials_n_frames, |
no test coverage detected