#!/usr/bin/env python # coding: utf-8 # In[1]: get_ipython().run_line_magic('pylab', 'inline') import random random.seed(1337) # # Documentation for `pyannote.core` # ## Install # `pyannote.core` package can be installed the easy way: # ```bash # $ pip install pyannote.core # ``` # # Adding support for Jupyter/IPython Notebook graphical representations is as easy as: # ```bash # $ pip install pyannote.core[notebook] # ``` # ## Available data structures # In[2]: from pyannote.core import * # ### Segment ([pyannote.core.segment](pyannote.core.segment.ipynb)) # In[3]: segment = Segment(start=0, end=10) segment # ### Timeline ([pyannote.core.timeline](pyannote.core.timeline.ipynb)) # In[4]: timeline = Timeline([Segment(1, 5), Segment(6, 8), Segment(12, 18), Segment(7, 20)]) timeline # ### Annotation ([pyannote.core.annotation](pyannote.core.annotation.ipynb)) # In[5]: annotation = Annotation() annotation[Segment(1, 5)] = 'John' annotation[Segment(6, 8)] = 'Jack' annotation[Segment(12, 18)] = 'John' annotation[Segment(7, 20)] = 'Alice' annotation # ### Feature ([pyannote.core.feature](pyannote.core.feature.ipynb)) # In[6]: # one 4-dimensional feature vector extracted every 100ms from a 200ms window frame = SlidingWindow(start=0.0, step=0.100, duration=0.200) data = np.random.randn(100, 4) features = SlidingWindowFeature(data, frame) # In[9]: features # In[7]: features.crop(Segment(2, 3)) # ### Scores ([pyannote.core.scores](pyannote.core.scores.ipynb)) # In[8]: scores = Scores() scores[Segment(3, 5), '_', 'Penny'] = 0.8 scores[Segment(3, 5), '_', 'Leonard'] = 0.15 scores[Segment(3, 5), '_', 'Sheldon'] = 0.05 scores[Segment(5.5, 7), '_', 'Penny'] = 0.4 scores[Segment(5.5, 7), '_', 'Leonard'] = 0.5 scores[Segment(5.5, 7), '_', 'Sheldon'] = 0.1 scores[Segment(8, 10), '_', 'Penny'] = 0.4 scores[Segment(8, 10), '_', 'Leonard'] = 0.25 scores[Segment(8, 10), '_', 'Sheldon'] = 0.35 scores # ## Contribute # `pyannote.core` is on [Github](https://github.com/pyannote/pyannote-core). # # # Fork and pull requests are very welcome!