code: def merge_equal_neighbors(self):
          
          IDX_LENGTH = 3
  
          merged = self.segs.copy()
          current_start = 0
          j = 0
          seg = self.segs.iloc[0]
          for i in range(1, self.num_segments):
              seg = self.segs.iloc[i]
              last = self.segs.iloc[i - 1]
              if seg.speaker == last.speaker:
                  merged.iat[j, IDX_LENGTH] = seg.start + seg.length - current_start
              else:
                  j += 1
                  merged.iloc[j] = seg
                  current_start = seg.start
          merged = merged.iloc[:(j+1)]
          merged.sort_values('start', inplace = True)
  
          return self.update_segs(merged)
docs: Merge neighbors with same speaker.