Luke Oliff.

TIL: Processing STT Word Timestamps With awk

·TIL·1 min read·Luke Oliff

Speech-to-text APIs return word-level timestamps. awk processes them faster than any Python script for simple transforms.

cat transcript.json | jq -r '.results.channels[0].alternatives[0].words[] | [.word, .start, .end] | @tsv' | awk '{print $2, $3, $1}'

awk splits each line into columns by whitespace. Reorder them, filter by time range.

cat timestamps.txt | awk '$2 > 10.0 && $3 < 20.0 {print $1}'

Extract words spoken between 10 and 20 seconds.

cat timestamps.txt | awk '{sum += $3 - $2} END {print "Total speech duration:", sum, "seconds"}'
``"

Sum up total speaking time.

### Is awk on macOS?

Yes. Built into every macOS and Linux install.