Merge Interview Transcript Segments Into Speaker Turns

Last updated: November 29, 2026

Quick Overview

Speech-to-text returns short timestamped segments tagged with a speaker; merge consecutive segments from the same speaker into a single turn when the silence between them is at most a given gap, dropping empty segments.

Micro1
Coding & Algorithms
Software Engineer
Micro1
November 29, 2026
Software Engineer
Technical Screen
Coding & Algorithms
Easy

0

0

0 solved


Speech-to-text returns short timestamped segments tagged with a speaker; merge consecutive segments from the same speaker into a single turn when the silence between them is at most a given gap, dropping empty segments.

A spoken AI interviewer needs clean turns before an LLM can score answers or a recruiter can read the transcript. The screen checks careful iteration, sorting by time, and sensible handling of noisy STT output.

What the Interviewer Expects
  • Sorts segments by start time first
  • Merges only same speaker within the gap
  • Extends the end with max to handle overlapping segments
  • Strips and skips empty text
  • Keeps the function pure and returns new tuples
Key Topics to Cover
Sorting
Linear scans
Stream processing
Speech-to-text output
Edge case handling
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • What changes if the two speakers talk over each other and segments interleave?
  • How would you stream this so turns are emitted while the interview is still running?
  • How would you pick max_gap from real data?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

Input: list of (speaker, start, end, text) in seconds, possibly out of order, plus max_gap. Output: list of turns in time order. Two segments merge when they share a speaker and `next.start - curr...

High-Level Design

Sort by (start, end), then scan once holding the last emitted turn. If the incoming segment continues the same speaker within the gap, extend the turn's end to max(end_a, end_b) and append text wi...


Submit Your Answer
Markdown supported

Related Questions