Re: Date interpretation help
2021/03/20 14:56:17
(permalink)
I would not put much faith into SSML documentation - it may say one thing, but what the actual TTS voice in use understands and implements is another thing. Also, some voices will say the date formatted like this correctly, at least if your TTS voice is set to American English. For example, Google TTS American English voices say them correctly in my tests.
Otherwise, what would you like the TTS voice to actually read aloud? When you encounter e.g.:
10/13/1959
Would it be OK if it reads "ten thirteen, nineteen fifty nine"? Most people in America would understand it perfectly. Or do you want the app to say precisely: "thirteenth of October, nineteen fifty nine" or "October thirteen, nineteen fifty nine"?
If the first option above is OK, then a simple substitution like:
Type: RegEx
Pattern: \b(\d{1,2})/(\d{1,2})/(\d{2,4})\b
Replace: $1 $2, $3
is all you need. If you want the name of the month to be said aloud, again we don't need SSML (which may be not implemented fully, or implemented incorrectly), but instead we would need to create 12 substitutions like:
Type: RegEx
Pattern: \b(1|01)/(\d{1,2})/(\d{2,4})\b
Replace: January $2, $3
Type: RegEx
Pattern: \b(2|02)/(\d{1,2})/(\d{2,4})\b
Replace: February $2, $3
...
Type: RegEx
Pattern: \b(12)/(\d{1,2})/(\d{2,4})\b
Replace: December $2, $3
If the TTS voice you are using says years like "one thousand nine hundred fifty nine" and you want "nineteen fifty nine", then we need to modify the year part - here I'm giving only the simple numeric replacement:
Type: RegEx
Pattern: \b(\d{1,2})/(\d{1,2})/(\d{2})(\d{2}){0,1}\b
Replace: $1 $2, $3 $4