Merge branch 'develop' into v2

This commit is contained in:
Hervé BREDIN authored and GitHub committed 2020-01-16 14:09:14 +01:00
commit b2ff46e4c0
6 files changed
+52 -12

No files matched your search

-1
View File
@@ -1,4 +1,3 @@
##############
pyannote.audio
##############
@@ -3,7 +3,7 @@
# The MIT License (MIT)
# Copyright (c) 2017-2019 CNRS
# Copyright (c) 2017-2020 CNRS
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
+5 -1
View File
@@ -34,4 +34,8 @@ from .speech_activity_detection import SpeechActivityDetection
from .overlap_detection import OverlapDetection
from .speech_turn_segmentation import SpeechTurnSegmentation
from .speaker_diarization import SpeakerDiarization
from .resegmentation import Resegmentation
try:
from .resegmentation import Resegmentation
except ModuleNotFoundError as e:
msg = f'Resegmentation module is not available: {e}'
print(msg)
+43 -6
View File
@@ -32,6 +32,7 @@ from pyannote.core import Annotation
from pyannote.database import get_annotated
from pyannote.metrics.diarization import GreedyDiarizationErrorRate
from pyannote.metrics.diarization import DiarizationPurityCoverageFMeasure
from .speech_turn_segmentation import SpeechTurnSegmentation
from .speech_turn_clustering import SpeechTurnClustering
@@ -42,7 +43,6 @@ from typing import Union
from pyannote.pipeline import Pipeline
from pyannote.pipeline.parameter import Uniform
class SpeakerDiarization(Pipeline):
"""Speaker diarization pipeline
@@ -61,7 +61,10 @@ class SpeakerDiarization(Pipeline):
Clustering method. Defaults to 'pool'.
evaluation_only : `bool`
Only process the evaluated regions. Default to False.
purity : `float`, optional
Optimize coverage for target purity.
Defaults to optimizing diarization error rate.
Hyper-parameters
----------------
min_duration : `float`
@@ -74,16 +77,17 @@ class SpeakerDiarization(Pipeline):
embedding: Optional[Path] = None,
metric: Optional[str] = 'cosine',
method: Optional[str] = 'pool',
evaluation_only: Optional[bool] = False):
evaluation_only: Optional[bool] = False,
purity: Optional[float] = None):
super().__init__()
self.sad_scores = sad_scores
self.scd_scores = scd_scores
self.speech_turn_segmentation = SpeechTurnSegmentation(
sad_scores=self.sad_scores,
scd_scores=self.scd_scores)
self.evaluation_only = evaluation_only
self.purity = purity
self.min_duration = Uniform(0, 10)
@@ -161,10 +165,43 @@ class SpeakerDiarization(Pipeline):
# TODO. add GMM-based resegmentation
def loss(self, current_file: dict, hypothesis: Annotation) -> float:
"""Compute (1 - coverage) at target purity
If purity < target, return 1 + (1 - purity)
Parameters
----------
current_file : `dict`
File as provided by a pyannote.database protocol.
hypothesis : `pyannote.core.Annotation`
Speech turns.
Returns
-------
loss : `float`
1. - cluster coverage.
"""
metric = DiarizationPurityCoverageFMeasure()
reference = current_file['annotation']
uem = get_annotated(current_file)
f_measure = metric(reference, hypothesis, uem=uem)
purity, coverage, _ = metric.compute_metrics()
if purity > self.purity:
return 1. - coverage
else:
return 1. + (1. - purity)
def get_metric(self) -> GreedyDiarizationErrorRate:
"""Return new instance of diarization error rate metric"""
return GreedyDiarizationErrorRate(collar=0.0, skip_overlap=False)
# defaults to optimizing diarization error rate
if self.purity is None:
return GreedyDiarizationErrorRate(collar=0.0, skip_overlap=False)
# fallbacks to using self.loss(...)
raise NotImplementedError()
class Yin2018(SpeakerDiarization):
"""Speaker diarization pipeline introduced in Yin et al., 2018
+2 -2
View File
@@ -1,8 +1,8 @@
cachetools >= 2.0.0
librosa >= 0.7.0
pandas >= 0.18.0
pyannote.core >= 3.2
pyannote.database >= 2.4.1
pyannote.core >= 3.3
pyannote.database >= 2.4.2
pyannote.generators >= 2.0
pyannote.metrics >= 2.2
pyannote.pipeline >= 1.2
+1 -1
View File
@@ -172,7 +172,7 @@ It can be run while the model is still training and evaluates the model every 20
In practice, it is tuning a simple speaker verification experiment and stores the best hyper-parameter configuration on disk:
```bash
$ export VAL_DIR = ${TRN_DIR}/validate/VoxCeleb.SpeakerDiarization.VoxCeleb1.test
$ export VAL_DIR = ${TRN_DIR}/validate_equal_error_rate/VoxCeleb.SpeakerDiarization.VoxCeleb1.test
$ cat ${VAL_DIR}/params.yml
```
```yaml