class_docstr: A ready-to-use SED interface (audio -> emotions and their durations)
  
  Arguments
  ---------
  hparams
      Hyperparameters (from HyperPyYAML)
  
  Example
  -------
  >>> from speechbrain.inference.diarization import Speech_Emotion_Diarization
  >>> tmpdir = getfixture("tmpdir")
  >>> sed_model = Speech_Emotion_Diarization.from_hparams(source="speechbrain/emotion-diarization-wavlm-large", savedir=tmpdir,) # doctest: +SKIP
  >>> sed_model.diarize_file("speechbrain/emotion-diarization-wavlm-large/example.wav") # doctest: +SKIP
docstr: Merge adjacent sub-segs if they are the same emotion.
  Arguments
  ---------
  lol : list of list
      Each list contains [utt_id, sseg_start, sseg_end, emo_label].
  Returns
  -------
  new_lol : list of list
      new_lol contains adjacent segments merged from the same emotion ID.
  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']]
code: def merge_ssegs_same_emotion_adjacent(self, lol):
      """Merge adjacent sub-segs if they are the same emotion.
      Arguments
      ---------
      lol : list of list
          Each list contains [utt_id, sseg_start, sseg_end, emo_label].
      Returns
      -------
      new_lol : list of list
          new_lol contains adjacent segments merged from the same emotion ID.
      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']]
      """
      new_lol = []
  
      # Start from the first sub-seg
      sseg = lol[0]
      flag = False
      for i in range(1, len(lol)):
          next_sseg = lol[i]
          # IF sub-segments overlap AND has same emotion THEN merge
          if (
              self.is_overlapped(sseg[2], next_sseg[1])
              and sseg[3] == next_sseg[3]
          ):
              sseg[2] = next_sseg[2]  # just update the end time
              # This is important. For the last sseg, if it is the same emotion then merge
              # Make sure we don't append the last segment once more. Hence, set FLAG=True
              if i == len(lol) - 1:
                  flag = True
                  new_lol.append(sseg)
          else:
              new_lol.append(sseg)
              sseg = next_sseg
      # Add last segment only when it was skipped earlier.
      if flag is False:
          new_lol.append(lol[-1])
      return new_lol
  
file_path: speechbrain/speechbrain/inference/diarization.py
imports: import torch
  from speechbrain.inference.interfaces import Pretrained
label_desc: Use image node_id 8 for calling the Speech_Emotion_Diarization obj's underlying member method code with example usage: obj.merge_ssegs_same_emotion_adjacent(lol) and returns: new_lol