docs(elevenlabs): clarify alignment leading-space handling

This commit is contained in:
Mark Backman
2026-05-05 14:39:59 -04:00
parent 2447db766e
commit 2620e76dab

View File

@@ -291,12 +291,13 @@ def _strip_utterance_leading_spaces(
) -> Mapping[str, Any]: ) -> Mapping[str, Any]:
"""Return alignment with utterance-leading space chars removed, if requested. """Return alignment with utterance-leading space chars removed, if requested.
Normalized alignment chunks from ElevenLabs often begin with a space. On the ElevenLabs Flash normalized alignment chunks can begin with a leading space
first chunk of an utterance, that space is leading whitespace and should not at the start of an utterance. Strip only utterance-leading spaces so bot
become a text token. On subsequent chunks, however, a leading space can be a turn text does not start with whitespace. On subsequent chunks, however, a
real inter-word separator (Flash models commonly split sentences this way), leading space can be a real inter-word separator (Flash models commonly
so it must be preserved for ``calculate_word_times`` to flush any partial split sentences this way), so it must be preserved for
word carried over from the previous chunk. ``calculate_word_times`` to flush any partial word carried over from the
previous chunk.
Args: Args:
alignment: Alignment dict from the API. alignment: Alignment dict from the API.