Skip to content

Commit

Permalink
feat: add support for Segment in one_hot_encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
hbredin committed Sep 24, 2021
1 parent 5de2565 commit 479e7b8
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions pyannote/core/utils/numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

def one_hot_encoding(
annotation: Annotation,
support: Timeline,
support: Union[Segment, Timeline],
window: Union[SlidingWindow, SlidingWindowFeature],
labels: Optional[List[Text]] = None,
mode: Text = "center",
Expand All @@ -51,7 +51,7 @@ def one_hot_encoding(
Parameters
----------
annotation : `pyannote.core.Annotation`
support : `pyannote.core.Timeline`
support : `pyannote.core.Timeline` or `pyannote.core.Segment`
window : `SlidingWindow`
Use this `window`.
labels : list, optional
Expand Down Expand Up @@ -79,7 +79,12 @@ def one_hot_encoding(
)
raise TypeError(msg)

extent = support.extent()
if isinstance(support, Segment):
extent = support
support = Timeline([support])
else:
extent = support.extent()

window = SlidingWindow(
start=extent.start, step=window.step, duration=window.duration
)
Expand Down

0 comments on commit 479e7b8

Please sign in to comment.