Implementation:Elevenlabs Elevenlabs python ForcedAlignmentWordResponseModel
| Attribute | Value |
|---|---|
| Sources | src/elevenlabs/types/forced_alignment_word_response_model.py
|
| Domains | Forced Alignment, Audio Timing, Transcription |
| Last Updated | 2026-02-15 |
Overview
Description
The ForcedAlignmentWordResponseModel represents a single word with its timing information and confidence score from the ElevenLabs forced aligner. In addition to the word text and its start/end times in seconds, this model includes a loss field representing the average alignment loss/confidence score for the word, calculated from its constituent characters. Lower loss values generally indicate higher confidence in the alignment accuracy.
Usage
This model is returned as part of forced alignment results, representing word-level timing data. It is used for tasks such as word-level subtitle synchronization, audio editing at word boundaries, and quality assessment of alignment results (via the loss field). Each instance represents one word's temporal position and alignment confidence in the audio.
Code Reference
Source Location
src/elevenlabs/types/forced_alignment_word_response_model.py
Class Signature
class ForcedAlignmentWordResponseModel(UncheckedBaseModel):
"""
Model representing a single word with its timing information from the aligner.
"""
...
Import Statement
from elevenlabs.types import ForcedAlignmentWordResponseModel
Base Class
UncheckedBaseModel (from elevenlabs.core.unchecked_base_model)
I/O Contract
| Field | Type | Required | Description |
|---|---|---|---|
text |
str |
Yes | The word that was transcribed. |
start |
float |
Yes | The start time of the word in seconds. |
end |
float |
Yes | The end time of the word in seconds. |
loss |
float |
Yes | The average alignment loss/confidence score for this word, calculated from its constituent characters. |
Usage Examples
from elevenlabs import ElevenLabs
client = ElevenLabs(api_key="your_api_key")
# Obtain forced alignment results (from a dubbing or alignment endpoint)
alignment_result = client.audio_native.get_alignment(
audio_id="audio_abc123"
)
# Iterate through word-level alignment data
for word in alignment_result.words:
duration = word.end - word.start
print(
f"Word '{word.text}': "
f"{word.start:.3f}s - {word.end:.3f}s "
f"(duration: {duration:.3f}s, loss: {word.loss:.4f})"
)
# Filter for words with high alignment confidence (low loss)
high_confidence_words = [
w for w in alignment_result.words if w.loss < 0.1
]
print(f"High confidence words: {len(high_confidence_words)}")
# Generate SRT-style subtitles from word timing
for i, word in enumerate(alignment_result.words):
start_h = int(word.start // 3600)
start_m = int((word.start % 3600) // 60)
start_s = word.start % 60
print(f"{start_h:02d}:{start_m:02d}:{start_s:06.3f} -> {word.text}")
Related Pages
- ForcedAlignmentCharacterResponseModel - Character-level forced alignment timing
- Alignment - Chunk-level audio-text alignment data