speechbrain.utils.EDER module
Calculates Emotion Diarization Error Rate (EDER) which is the sum of Missed Emotion (ME), False Alarm (FA), and Confusion (CF).
- Authors
Yingzhi Wang 2023
Summary
Functions:
Calculates the EDER value |
|
Distributes the overlapped speech equally among the adjacent segments with different emotions. |
|
get the overlapped length of two intervals |
|
Returns True if segments are overlapping. |
|
Merge adjacent sub-segs if they are the same emotion. |
|
change reference to a list of list :param id (str): :type id (str): id of the utterance :param duration (float): :type duration (float): duration of the utterance :param emotion (list of dicts): e.g. |
Reference
- speechbrain.utils.EDER.EDER(prediction, id, duration, emotion, window_length, stride)[source]
Calculates the EDER value
- Args:
prediction (list): a list of frame-wise predictions of the utterance id (str): id of the utterance duration (float): duration of the utterance emotion (list of dicts): the ground truth emotion and its duration,
e.g. [{‘emo’: ‘angry’, ‘start’: 1.016, ‘end’: 6.336}]
window_length (float): the frame length used for frame-wise prediction stride (float): the frame length used for frame-wise prediction
- Returns:
float: the calculted EDER for the utterance
Example
>>> from speechbrain.utils.EDER import EDER >>> prediction=['n', 'n', 'n', 'a', 'a', 'a'] >>> id="spk1_1" >>> duration=1.22 >>> emotion=[{'emo': 'angry', 'start': 0.39, 'end': 1.10}] >>> window_length = 0.2 >>> stride = 0.2 >>> EDER(prediction, id, duration, emotion, window_length, stride) 0.2704918032786885
- speechbrain.utils.EDER.getOverlap(a, b)[source]
get the overlapped length of two intervals
Example
>>> from speechbrain.utils.EDER import getOverlap >>> interval1=[1.2, 3.4] >>> interval2=[2.3, 4.5] >>> getOverlap(interval1, interval2) 1.1
- speechbrain.utils.EDER.is_overlapped(end1, start2)[source]
Returns True if segments are overlapping.
- Parameters:
- Returns:
overlapped – True of segments overlapped else False.
- Return type:
Example
>>> from speechbrain.processing import diarization as diar >>> diar.is_overlapped(5.5, 3.4) True >>> diar.is_overlapped(5.5, 6.4) False
- speechbrain.utils.EDER.merge_ssegs_same_emotion_adjacent(lol)[source]
Merge adjacent sub-segs if they are the same emotion. :param lol: Each list contains [utt_id, sseg_start, sseg_end, emo_label]. :type lol: list of list
- Returns:
new_lol – new_lol contains adjacent segments merged from the same emotion ID.
- Return type:
Example
>>> from speechbrain.utils.EDER import merge_ssegs_same_emotion_adjacent >>> lol=[['u1', 0.0, 7.0, 'a'], ... ['u1', 7.0, 9.0, 'a'], ... ['u1', 9.0, 11.0, 'n'], ... ['u1', 11.0, 13.0, 'n'], ... ['u1', 13.0, 15.0, 'n'], ... ['u1', 15.0, 16.0, 'a']] >>> merge_ssegs_same_emotion_adjacent(lol) [['u1', 0.0, 9.0, 'a'], ['u1', 9.0, 15.0, 'n'], ['u1', 15.0, 16.0, 'a']]
- speechbrain.utils.EDER.reference_to_lol(id, duration, emotion)[source]
change reference to a list of list :param id (str): :type id (str): id of the utterance :param duration (float): :type duration (float): duration of the utterance :param emotion (list of dicts): e.g. [{‘emo’: ‘angry’, ‘start’: 1.016, ‘end’: 6.336}] :type emotion (list of dicts): the ground truth emotion and its duration,
- Returns:
lol – It has each list structure as [rec_id, sseg_start, sseg_end, spkr_id].
- Return type:
Example
>>> from speechbrain.utils.EDER import reference_to_lol >>> id="u1" >>> duration=8.0 >>> emotion=[{'emo': 'angry', 'start': 1.016, 'end': 6.336}] >>> reference_to_lol(id, duration, emotion) [['u1', 0, 1.016, 'n'], ['u1', 1.016, 6.336, 'a'], ['u1', 6.336, 8.0, 'n']]
- speechbrain.utils.EDER.distribute_overlap(lol)[source]
Distributes the overlapped speech equally among the adjacent segments with different emotions.
- Parameters:
lol (list of list) – It has each list structure as [rec_id, sseg_start, sseg_end, spkr_id].
- Returns:
new_lol – It contains the overlapped part equally divided among the adjacent segments with different emotion IDs.
- Return type:
Example
>>> from speechbrain.processing import diarization as diar >>> lol = [['r1', 5.5, 9.0, 's1'], ... ['r1', 8.0, 11.0, 's2'], ... ['r1', 11.5, 13.0, 's2'], ... ['r1', 12.0, 15.0, 's1']] >>> diar.distribute_overlap(lol) [['r1', 5.5, 8.5, 's1'], ['r1', 8.5, 11.0, 's2'], ['r1', 11.5, 12.5, 's2'], ['r1', 12.5, 15.0, 's1']]