MCPcopy Create free account
hub / github.com/modelscope/FunASR / calc_diarization_error

Method calc_diarization_error

funasr/models/eend/utils/report.py:204–229  ·  view source on GitHub ↗

Calc diarization error. Args: decisions: TODO. label: TODO. label_delay: TODO.

(self, decisions, label, label_delay=0)

Source from the content-addressed store, hash-verified

202 return res, loss_s, stats.keys(), vad_acc
203
204 def calc_diarization_error(self, decisions, label, label_delay=0):
205 """Calc diarization error.
206
207 Args:
208 decisions: TODO.
209 label: TODO.
210 label_delay: TODO.
211 """
212 label = label[: len(label) - label_delay, ...]
213 n_ref = torch.sum(label, dim=-1)
214 n_sys = torch.sum(decisions, dim=-1)
215 res = {}
216 res["speech_scored"] = torch.sum(n_ref > 0)
217 res["speech_miss"] = torch.sum((n_ref > 0) & (n_sys == 0))
218 res["speech_falarm"] = torch.sum((n_ref == 0) & (n_sys > 0))
219 res["speaker_scored"] = torch.sum(n_ref)
220 res["speaker_miss"] = torch.sum(torch.max(n_ref - n_sys, torch.zeros_like(n_ref)))
221 res["speaker_falarm"] = torch.sum(torch.max(n_sys - n_ref, torch.zeros_like(n_ref)))
222 n_map = torch.sum(((label == 1) & (decisions == 1)), dim=-1).to(torch.float32)
223 res["speaker_error"] = torch.sum(torch.min(n_ref, n_sys) - n_map)
224 res["correct"] = torch.sum(label == decisions) / label.shape[1]
225 res["diarization_error"] = (
226 res["speaker_miss"] + res["speaker_falarm"] + res["speaker_error"]
227 )
228 res["frames"] = len(label)
229 return res

Callers 1

report_coreMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected