Awesome TTS - Please help with Regex. Make first word after linebreak start with uppercase

Hi, can you please help me with this regex syntax for the Advanced Text Configuration in Awesome TTS. I want each first word after a new line break to start with an upper case.

I have cards with normal text and bullet point lists. My problem is that some bullet points start with capital letters, some with lower case letters, which means the pauses between bullet point items are irregular when converted to speech. The pause is great if there is a capital letter at the beginning, but it’s too short if there is a lowercase letter at the beginning. I’ve already selected the ‘convert any newline(s) into an ellipsis’ option in Awesome TTS, but this is not enough, pauses are still shorter if a new line starts with a lowercase letter. I want to change this by making sure each new line starts with a capital letter, so that during speech conversion the pauses are all equal. I assume this would be possible through regex syntax?

To clarify further, here is a screenshot:

The text on the front of the card is typical of the type of content I’m converting. The text on the back of the card is what it should look like when sent to speech conversion (every new line starts with a capital letter, thereby equal pauses are maintained).

If you could help me with the syntax that I can enter into the Advanced Text Regex dialogue box, that would be awesome!

Please let me know if this doesn’t make sense.

Thank you so much for your help :slight_smile:

I highly recommend this tool for experimenting with regex in python:

https://pythex.org/

If you copy the example that you shared in the screenshot as text here, that would be helpful.

2 Likes

Hi, thank you for your reply. I’ve never written anything in regex before, so I’m really struggling with this.

But basically what I need is a regex that finds words starting with a lower case after a < li > marker and turns them into words starting with an upper case.

For example, my flashcard may be

  • Text
  • Text
  • text
  • text
    • text
    • Text
    • Text
      • text
      • text
      • text
      • Text

AwesomeTTS looks at the html of this, so I need a regex that finds the first letter after the < li > marker and if it is in lowercase it needs to convert it into upper case.

This needs to work with the Awesome TTS add-on, where I can enter a find and replace regex.

If you can help me with this, that would be absolutely awesome :smiley:

I managed to find a solution to this now. It has been a bit of journey though for me. Initially I tried the following Regex Syntax:

(?<=< li >)([a-z]) replace with \U$1 (to make first word in list item start with uppercase)
(?<=< li >)([t]) replace with T (makes specific first character in first word of list item uppercase)
< li >t replace with < li >T (to work on individual characters and replace the < li > tag with it)

None of the above worked and it was mentioned to me that this may be a limitation of Python.

However, what worked for me was this regex syntax:

\b(t) replace with T (makes each word begin with a capital letter)

I created a variation of this syntax for every letter of the alphabet. This is probably a bit of a crude hack, but it solves my problem of the pronunciation and it does not seem to change the pronunciation of words otherwise.

2 Likes