Page 1 of 1

Help! Sms speech from specific contact containing digits

Posted: 18 Dec 2014 14:13
by Iflyisland11
I want to have only the digits announced or spoken from a text from a specific contact. I'm starting to figure everything out slowly but surely but I havnt had luck with this.

Note:all the basic stuff like sms sender and speech is basic but it's just the scripting or expressions I'm lost with. Please help me out!

Re: Help! Sms speech from specific contact containing digits

Posted: 18 Dec 2014 19:20
by Martin
Hi,

A script to remove everything from a text except the numbers could look like this (goes in an action Script):

Code: Select all

numbers_only = replaceAll(sms_text, "\\D", "");
The regular expression \\D matches every non-digit and replaces the character with the empty string (effectively deleting the non-digit).
The value text123abc456xyz would be converted to 123456.
See also this page: Regular expression syntax

Following script could be used to add a space between two digits which can be helpful when you want to speak the digits one by one and not as a big number:

Code: Select all

numbers_only = replaceAll(numbers_only, "(.)", "$1 ");
See also this page: Script examples

Regards,
Martin

Re: Help! Sms speech from specific contact containing digits

Posted: 22 Dec 2014 08:15
by Iflyisland11
Thank you for helping! I really appreciate it. I plan on learning automagic a through z. It will take time so any help I can get in the beginning really helps. Thanks again.

I've been reading over the syntax and script examples to get better understand of your example but still dont fully understand yet . How would I implement the script?

Ex.

Sms received
Code you gave me
Then speech output sms received?

Would you mind giving an example flow?

Re: Help! Sms speech from specific contact containing digits

Posted: 22 Dec 2014 20:54
by Martin
Here's an example flow:
Speak out SMS digits

The first action in the flow is only used to simulate an incoming SMS. It simulates the text "the pin is 12345. have a nice day.". You can remove this action when you want to test the flow using a real SMS.
The second action of the flow is the script that removes all non-digits and then replaces 12345 by 1 2 3 4 5. The result is stored in variable numbers_only.
The speech output action uses the text {numbers_only} which instructs Automagic to replace the curly braces and the variable name with the real content of the variable when the action is executed.

Regards,
Martin

Re: Help! Sms speech from specific contact containing digits

Posted: 23 Dec 2014 00:14
by Iflyisland11
Interesting. Thank you for taking time out to do that for me.it opens up a lot of doors and understanding.

I'm on a mission to be proficient.

Is the language used within automagic universal or could be defined as a language? I'm asking so I can read more about it in other texts/videos. Its unfortunate how the beginning of learning something new is the only thing that limits creativity! Ha.

Thank you,
Chris

Re: Help! Sms speech from specific contact containing digits

Posted: 23 Dec 2014 00:32
by Iflyisland11
Forgot to mention.

Flawless. Just what I needed.

Having a million questions is never fun for both. So please don't dislike the beginner. Ha.

Tiny thing-
I tried a few variations but obviously missing a snippet somewhere. Speech output wording it as a number with a decibel?


Ex: 52.13 = 52 point 13
Big change in scripting?

Re: Help! Sms speech from specific contact containing digits

Posted: 29 Dec 2014 18:32
by Martin
Maybe I don't understand what you want to achieve. Do you want to keep the decimal dot when the SMS contains a decimal number like 52.13?

Extracting the decimal number is probably quite complicated in general but could be done using numbers_only = replaceAll(sms_text, "[^\\d\\.]", "") in some cases of input text.

You could also use the function matches to extract the values of a capturing group:

Code: Select all

groups = newList();
matches(sms_text, ".*?([\\d.]+).*?", groups);
number = getElement(groups, 1);
Both solutions above will extract incorrect numbers when the input text contains a text like 'xyz 52.13.45.bla'.

You can also do a Google search to find pointers to other solutions.
This post on stackoverflow contains some interesting hints:
http://stackoverflow.com/questions/5917 ... ls-in-text

Re: Help! Sms speech from specific contact containing digits

Posted: 29 Dec 2014 22:26
by Iflyisland11
Okay. this helps a lot. Thank you.
Yeah I am trying to keep the decimal. What I'm doing is creating a shortcut to extract the numbers and decimal and read aloud correctly. Your example will help me a lot. I need push in the right direction with all of this.