Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Martin Lebourdais
s4d
Commits
45073b88
Commit
45073b88
authored
Feb 22, 2018
by
Florent Desnous
Browse files
edited comments
parent
50694289
Changes
1
Hide whitespace changes
Inline
Side-by-side
s4d/segmentation.py
View file @
45073b88
...
...
@@ -38,7 +38,7 @@ def sanity_check(cep, show, cluster='init'):
def
init_seg
(
cep
,
show
=
'empty'
,
cluster
=
'init'
):
"""
Return a initial segmentation composed of one segment from the first to the
Return a
n
initial segmentation composed of one segment from the first to the
last feature in *cep*.
:param cep: numpy.ndarry containing MFCC
...
...
@@ -55,9 +55,9 @@ def init_seg(cep, show='empty', cluster='init'):
def
adjust
(
cep
,
diarization
):
"""
Moves the border of segment of *diarization* into lowest energy region and split
segments gre
t
ter than 30s
segments gre
a
ter than 30s
:todo: change
s
numpy.convolve to the panada version
:todo: change numpy.convolve to the panada version
:param cep: a numpy.ndarray containing MFCC
:param diarization: a Diarization object
...
...
@@ -100,10 +100,10 @@ def _adjust(smooth, diarization, window_size=25):
def
_split_e
(
smooth
,
diarization
,
split_size
):
"""
Long segments of *diarization* are cut recursively at their points of lowest
energy
in order to yield segments shorter than *split_size* seconds.
Long segments of *diarization* are cut recursively at their points of lowest
energy
in order to yield segments shorter than *split_size* seconds.
:param smooth: sliding means of the energy (numpy.ndarry)
:param smooth: sliding means of the energy (numpy.ndarr
a
y)
:param diarization: a Diarization object
:param split_size: maximum size of a segment
:return: a Diar object
...
...
@@ -118,7 +118,7 @@ def _split_seg(smooth, segment, min_seg_size, split_size, lst):
"""
*segment*, a long segment, is cut recursively at their points of lowest energy
in order to yield segments shorter than *split_size* seconds. The new
segments gre
t
ter than *min_seg_size* are append into *lst*
segments gre
a
ter than *min_seg_size* are append
ed
into *lst*
:param smooth: sliding means of the energy (numpy.ndarry)
:param segment: a segment
...
...
@@ -145,23 +145,23 @@ def _split_seg(smooth, segment, min_seg_size, split_size, lst):
def
div_gauss
(
cep
,
show
=
'empty'
,
win
=
250
,
shift
=
0
):
"""
Segmentation based on divergence
gaussien
.
Segmentation based on
gaussian
divergence.
The segmentation detects the instantaneous change points corresponding to
segment boundaries. The proposed algorithm is based on the detection of
local maxima. It detects the change points through a gaussian divergence
(see equation below),
computed using Gaussians with diagonal covariance matrices. The left a
nd
right gaussians are estimated over a five-second window sliding along the
whole signal (2.5 seconds for each gaussian,
given *win* =250 features).
(see equation below),
computed using Gaussians with diagonal covariance
matrices. The left and right gaussians are estimated over a five-seco
nd
window sliding along the whole signal (2.5 seconds for each gaussian,
given *win* =250 features).
A change point, i.e. a segment boundary, is present in the middle of the
window when the gaussian diverence score reaches a local maximum.
window when the gaussian diver
g
ence score reaches a local maximum.
:math:`GD(s_l,s_r)=(
\\
mu_r-
\\
mu_l)^t
\\
Sigma_l^{-1/2}
\\
Sigma_r^{-1/2}(
\\
mu_r-
\\
mu_l)`
where :math:`s_l` is the left segment modeled by the mean :math:`\mu_l` and
the diagonal covariance matrix :math:`
\\
Sigma_l`, :math:`s_
l
` is the right
the diagonal covariance matrix :math:`
\\
Sigma_l`, :math:`s_
r
` is the right
segment modeled by the mean :math:`\mu_r` and the diagonal covariance
matrix :math:`
\\
Sigma_r`.
...
...
@@ -245,17 +245,17 @@ def bic_linear(cep, diarization, alpha, sr=False):
:math:`cst =
\\
frac{1}{2}
\\
alpha
\\
left(d +
\\
frac{d(d+1)}{2}
\\
right)`
:math:`P = cst
+
log(n_i+n_j)`
:math:`P = cst
\\
times
log(n_i+n_j)`
where :math:`|
\\
Sigma_i|`, :math:`|
\\
Sigma_j|` and :math:`|
\\
Sigma|` are the
determinants of gaussians associated to the left and right segm
n
ents
determinants of gaussians associated to the left and right segments
:math:`i`, :math:`j`
and :math:`i+j`. :math:`
\\
alpha` is a parameter to set up. The penalty
factor :math:`P` depends on :math:`d`, the dimension of the cep, as
well as on :math:`n_i` and :math:`n_j`, refering to the total length of
left segment :math:`i` and right segment :math:`j` respectively.
if *sr* is True, BIC distance is replace by the square root bic
if *sr* is True, BIC distance is replace
d
by the square root bic
(see :py:func:`clustering.hac_utils.bic_square_root`)
:param cep: numpy.ndarray
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment