Views
No views yet
1from diarizers import SegmentationModel
2
3segmentation_model = SegmentationModel().from_pretrained('diarizers-community/speaker-segmentation-fine-tuned-callhome-deu')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
8# load the pre-trained pyannote pipeline
9pipeline = Pipeline.from_pretrained("pyannote/speaker-diarization-3.1")
10pipeline.to(device)
11
12# replace the segmentation model with your fine-tuned one
13model = segmentation_model.to_pyannote_model()
14pipeline._segmentation.model = model.to(device)1# load dataset example
2dataset = load_dataset("diarizers-community/callhome", "deu", split="data")
3sample = dataset[0]["audio"]
4
5# pre-process inputs
6sample["waveform"] = torch.from_numpy(sample.pop("array")[None, :]).to(device, dtype=model.dtype)
7sample["sample_rate"] = sample.pop("sampling_rate")
8
9# perform inference
10diarization = pipeline(sample)
11
12# dump the diarization output to disk using RTTM format
13with open("audio.rttm", "w") as rttm:
14 diarization.write_rttm(rttm)| Training Loss | Epoch | Step | Validation Loss | Der | False Alarm | Missed Detection | Confusion |
|---|---|---|---|---|---|---|---|
| 0.4622 | 1.0 | 330 | 0.3844 | 0.1439 | 0.0653 | 0.0562 | 0.0223 |
| 0.4306 | 2.0 | 660 | 0.4004 | 0.1519 | 0.0763 | 0.0515 | 0.0241 |
| 0.4069 | 3.0 | 990 | 0.3775 | 0.1407 | 0.0707 | 0.0496 | 0.0204 |
| 0.3949 | 4.0 | 1320 | 0.3771 | 0.1408 | 0.0710 | 0.0498 | 0.0200 |
| 0.3879 | 5.0 | 1650 | 0.3780 | 0.1415 | 0.0724 | 0.0490 | 0.0201 |