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:
Python API
Setword_timestamps=True when calling transcribe():
Output Format
When word timestamps are enabled, each segment includes awords list:
word: The word text (including leading/trailing spaces and punctuation)start: Start time in secondsend: End time in secondsprobability: 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:"Hello → treated as one word
Appended Punctuation
These marks are merged with the previous word:world! → treated as one word
Custom Punctuation Rules
Advanced Options
Subtitle Formatting
Word timestamps enable advanced subtitle formatting:- Line Width Control
- Line Count
- Word Highlighting
- Words Per Line
Hallucination Detection
Skip silent periods when hallucinations are detected: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
Accuracy Factors
- Word timestamps are more accurate for clear speech with minimal background noise
- Fast speech or overlapping speakers can reduce accuracy
- The
probabilityfield 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
- Use higher-quality models (
medium,large) for better timestamp accuracy - Filter out low-probability words for critical applications
- Validate timestamps against actual audio for important use cases
- Consider segment-level timestamps for less critical applications