Page 1 of 1

Spoken number format

Posted: 16 Nov 2019 04:15
by Lucy
Hey how can i implement something like this script example from the forum...

"value = "00411234567"; optimized_value = replaceAll(value, "(.)", "$1 "); log(optimized_value);// 0 0 4 1 1 2 3 4 5 6 7"

TO THESE VARIABLES WHEN USING SPEECH OUTPUT...

"incoming_number or sms_sender"

Re: Spoken number format

Posted: 22 Nov 2019 17:25
by Desmanto
just replace the variable name right?

Code: Select all

speak = replaceAll(incoming_number, "(.)", "$1 ");
Use {speak} in the speech output.

Re: Spoken number format

Posted: 22 Nov 2019 21:19
by Lucy
Sorry... yeah i got it figured out. Thank you

Re: Spoken number format

Posted: 12 Jan 2020 21:30
by Micky Micky
Hi
I've something similar to this, which I solved by my crude method approach. I'm expecting you could do better.

The string contains something like "BATMAN PREMIERES ON TELEVISION 1966"
1966 needs to be split into 19 66 to be spoken properly.

I've done it like so: (Feel free to laugh)

a = "BATMAN PREMIERES ON TELEVISION 1966";
b = findAll(a,"[0-9]");
len = length (b);

len == 4;

c = join (b, ",");
d = replace (c, ",","");
addElement (b, 2, " ");
f = join (b, ",");
g = replace (f, ",","");
a = replace (a, d, g);
a = trim (a);

Note I check the length so it only applies to years and not to other numbers in the string.

Thanks