def add_annotation(self, annotator: Annotator, annotation: Annotation): """ Add a full pyannote annotation to the continuum. Parameters ---------- annotator: str A string id for the annotator who produced that annotation. annotation: :class:`pyannote.core.Annotation` A pyannote `Annotation` object. If a label is present for a given segment, it will be considered as that label's annotation. """ for segment, _, label in annotation.itertracks(yield_label=True): self.add(annotator, segment, label)
def to_audio_spans(annotation: Annotation, focus: Segment = None) -> Dict: """Convert pyannote.core.Annotation to Prodigy's audio_spans Parameters ---------- annotation : Annotation Annotation with t=0s time origin. focus : Segment, optional When provided, use its start time as audio_spans time origin. Returns ------- audio_spans : list of dict """ shift = 0.0 if focus is None else focus.start return [{ "start": segment.start - shift, "end": segment.end - shift, "label": label } for segment, _, label in annotation.itertracks(yield_label=True)]