Update README.md
Browse files
README.md
CHANGED
@@ -6,12 +6,44 @@ tags:
|
|
6 |
---
|
7 |
|
8 |
```python
|
|
|
|
|
9 |
from pyannote.audio import Pipeline
|
10 |
pipeline = Pipeline.from_pretrained('hbredin/utter-project-diarization')
|
11 |
|
|
|
12 |
import torch
|
13 |
mps = torch.device('mps')
|
14 |
pipeline.to(mps)
|
15 |
|
16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
```
|
|
|
6 |
---
|
7 |
|
8 |
```python
|
9 |
+
|
10 |
+
# load pretrained pipeline
|
11 |
from pyannote.audio import Pipeline
|
12 |
pipeline = Pipeline.from_pretrained('hbredin/utter-project-diarization')
|
13 |
|
14 |
+
# send it to MPS device (on Apple Silicon)
|
15 |
import torch
|
16 |
mps = torch.device('mps')
|
17 |
pipeline.to(mps)
|
18 |
|
19 |
+
# apply it on sample file
|
20 |
+
from pyannote.audio.sample import SAMPLE_FILE
|
21 |
+
diarization = pipeline(SAMPLE_FILE)
|
22 |
+
|
23 |
+
# print output
|
24 |
+
print(diarization)
|
25 |
+
# [ 00:00:06.730 --> 00:00:06.747] A speaker90
|
26 |
+
# [ 00:00:06.747 --> 00:00:07.169] B speaker91
|
27 |
+
# [ 00:00:07.169 --> 00:00:07.185] C speaker90
|
28 |
+
# [ 00:00:07.590 --> 00:00:07.624] D speaker90
|
29 |
+
# [ 00:00:07.624 --> 00:00:08.029] E speaker91
|
30 |
+
# [ 00:00:08.029 --> 00:00:09.970] F speaker90
|
31 |
+
# [ 00:00:09.970 --> 00:00:10.982] G speaker91
|
32 |
+
# [ 00:00:10.459 --> 00:00:14.729] H speaker90
|
33 |
+
# [ 00:00:14.307 --> 00:00:17.884] I speaker91
|
34 |
+
# [ 00:00:18.019 --> 00:00:21.512] J 2
|
35 |
+
# [ 00:00:18.188 --> 00:00:18.407] K speaker91
|
36 |
+
# [ 00:00:21.765 --> 00:00:28.499] L speaker91
|
37 |
+
# [ 00:00:27.824 --> 00:00:29.967] M 2
|
38 |
+
|
39 |
+
# compute diarization error rate
|
40 |
+
from pyannote.metrics.diarization import DiarizationErrorRate
|
41 |
+
metric = DiarizationErrorRate()
|
42 |
+
metric(SAMPLE_FILE['annotation'], diarization, detailed=True)
|
43 |
+
# {'confusion': 6.2540312500000015,
|
44 |
+
# 'missed detection': 0.5480625000000003,
|
45 |
+
# 'correct': 17.547906249999997,
|
46 |
+
# 'false alarm': 0.4811874999999999,
|
47 |
+
# 'total': 24.349999999999998,
|
48 |
+
# 'diarization error rate': 0.2991080595482547}
|
49 |
```
|