Skip to content

Conversation

@Hormold
Copy link
Contributor

@Hormold Hormold commented Nov 14, 2025

Additional TTS preprocessing for:

  • Brackets <> - removes HTML-like tags: "Hello <tag>world" → "Hello world"
  • Replace newlines with periods - converts line breaks: "First\nSecond" → "First Second"
  • Format numbers - converts to words: "I have 5 apples" → "I have five apples"
  • Currency - "$42.50" → "forty two dollars and fifty cents"
  • Dates - "2024-12-25" → "Wednesday, December 25, 2024"
  • Phone numbers - "555-123-4567" → "5 5 5 1 2 3 4 5 6 7"
  • Emails - "[email protected]" → "john at example dot com"
  • Percentages, distances, units, times, acronyms

@Hormold Hormold changed the base branch from main to theo/v1.3 November 14, 2025 00:47
@Hormold Hormold requested a review from longcw November 14, 2025 21:14
@Hormold
Copy link
Contributor Author

Hormold commented Nov 14, 2025

@longcw one thing: not sure if we need to enable some of these things by default


# Preserve years
if 1900 <= num <= 2099:
return str(num_str)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we need split it: 2020 -> 20 20

Format dollar amounts for TTS:
- $5 -> "five dollars"
- $12.50 -> "twelve dollars and fifty cents"
- $0.023 -> "zero point zero two three dollars" (speaks out each decimal digit)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thinking - maybe should we go deeper and convert it to - "zero pint zero twenty three dollars"?

async def format_phone_numbers(text: AsyncIterable[str]) -> AsyncIterable[str]:
"""
Format phone numbers for TTS:
- 555-123-4567 -> "5 5 5 1 2 3 4 5 6 7"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is only for US phone numbers. should we cover +1 phone numbers also?

@Hormold Hormold marked this pull request as ready for review November 14, 2025 21:19
from typing import Literal, Optional, Union

# Number to word mappings for TTS preprocessing
ONES = ["", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we move these to a separate file, also the markdown and emoji filters can move to files since we are going to have more transforms.

@davidzhao davidzhao marked this pull request as draft November 16, 2025 20:59
Base automatically changed from theo/v1.3 to main November 17, 2025 05:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants