Word timing

Highlight the current word

Reviewed

Request one start and end time per word, in seconds. Keep the whole phrase visible and highlight the word whose interval contains the player’s current time. A sentence timestamp can tell you when to show a line, but the speaker may pause halfway through it.

Sample playerWAV / MONO
Studio check16 kHz
MayaIs the studio booked for Tuesday?
0:00 / 0:10

Play the clip or move the playhead. The highlighted word follows the synthesis timing in our reference JSON.

Request a word timeline

Set AUDIO to a short recording and OPENROUTER_API_KEY to your key. The command uses curl and jq. It prints each recognized word beside its start and end times, so you can check whether the response has enough detail for highlighting. OpenRouter transcription documentation

curl --fail-with-body --silent --show-error \
  'https://openrouter.ai/api/v1/audio/transcriptions' \
  -H "Authorization: Bearer $OPENROUTER_API_KEY" \
  -F "file=@$AUDIO" -F model=openai/whisper-1 \
  -F response_format=verbose_json \
  -F 'timestamp_granularities[]=word' |
  jq -er 'if (.words | length) > 0 then
    .words[] | [.start, .end, .word] | @tsv
  else error("No timed words in the response") end'

Keep the original JSON if you will render these words in an app. In an OpenRouter response, look for the top-level words array. In Deepgram’s prerecorded response for a mono track, look under results.channels[0].alternatives[0].words. When punctuation is enabled, punctuated_word gives the display form while start and end remain attached to the same word. Deepgram word fields and punctuation

Match the highlight to playback

This hand-built example includes a pause. At 0.70 seconds “Blue” has finished. “Sky” begins at 0.95 seconds. Both words stay visible during the gap, with neither highlighted.

const phrase = [
  { word: "Blue", start: 0.30, end: 0.70 },
  { word: "sky.", start: 0.95, end: 1.25 }
];

function activeWord(words, playbackSeconds) {
  return words.findIndex(({ start, end }) =>
    start <= playbackSeconds && playbackSeconds < end
  );
}

activeWord(phrase, 0.50); // 0, Blue
activeWord(phrase, 0.85); // -1, silence
activeWord(phrase, 0.95); // 1, sky.

Call the function with media.currentTime for the phrase on screen. Update it when playback advances and immediately after a seek. This also works when the viewer replays a word or changes playback speed. Preserve the timed words when you add line breaks. If you replace several spoken words with one edited phrase, replay that passage and align it again.

Choose how the highlight will travel

WebVTT can carry internal cue timestamps. In the example below, “sky.” becomes current at 0.950 seconds inside the cue. An inline marker indicates a new word boundary. To turn off the previous word precisely when a pause begins, use the full start/end intervals in your own renderer. Check playback in the intended player before delivery. WebVTT inline timestamp specification

WEBVTT

00:00:00.300 --> 00:00:01.250
Blue <00:00:00.950>sky.

Local check. We ran the lookup on the two-word example, including the pause and the exact end of the last word. The API request is based on the provider documentation. These sample times were chosen to demonstrate playback behavior.

Related reading

Export SRT and WebVTTLabel interview speakersCompare transcription routesThe studio check