-
Notifications
You must be signed in to change notification settings - Fork 1
/
run_diarization_recipe.py
52 lines (43 loc) · 1.67 KB
/
run_diarization_recipe.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
########################################################################
# Author : David Erik Mollberg & Carlos Daniel Hernández Mena
# Date : November 1st, 2023
# Location : Reykjavík University and Tiro ehf.
# ########################################################################
# Step 1
# Convert the audio files and transcript into a diarization format.
# The output is folder for each conversation with three files. Combined
# audio file, and transcript in JSON and RTTM format
from src.convert2diarization import convert
convert()
# ########################################################################
# Step 2
# To replicate the results for the diarization experiment.
# First install the Pyannote toolkit (https://github.com/pyannote/pyannote-audio)
# per their instructions and your system. Replace the variable with your
# authentication token.
# Using a GPU (device='cuda') the decoding only takes a few minutes.
from src.diarize import diarize
token = ""
# device = "cuda"
device = "cpu"
diarize(authentication_token=token, device=device)
# ########################################################################
# Step 3
# To evaluate the results we use the NIST scoring tool, packaged
# here https://github.com/nryant/dscore.
# Install that toolkit and change the variable 'path2dscore' to your
# install location
import subprocess
path2dscore = None
if path2dscore:
subprocess.call(
"python",
f"{path2dscore}/score.py",
"--collar 1",
"-R results/diarize/ref_dir.scp",
"-S results/diarize/hyp_dir.scp",
)
else:
print(
"Please install 'https://github.com/nryant/dscore' and provied the path to the tool."
)