%pylab inline
import random
random.seed(1337)
Populating the interactive namespace from numpy and matplotlib
pyannote.core
¶pyannote.core
package can be installed the easy way:
$ pip install pyannote.core
Adding support for Jupyter/IPython Notebook graphical representations is as easy as:
$ pip install pyannote.core[notebook]
from pyannote.core import *
segment = Segment(start=0, end=10)
segment
timeline = Timeline([Segment(1, 5), Segment(6, 8), Segment(12, 18), Segment(7, 20)])
timeline
annotation = Annotation()
annotation[Segment(1, 5)] = 'John'
annotation[Segment(6, 8)] = 'Jack'
annotation[Segment(12, 18)] = 'John'
annotation[Segment(7, 20)] = 'Alice'
annotation
# 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)
features
features.crop(Segment(2, 3))
array([[ 0.4421429 , -1.44502143, -0.43282043, -0.01994535], [ 0.95060543, -0.74292602, 1.22086979, 1.95070816], [ 1.19066555, 1.29371768, 0.11550674, -3.74567368], [ 1.17795762, -0.39977873, -1.27290048, 1.13461351], [-0.86933379, -0.69830552, -0.37775889, -0.32930616], [-0.20408787, -0.24439993, -0.07213635, -1.17373151], [-0.25488363, 0.13070289, 0.56219605, 0.36592598], [ 0.82328558, 0.80167407, -1.61040618, -0.18284535], [ 1.02423512, 0.78117785, -0.57796508, -0.24171816], [ 0.41506776, -1.05395226, -1.32510005, 0.0041201 ], [ 0.39898321, -0.4456852 , 0.50380856, -0.64459603], [ 1.08797586, 0.48974714, 0.50622516, -0.05644439], [-0.30759844, 0.05496161, -0.79779151, -1.32959826]])
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
pyannote.core
is on Github.
Fork and pull requests are very welcome!