units
Expand unit abbreviations into their spoken form for TTS.
- async pipecat.utils.text.transforms.units.expand_units(text: str, aggregation_type: str | AggregationType) str[source]
Expand unit abbreviations to their full spoken form.
- Parameters:
text – Input text possibly containing unit expressions.
aggregation_type – Aggregation type of the text frame (unused).
- Returns:
Text with unit abbreviations replaced by spoken equivalents.
Example:
result = await expand_units("Run 5km at 100kph", "*") # "Run 5 kilometers at 100 kilometers per hour"