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 |
Referenceο
- speechbrain.utils.EDER.EDER(prediction, id, duration, emotion, window_length, stride)[source]ο
Calculates the EDER value
- Parameters:
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
- Return type:
the calculated 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.
- Parameters:
lol (list of list) β Each list contains [utt_id, sseg_start, sseg_end, emo_label].
- 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
- Parameters:
- 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']]