mirror of
https://github.com/pyannote/pyannote-audio.git
synced 2026-11-20 13:07:51 +09:00
feat: add option to pass arguments to inference (#655)
This commit is contained in:
1 parent
7f90409756
commit
37a6760738
4 files changed
+28
-42
No files matched your search
@@ -87,16 +87,16 @@ class OverlappedSpeechDetection(Pipeline):
|
||||
----------
|
||||
segmentation : Model, str, or dict, optional
|
||||
Pretrained segmentation (or overlapped speech detection) model.
|
||||
Defaults to "pyannote/Segmentation-PyanNet-DIHARD".
|
||||
Defaults to "pyannote/segmentation".
|
||||
See pyannote.audio.pipelines.utils.get_model for supported format.
|
||||
batch_size : int, optional
|
||||
Batch size. Defaults to 32.
|
||||
precision : float, optional
|
||||
Optimize recall at target precision.
|
||||
Defaults to optimize precision/recall fscore.
|
||||
recall : float, optional
|
||||
Optimize precision at target recall
|
||||
Defaults to optimize precision/recall fscore
|
||||
inference_kwargs : dict, optional
|
||||
Keywords arguments passed to Inference.
|
||||
|
||||
Hyper-parameters
|
||||
----------------
|
||||
@@ -110,15 +110,14 @@ class OverlappedSpeechDetection(Pipeline):
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
segmentation: PipelineModel = "pyannote/Segmentation-PyanNet-DIHARD",
|
||||
batch_size: int = 32,
|
||||
segmentation: PipelineModel = "pyannote/segmentation",
|
||||
precision: Optional[float] = None,
|
||||
recall: Optional[float] = None,
|
||||
**inference_kwargs,
|
||||
):
|
||||
super().__init__()
|
||||
|
||||
self.segmentation = segmentation
|
||||
self.batch_size = batch_size
|
||||
|
||||
# load model and send it to GPU (when available and not already on GPU)
|
||||
model = get_model(segmentation)
|
||||
@@ -126,10 +125,7 @@ class OverlappedSpeechDetection(Pipeline):
|
||||
(segmentation_device,) = get_devices(needs=1)
|
||||
model.to(segmentation_device)
|
||||
|
||||
self.segmentation_inference_ = Inference(
|
||||
model,
|
||||
batch_size=self.batch_size,
|
||||
)
|
||||
self.segmentation_inference_ = Inference(model, **inference_kwargs)
|
||||
|
||||
# hyper-parameters used for hysteresis thresholding
|
||||
self.onset = Uniform(0.0, 1.0)
|
||||
@@ -209,7 +205,7 @@ class OverlappedSpeechDetection(Pipeline):
|
||||
reference: Annotation,
|
||||
hypothesis: Annotation,
|
||||
uem: Timeline = None,
|
||||
**kwargs
|
||||
**kwargs,
|
||||
) -> dict:
|
||||
return super().compute_components(
|
||||
to_overlap(reference), hypothesis, uem=uem, **kwargs
|
||||
|
||||
@@ -50,10 +50,13 @@ class Resegmentation(Pipeline):
|
||||
Parameters
|
||||
----------
|
||||
segmentation : Model, str, or dict, optional
|
||||
Pretrained segmentation model. Defaults to "pyannote/Segmentation-PyanNet-DIHARD".
|
||||
Pretrained segmentation model. Defaults to "pyannote/segmentation".
|
||||
See pyannote.audio.pipelines.utils.get_model for supported format.
|
||||
diarization : str, optional
|
||||
File key to use as input diarization. Defaults to "diarization".
|
||||
inference_kwargs : dict, optional
|
||||
Keywords arguments passed to Inference.
|
||||
|
||||
|
||||
Hyper-parameters
|
||||
----------------
|
||||
@@ -67,16 +70,15 @@ class Resegmentation(Pipeline):
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
segmentation: PipelineModel = "pyannote/Segmentation-PyanNet-DIHARD",
|
||||
batch_size: int = 32,
|
||||
segmentation: PipelineModel = "pyannote/segmentation",
|
||||
diarization: Text = "diarization",
|
||||
**inference_kwargs,
|
||||
):
|
||||
|
||||
super().__init__()
|
||||
|
||||
self.segmentation = segmentation
|
||||
self.diarization = diarization
|
||||
self.batch_size = batch_size
|
||||
|
||||
# load model and send it to GPU (when available and not already on GPU)
|
||||
model = get_model(segmentation)
|
||||
@@ -95,13 +97,9 @@ class Resegmentation(Pipeline):
|
||||
self.seg_frames_ = model.introspection.frames
|
||||
|
||||
# prepare segmentation model for inference
|
||||
self.seg_inference_ = Inference(
|
||||
model,
|
||||
window="sliding",
|
||||
skip_aggregation=True,
|
||||
duration=model.specifications.duration,
|
||||
batch_size=32,
|
||||
)
|
||||
inference_kwargs["window"] = "sliding"
|
||||
inference_kwargs["skip_aggregation"] = True
|
||||
self.seg_inference_ = Inference(model, **inference_kwargs)
|
||||
|
||||
# hyper-parameters used for hysteresis thresholding
|
||||
self.onset = Uniform(0.0, 1.0)
|
||||
|
||||
@@ -58,10 +58,10 @@ class Segmentation(Pipeline):
|
||||
Parameters
|
||||
----------
|
||||
segmentation : Model, str, or dict, optional
|
||||
Pretrained segmentation model. Defaults to "pyannote/Segmentation-PyanNet-DIHARD".
|
||||
Pretrained segmentation model. Defaults to "pyannote/segmentation".
|
||||
See pyannote.audio.pipelines.utils.get_model for supported format.
|
||||
batch_size : int, optional
|
||||
Batch size. Defaults to 32.
|
||||
inference_kwargs : dict, optional
|
||||
Keywords arguments passed to Inference.
|
||||
|
||||
Hyper-parameters
|
||||
----------------
|
||||
@@ -75,13 +75,12 @@ class Segmentation(Pipeline):
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
segmentation: PipelineModel = "pyannote/Segmentation-PyanNet-DIHARD",
|
||||
batch_size: int = 32,
|
||||
segmentation: PipelineModel = "pyannote/segmentation",
|
||||
**inference_kwargs,
|
||||
):
|
||||
super().__init__()
|
||||
|
||||
self.segmentation = segmentation
|
||||
self.batch_size = batch_size
|
||||
|
||||
# load model and send it to GPU (when available and not already on GPU)
|
||||
model = get_model(segmentation)
|
||||
@@ -89,10 +88,7 @@ class Segmentation(Pipeline):
|
||||
(segmentation_device,) = get_devices(needs=1)
|
||||
model.to(segmentation_device)
|
||||
|
||||
self.segmentation_inference_ = Inference(
|
||||
model,
|
||||
batch_size=self.batch_size,
|
||||
)
|
||||
self.segmentation_inference_ = Inference(model, **inference_kwargs)
|
||||
|
||||
# hyper-parameters used for hysteresis thresholding
|
||||
self.onset = Uniform(0.0, 1.0)
|
||||
|
||||
@@ -85,13 +85,13 @@ class VoiceActivityDetection(Pipeline):
|
||||
----------
|
||||
segmentation : Model, str, or dict, optional
|
||||
Pretrained segmentation (or voice activity detection) model.
|
||||
Defaults to "hbredin/VoiceActivityDetection-PyanNet-DIHARD".
|
||||
Defaults to "pyannote/segmentation".
|
||||
See pyannote.audio.pipelines.utils.get_model for supported format.
|
||||
batch_size : int, optional
|
||||
Batch size. Defaults to 32.
|
||||
fscore : bool, optional
|
||||
Optimize (precision/recall) fscore. Defaults to optimizing detection
|
||||
error rate.
|
||||
inference_kwargs : dict, optional
|
||||
Keywords arguments passed to Inference.
|
||||
|
||||
Hyper-parameters
|
||||
----------------
|
||||
@@ -105,14 +105,13 @@ class VoiceActivityDetection(Pipeline):
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
segmentation: PipelineModel = "hbredin/VoiceActivityDetection-PyanNet-DIHARD",
|
||||
batch_size: int = 32,
|
||||
segmentation: PipelineModel = "pyannote/segmentation",
|
||||
fscore: bool = False,
|
||||
**inference_kwargs,
|
||||
):
|
||||
super().__init__()
|
||||
|
||||
self.segmentation = segmentation
|
||||
self.batch_size = batch_size
|
||||
self.fscore = fscore
|
||||
|
||||
# load model and send it to GPU (when available and not already on GPU)
|
||||
@@ -121,10 +120,7 @@ class VoiceActivityDetection(Pipeline):
|
||||
(segmentation_device,) = get_devices(needs=1)
|
||||
model.to(segmentation_device)
|
||||
|
||||
self.segmentation_inference_ = Inference(
|
||||
model,
|
||||
batch_size=self.batch_size,
|
||||
)
|
||||
self.segmentation_inference_ = Inference(model, **inference_kwargs)
|
||||
|
||||
# hyper-parameters used for hysteresis thresholding
|
||||
self.onset = Uniform(0.0, 1.0)
|
||||
|
||||
Reference in new issue
Block a user