Skip to main content

Overview

Whisper can extract word-level timestamps using cross-attention patterns and dynamic time warping (DTW). This feature enables precise synchronization between transcribed text and the original audio.
Word-level timestamps are extracted using the cross-attention mechanism, which aligns the decoder’s attention to specific audio frames for each word.

Basic Usage

CLI

Enable word timestamps with the --word_timestamps flag:
The output JSON file will include word-level timing information:

Python API

Set word_timestamps=True when calling transcribe():

Output Format

When word timestamps are enabled, each segment includes a words list:
Each word entry contains:
  • word: The word text (including leading/trailing spaces and punctuation)
  • start: Start time in seconds
  • end: End time in seconds
  • probability: Average token probability for the word

Punctuation Handling

Whisper automatically merges punctuation marks with adjacent words:

Prepended Punctuation

These marks are merged with the next word:
Example: "Hello → treated as one word

Appended Punctuation

These marks are merged with the previous word:
Example: world! → treated as one word

Custom Punctuation Rules

Advanced Options

Subtitle Formatting

Word timestamps enable advanced subtitle formatting:
Maximum number of characters per line before breaking.

Hallucination Detection

Skip silent periods when hallucinations are detected:
This helps prevent the model from generating text during long silent periods.

Use Cases

1. Precise Subtitle Generation

2. Audio-Text Alignment for Editing

3. Karaoke-Style Lyrics Display

4. Speech Segmentation and Analysis

5. Create Clickable Transcript

Limitations and Considerations

Word-level timestamps on translations may not be reliable, as the timing is based on the source language but the text is in English.

Accuracy Factors

  • Word timestamps are more accurate for clear speech with minimal background noise
  • Fast speech or overlapping speakers can reduce accuracy
  • The probability field indicates confidence for each word
  • Very short words (< 0.133s) or very long words (> 2.0s) may indicate alignment issues

Performance Impact

Enabling word timestamps:
  • Increases processing time (requires cross-attention analysis and DTW)
  • Uses additional memory for storing alignment data
  • Is most noticeable on longer audio files

Best Practices

  1. Use higher-quality models (medium, large) for better timestamp accuracy
  2. Filter out low-probability words for critical applications
  3. Validate timestamps against actual audio for important use cases
  4. Consider segment-level timestamps for less critical applications