speaker_batch.py 609 B

12345678910111213
  1. import numpy as np
  2. from typing import List
  3. from encoder.data_objects.speaker import Speaker
  4. class SpeakerBatch:
  5. def __init__(self, speakers: List[Speaker], utterances_per_speaker: int, n_frames: int):
  6. self.speakers = speakers
  7. self.partials = {s: s.random_partial(utterances_per_speaker, n_frames) for s in speakers}
  8. # Array of shape (n_speakers * n_utterances, n_frames, mel_n), e.g. for 3 speakers with
  9. # 4 utterances each of 160 frames of 40 mel coefficients: (12, 160, 40)
  10. self.data = np.array([frames for s in speakers for _, frames, _ in self.partials[s]])