kamilakesbi commited on
Commit
22d6b5c
·
verified ·
1 Parent(s): af47e92

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +53 -1
README.md CHANGED
@@ -27,7 +27,59 @@ It achieves the following results on the evaluation set:
27
 
28
  ## Model description
29
 
30
- More information needed
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
 
32
  ## Intended uses & limitations
33
 
 
27
 
28
  ## Model description
29
 
30
+ This segmentation model has been trained on English data (Callhome) using [diarizers](https://github.com/huggingface/diarizers/tree/main).
31
+ It can be loaded with two lines of code using the following snipet:
32
+
33
+ ```python
34
+ from diarizers import SegmentationModel
35
+
36
+ segmentation_model = SegmentationModel().from_pretrained('diarizers-community/speaker-segmentation-fine-tuned-callhome-eng')
37
+ ```
38
+
39
+ To use it within a pyannote speaker diarization pipeline, convert the model to a pyannote compatible format:
40
+
41
+ ```python
42
+ segmentation_model = segmentation_model.to_pyannote_model()
43
+ ```
44
+
45
+ ...load it in the [pyannote/speaker-diarization-3.1](https://huggingface.co/pyannote/speaker-diarization-3.1) pipeline:
46
+
47
+ ```python
48
+
49
+ from pyannote.audio import Pipeline
50
+ import torch
51
+
52
+ device = torch.device("cuda:0") if torch.cuda.is_available() else torch.device("cpu")
53
+
54
+
55
+ # load the pre-trained pyannote pipeline
56
+ pipeline = Pipeline.from_pretrained("pyannote/speaker-diarization-3.1")
57
+ pipeline.to(device)
58
+
59
+ # Replace the pre-trained segmentation model with the fine-tuned version:
60
+ pipeline._segmentation.model = model.to(device)
61
+ ```
62
+
63
+ ...and use it on a audio example:
64
+
65
+ ```python
66
+ # load dataset example
67
+ dataset = load_dataset("diarizers-community/callhome", "jpn", split="data")
68
+ sample = dataset[0]["audio"]
69
+
70
+ # pre-process inputs
71
+ sample["waveform"] = torch.from_numpy(sample.pop("array")[None, :]).to(device, dtype=model.dtype)
72
+ sample["sample_rate"] = sample.pop("sampling_rate")
73
+
74
+ # perform inference
75
+ diarization = pipeline(sample)
76
+
77
+ # dump the diarization output to disk using RTTM format
78
+ with open("audio.rttm", "w") as rttm:
79
+ diarization.write_rttm(rttm)
80
+ ```
81
+
82
+
83
 
84
  ## Intended uses & limitations
85