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