Author Topic: How to make text to speech say numbers digit by digit?  (Read 1062 times)

WillRiker2701

  • Newbie
  • *
  • Posts: 13
How to make text to speech say numbers digit by digit?
« on: February 09, 2023, 03:49:53 PM »
Hi.

I am giving to TTS a variable to say that's in the form of "118.3" for example.
TTS is currently saying: One hundred eighteen point three
But i need it to say: One one eight point three

What's the best way to do it?

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4759
  • RTFM
Re: How to make text to speech say numbers digit by digit?
« Reply #1 on: February 09, 2023, 04:28:29 PM »
The official SSML specification unfortunately does not appear to support this.
The closest you can get is to use the "say-as" tag to have a number spoken as characters, but then the "." character will be spoken as "period" or "dot", by US and UK engines, respectively.

What you can do is manually replace that character with the word "point", and exclude it from the say-as tag, E.G.
Code: [Select]
Set decimal [my decimal variable] value to 123456789.12
Say, '<speak version="1.0" xml:lang="en-US"> <say-as interpret-as="characters">{TXTREPLACEVAR:"{DECINV:my decimal variable}":".":"</say-as>point<say-as interpret-as="characters">"}</say-as> </speak>'

Note that the "xml:lang" tag is mandatory, and should be set to the language of the voice you want to use. If you have that set to "en-US" but the voice you've selected in the "Voice" dropdown is a UK English voice, a US English voice will be used instead of that selected voice.