diff --git a/pyannote/audio/pipelines/overlapped_speech_detection.py b/pyannote/audio/pipelines/overlapped_speech_detection.py index 543af4ee..ea480299 100644 --- a/pyannote/audio/pipelines/overlapped_speech_detection.py +++ b/pyannote/audio/pipelines/overlapped_speech_detection.py @@ -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 diff --git a/pyannote/audio/pipelines/resegmentation.py b/pyannote/audio/pipelines/resegmentation.py index e8d26820..f474388b 100644 --- a/pyannote/audio/pipelines/resegmentation.py +++ b/pyannote/audio/pipelines/resegmentation.py @@ -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) diff --git a/pyannote/audio/pipelines/segmentation.py b/pyannote/audio/pipelines/segmentation.py index 220c4904..2ae7c971 100644 --- a/pyannote/audio/pipelines/segmentation.py +++ b/pyannote/audio/pipelines/segmentation.py @@ -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) diff --git a/pyannote/audio/pipelines/voice_activity_detection.py b/pyannote/audio/pipelines/voice_activity_detection.py index 67663f0c..053be630 100644 --- a/pyannote/audio/pipelines/voice_activity_detection.py +++ b/pyannote/audio/pipelines/voice_activity_detection.py @@ -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)