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!
Help! Sms speech from specific contact containing digits
Moderator: Martin
-
- Posts: 5
- Joined: 03 Dec 2014 09:13
Re: Help! Sms speech from specific contact containing digits
Hi,
A script to remove everything from a text except the numbers could look like this (goes in an action Script):
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:
See also this page: Script examples
Regards,
Martin
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 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 ");
Regards,
Martin
-
- Posts: 5
- Joined: 03 Dec 2014 09:13
Re: Help! Sms speech from specific contact containing digits
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?
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
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
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
-
- Posts: 5
- Joined: 03 Dec 2014 09:13
Re: Help! Sms speech from specific contact containing digits
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
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
-
- Posts: 5
- Joined: 03 Dec 2014 09:13
Re: Help! Sms speech from specific contact containing digits
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?
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
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:
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
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);
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
-
- Posts: 5
- Joined: 03 Dec 2014 09:13
Re: Help! Sms speech from specific contact containing digits
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.
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.