Views
No views yet
1from diarizers import SegmentationModel
2
3segmentation_model = SegmentationModel().from_pretrained('diarizers-community/speaker-segmentation-fine-tuned-callhome-jpn')1
2from pyannote.audio import Pipeline
3import torch
4
5device = torch.device("cuda:0") if torch.cuda.is_available() else torch.device("cpu")
6
7# load the pre-trained pyannote pipeline
8pipeline = Pipeline.from_pretrained("pyannote/speaker-diarization-3.1")
9pipeline.to(device)
10
11# replace the segmentation model with your fine-tuned one
12segmentation_model = segmentation_model.to_pyannote_model()
13pipeline._segmentation.model = segmentation_model.to(device)1from datasets import load_dataset
2# load dataset example
3dataset = load_dataset("diarizers-community/callhome", "jpn", split="data")
4sample = dataset[0]["audio"]
5
6# pre-process inputs
7sample["waveform"] = torch.from_numpy(sample.pop("array")[None, :]).to(device, dtype=model.dtype)
8sample["sample_rate"] = sample.pop("sampling_rate")
9
10# perform inference
11diarization = pipeline(sample)
12
13# dump the diarization output to disk using RTTM format
14with open("audio.rttm", "w") as rttm:
15 diarization.write_rttm(rttm)| Training Loss | Epoch | Step | Validation Loss | Der | False Alarm | Missed Detection | Confusion |
|---|---|---|---|---|---|---|---|
| 0.5917 | 1.0 | 328 | 0.7859 | 0.2409 | 0.0507 | 0.1369 | 0.0533 |
| 0.5616 | 2.0 | 656 | 0.7738 | 0.2350 | 0.0530 | 0.1350 | 0.0471 |
| 0.5364 | 3.0 | 984 | 0.7737 | 0.2358 | 0.0484 | 0.1368 | 0.0506 |
| 0.5121 | 4.0 | 1312 | 0.7626 | 0.2317 | 0.0483 | 0.1358 | 0.0475 |
| 0.5166 | 5.0 | 1640 | 0.7653 | 0.2311 | 0.0477 | 0.1352 | 0.0482 |