Spoken number format

Post your questions and help other users.

Moderator: Martin

Post Reply
Lucy
Posts: 225
Joined: 10 Aug 2019 11:24

Spoken number format

Post by Lucy » 16 Nov 2019 04:15

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"

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Spoken number format

Post by Desmanto » 22 Nov 2019 17:25

just replace the variable name right?

Code: Select all

speak = replaceAll(incoming_number, "(.)", "$1 ");
Use {speak} in the speech output.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

Lucy
Posts: 225
Joined: 10 Aug 2019 11:24

Re: Spoken number format

Post by Lucy » 22 Nov 2019 21:19

Sorry... yeah i got it figured out. Thank you

Micky Micky
Posts: 179
Joined: 16 Oct 2019 17:38

Re: Spoken number format

Post by Micky Micky » 12 Jan 2020 21:30

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
Crude but it works.

Post Reply