numbers
Expand numeric expressions into spoken form for TTS.
- pipecat.utils.text.transforms.numbers.expand_numbers(digit_cutoff: int | None = 2025) Callable[[str, str | AggregationType], object][source]
Return a transform that expands numbers to their spoken form.
When digit_cutoff is set, numbers above it are read digit-by-digit (e.g.
"2026"→"2 0 2 6"). Numbers at or below the cutoff are expanded as quantities (e.g."42"→"forty two"). PassNoneto expand all numbers as words regardless of magnitude.- Parameters:
digit_cutoff – Numbers larger than this value are read digit-by-digit.
Nonedisables the cutoff so every number is expanded as a word.- Returns:
An async transform callable compatible with
text_transforms.
Example:
transform = expand_numbers(digit_cutoff=2025) result = await transform("Room 42 has 1234 seats and opens in 2026", "*") # "Room forty two has one thousand two hundred thirty four seats and opens in 2 0 2 6"