code: def get_labels(data, win_len=0.02, stride=0.02):
      """make labels for training/test
  
      Arguments
      ---------
      data (dict): a dictionary that contains:
          {
              'wav': path,
              'duration': dur,
              'emotion': [{'emo': emo, 'start': s, 'end': e}],
              'transcription': trans,
          }
      win_len (float): the frame length used for frame-wise prediction
      stride (float): the frame length used for frame-wise prediction
  
      """
      emo_list = data["emotion"]
      assert len(emo_list) == 1
  
      duration = data["duration"]
      emotion = data["emotion"][0]["emo"]
      emo_start = data["emotion"][0]["start"]
      emo_end = data["emotion"][0]["end"]
  
      number_frames = int(duration / stride) + 1
  
      intervals = []
      labels = []
      if emo_start != 0:
          intervals.append([0.0, emo_start])
          labels.append("n")
      intervals.append([emo_start, emo_end])
      labels.append(emotion[0])
      if emo_end != duration:
          intervals.append([emo_end, duration])
          labels.append("n")
  
      start = 0.0
      frame_labels = []
      for i in range(number_frames):
          win_start = start + i * stride
          win_end = win_start + win_len
  
          # make sure that every sample exists in a window
          if win_end >= duration:
              win_end = duration
              win_start = max(duration - win_len, 0)
  
          for j in range(len(intervals)):
              if getOverlap(
                  [win_start, win_end], intervals[j]
              ) >= 0.5 * (win_end - win_start):
                  emo_frame = labels[j]
                  break
          frame_labels.append(emo_frame)
          if win_end >= duration:
              break
      return intervals, labels, frame_labels
  
file_path: speechbrain/recipes/ZaionEmotionDataset/emotion_diarization/zed_prepare.py
imports: import os
  import random
  import json
  import logging
  from datasets.prepare_EMOVDB import prepare_emovdb
  from datasets.prepare_ESD import prepare_esd
  from datasets.prepare_IEMOCAP import prepare_iemocap
  from datasets.prepare_JLCORPUS import prepare_jlcorpus
  from datasets.prepare_RAVDESS import prepare_ravdess
label_desc: Use image node_id 2 for calling a global function with example usage: get_labels(data, win_len, stride) and returns: intervals,  labels,  frame_labels