Align speech timestamps: map chunk results to source audio
Map each chunk-relative recognition time to one source-audio timeline. Track sample rate, chunk offsets, gaps, and overlap; packet arrival time is not sample time.
Timestamp alignment maps model output times to the source-audio timeline. Decide whether each value is chunk-relative or stream-absolute. With a fixed sample rate, time is sample index divided by that rate; add the chunk's source start offset for relative output.
Store the actual source start sample and rate for every chunk. Count samples consumed, not just chunk number; record reused overlap so it is not counted twice. After resampling, convert indices using the rate of the corresponding buffer. Mark dropped or repeated samples and retry input.
RTP timestamps represent when the packet's first sample was sampled, not packet arrival or decode completion. Different media streams can have different clock rates and offsets; map them through a shared reference clock such as RTCP Sender Reports instead of comparing timestamp numbers directly. RFC 3550 §5.1 A constant shift suggests a missing offset; growing drift suggests clock/rate mismatch; jumps at chunk boundaries suggest gaps or overlap. Test known audio events at the beginning, middle, end, and boundaries. Forced alignment positions a supplied transcript; streaming alignment maps returned segments to the source timeline. Neither guarantees transcript truth.