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