sms2speech

In this post i describe a simple application that repeat an sms when device receive a message; i'll also describe all androidScript features used.

AndroidScript is based on a global object named app that basically is an API that provided interfaces to device features: it allows to instanziate all kind of object used in an application.

The main one is Layout: you can think of this as a container for your app where all elements are appended as children.

The basic structure of an app is: 

   1: function OnStart()
   2: {
   3: lay = app.CreateLayout( "linear", "VCenter,FillXY" );
   4: app.AddLayout( lay );
   5: }
Show/Hide Line Numbers . Full Screen . Plain

First, all is grouped in a function OnStart(): this is about equivalent to OnDeviceReady() of other libraries/frameworks and runs the app when devide is ready.

Layout is instanziated with 2 arguments:

  1.  linear: this stands for a linear disposition of all controls created in it
  2. VCenter dispose the layout content vertically centered, and FillXY arrange the layout to adact to the device scree.

App and Layout objects have many other argument option, also many methods that to control background color, color, position you can find in docs section of androidScript: i'll describe the ones used in this app.

Let's complete our app adding an image and a button: when clicking on it the sms will be repeated. 

   1: function OnStart()
   2: {
   3:  messaggio = "";
   4:  //Create a layout with objects vertically centered.
   5:  lay = app.CreateLayout( "linear", "VCenter,FillXY" );
   6: img = app.CreateImage( "Img/sms.gif", 0.6, -1 );
   7:  lay.AddChild( img );
   8:  btn = app.CreateButton( "Repeat", 0.3, 0.1 );
   9:  btn.SetMargins( 0, 0.05, 0, 0 );
  10:  lay.AddChild( btn );
  11:  //Set function to call when button pressed.
  12:  btn.SetOnTouch( btn_OnTouch );
  13:  //Add layout to app.
  14:  app.AddLayout( lay );
  15:  //Create SMS object and set callbacks.
  16:  sms = app.CreateSMS();
  17:  sms.SetOnMessage( sms_OnMessage );
  18: }
  19: //speech in-coming SMS messages.
  20: function sms_OnMessage( number, msg )
  21: {
  22:  messaggio = msg;
  23:  //var pitch = 1.0, speed = 1.0;
  24:  //app.TextToSpeech( msg, pitch, speed );
  25:  btn_OnTouch();
  26: }
  27: function btn_OnTouch()
  28: {
  29:  if(messaggio != ""){
  30:  var pitch = 1.0, speed = 1.0;
  31:  app.TextToSpeech( messaggio, pitch, speed );
  32:  }
  33: }
Show/Hide Line Numbers . Full Screen . Plain

 

   1: img = app.CreateImage( "Img/sms.gif", 0.6, -1 )

this is the app method to create an image: it requires 3 args: 

  1. Img/sms.gif is the image sms.gif loaded from the Img folder: yoy can upload images for your app clicking on Assets link in the top bar od the development area of androidScript
  2. the second argument is the H image dimension  in percentage of the layout: 0.6 stands for 60% 
  3. the third argument is the V image dimension  in percentage of the layout:-1 stands for original V dimension of the image but we can define this as a percentage of the layout 

   1: lay.AddChild( img );

now we append the image create as a child of layout. 

   1: btn = app.CreateButton( "Repeat", 0.3, 0.1 );
   2: btn.SetMargins( 0, 0.05, 0, 0 );
   3: lay.AddChild( btn );
   4: btn.SetOnTouch( btn_OnTouch );
   5: //Add layout to app.
   6: app.AddLayout( lay );
Show/Hide Line Numbers . Full Screen . Plain

 the app.createButton(..) method creates a button: this method is invoked with 3 arguments:

  1. "Repeat": is the text appearing on the button
  2. is the H dimension of the button: 0.3 stands for 30% of the layout;
  3. is the V dimension of the button: 0.1 stands for 10% of the layout

the btn.setMargin(...) set the margin of the button : in order are top, right, bottom, left

Finally we append the button to our layout having the grafical aspect completed, so we start with the logic. 

   1: //Set function to call when button pressed.
   2: btn.SetOnTouch( btn_OnTouch );
   3: //Add layout to app.
   4: app.AddLayout( lay );
Show/Hide Line Numbers . Full Screen . Plain

Here we first define an event listener, the function Btn_onTouch() to the button, and append all object to our layout.

   1: sms = app.CreateSMS();
   2: sms.SetOnMessage( sms_OnMessage ); E
Show/Hide Line Numbers . Full Screen . Plain

We first create an sms object with the method app.CreateSMS(), and then assign a function, sms_OnMessage(), as event listener of the sms incoming event.

   1: function sms_OnMessage( number, msg )
   2: {
   3:  messaggio = msg;
   4: btn_OnTouch();
   5: }
Show/Hide Line Numbers . Full Screen . Plain

This function only copy the text of the sms to the global variable message : in this way it is not lost and can be repeate clicking on the button btn. 

   1: function btn_OnTouch()
   2: {
   3:  if(messaggio != ""){
   4:  var pitch = 1.0, speed = 1.0;
   5:  app.TextToSpeech( messaggio, pitch, speed );
   6:  }
Show/Hide Line Numbers . Full Screen . Plain

This function speechs the sms content, by the use od the app.TextToSpeech() method, with 3 args:

  1. messaggio: the variable containg sms content
  2. pitch: quality of sinthetized voice
  3. speed: speed of sinthetized voice

I suggest to try more values for pitch and speed to adapt the response to your locale.

Even if this app already has a pratical usefullness, when androidScript will permit to read device contacts, a usefull upgrade will be to set a list of contact wfrom which repeat sms, but this is another story.

For now, that's all folks.

54 Comments :
Steve Garman
on Saturday 06 September 2014 07:47 AM
Thanks for that Salvatore. It works really well.
Salvatore Fusto
on Monday 08 September 2014 01:07 AM
Happy this is usefull.
regards
essay center writing service
on Thursday 10 December 2015 05:34 AM
Education has many faces which are running in our society. If the student who wants to become a doctor. So the student has to study the natural sciences subject like biology like it, these are also the branches of the educational setup.
celine outlet
on Monday 09 May 2016 02:44 AM
We first create an sms object with the method app.CreateSMS(), and then assign a function, sms_OnMessage(), as event listener of the sms incoming event.
hermes outlet
on Monday 09 May 2016 02:44 AM
you can think of this as a container for your app where all elements are appended as children.
chanel replica
on Thursday 02 June 2016 02:53 AM
Lift Lafayette Karl Lagerfeld, the apperception will be his sunglasses white hair braids Cock absurd day Lengkudaodi image, but in actuality he is abound old elf.
research paper services
on Saturday 25 June 2016 07:45 AM
Your app is very useful and there is a lot of to learn out of your blog. Continue developing your project.
dilan
on Tuesday 28 June 2016 07:53 AM
or your app where all elements are appended as children.
show box app
on Friday 29 July 2016 07:10 AM
ShowBox app is used to stream videos, films, TV Shows and serials with free of cost, and it allows you to download all types of watching latest Showbox movies ..
spicy beef jerky for sale
on Monday 03 October 2016 04:21 AM
It is perfect time to make some plans for the future and it is time to be happy. I’ve read this post and if I could I desire to suggest you few interesting things or tips. Perhaps you could write next articles referring to this article. I want to read more things about it
view homes for sale
on Monday 03 October 2016 08:16 PM
You will find a lot of approaches after visiting your post. I was exactly searching for. Thanks for such post and please keep it up. Great work.
car cover
on Saturday 08 October 2016 04:50 AM
This type of message always inspiring and I prefer to read quality content. so happy to find good place to many here in the post. the writing is just great. thanks for the post.
car cover
on Saturday 08 October 2016 04:54 AM
There is obviously a lot to know about this. I think you made some good points in Features also. ! Keep working, great job!
gift baskets for men
on Sunday 09 October 2016 12:10 AM
I am overwhelmed by your post with such a nice topic. Usually I visit your blogs and get updated through the information you include but today’s blog would be the most appreciable
thank you gift baskets
on Sunday 09 October 2016 02:03 AM
Your blog provided us with valuable information to work with. Each & every tips of your post are awesome. Thanks a lot for sharing. Keep blogging..
tact advisory
on Tuesday 11 October 2016 06:42 AM
Thank you for some other informative website. The place else may just I get that kind of information written in such a perfect method? I have a venture that I am simply now running on, and I’ve been at the glance out for such info
epos system
on Tuesday 11 October 2016 10:22 PM
Connect Multichannel EPoS helps you manage all your stock from one place using simple 'drag and drop', making it easier
Novelty Ties
on Thursday 13 October 2016 01:53 AM
This is a great inspiring article.I am pretty much pleased with your good work.You put really very helpful information
womens wallets
on Friday 14 October 2016 10:38 PM
Thanks a lot very much for the high quality and results-oriented help. I won’t think twice to endorse your blog post to anybody who wants and needs support about this area.
Dieser Spiegelreflexkamera Te
on Monday 17 October 2016 04:21 AM
Very interesting blog. A lot of blogs I see these days don't really provide anything that I'm interested in, but I'm most definitely interested in this one
Carpet Cleaner Mattoon IL
on Monday 17 October 2016 10:14 AM
When your website or blog goes live for the first time, it is exciting. That is until you realize no one but you and your.
natural gastric ball
on Thursday 20 October 2016 05:01 AM
I must say, I thought this was a pretty interesting read when it comes to this topic. Liked the material. . . . .
OEM
on Thursday 20 October 2016 10:40 AM
Great post! I am actually getting ready to across this information, is very helpful my friend. Also great blog here with all of the valuable information you have. Keep up the good work you are doing here.
best electric razor for men
on Friday 21 October 2016 07:38 AM
ave got complete sense without confusing the readers.paralegal services
xtc kopen
on Saturday 22 October 2016 07:35 AM
I am a new user of this site so here i saw multiple articles and posts posted by this site,I curious more interest in some of them hope you will give more information on this topics in your next articles
gsniper review
on Monday 24 October 2016 04:53 AM
Thanks for the nice blog. It was very useful for me. I'm happy I found this blog. Thank you for sharing with us,I too always learn something new from your post.
buy dissertation online
on Tuesday 25 October 2016 03:16 AM
Android scripts is a well-known apparatus to the application engineers who are energetic to create various sorts of android applications. With the assistance of this instrument, numerous application engineers discovered some compelling approaches to growing amazing applications for different purposes.
smith
on Tuesday 25 October 2016 04:38 AM
I hope this information will be great for the readers. Accessing such a post is little difficult for us. Here you are shared all the important points very effectively.
cabling staffing
on Tuesday 25 October 2016 04:50 AM
Thanks for it, i have been seeking for information regarding this material for ages and yours is that the best I even have discovered up to now
family portrait Hong Kong
on Wednesday 26 October 2016 05:32 AM
Superb blog post. Any place strikes numerous pressing obstacles of your modern culture. People can not be uninvolved that will those obstacles.
Best lasagna in Toronto
on Wednesday 26 October 2016 10:08 AM
I think this is an informative post and it is very useful and knowledgeable. therefore, I would like to thank you for the efforts you have made in writing this article.
stylus pen
on Thursday 27 October 2016 10:16 AM
Great blog. Lets stay connected. You can visit my online gift idea store
window and door installer jobs
on Saturday 29 October 2016 10:18 PM
This is a great inspiring article.I am pretty much pleased with your good work.You put really very helpful information. Keep it up. Keep blogging. Looking to reading your next post.
travel course
on Sunday 30 October 2016 12:20 AM
You have talked about an important topic in this article. I think today most of the people are not giving much importance or trust in relationships. I am so glad to read this topic on this blog. Thank you!
Yourbestwriters.com
on Thursday 01 December 2016 12:50 AM
Android scripts are famous tools to the application engineers who are active to make various sorts of android applications. With the help of this tool, numerous application engineers exposed some forceful approaches to rising astonishing applications for various purposes.
essay writing service
on Tuesday 07 February 2017 12:56 AM
Amazing post. I am so impressed. Could never think of such a thing is possible with it...I think you have a great knowledge especially while dealings with such subjects...
assignment help UK
on Monday 27 February 2017 08:53 AM
I want you to thank for your time of this wonderful read!!! I definately enjoy every little bit of it and I have you bookmarked to check out new stuff of your blog a must read blog!!!!
justin
on Sunday 05 March 2017 05:17 AM
This post is really magnificent. I really like this post. It is one of the best posts that I ve read in a long time. Thanks a lot for this really good post. I really appreciate it!Passport Seva
usps tracking
on Saturday 18 March 2017 02:21 PM
this is not
Love Commands
on Monday 20 March 2017 12:56 PM
Just saying thanks will not just be sufficient, for the fantasti c lucidity in your writing. I will instantly grab your rss feed to stay informed of any updates.
essayace review
on Tuesday 09 May 2017 04:39 AM
A complete procedure of sms 2 speech you like to shared in this article. It's not lengthy procedue but yes little bit tough to understand it. Here you fully try to make it easy for everyone who interested to learn about it.
Lakeway Home Builders
on Wednesday 31 May 2017 08:44 AM
Should there be another persuasive post you can share next time, I’ll be surely waiting for it.
Austin Texas Houses
on Wednesday 07 June 2017 11:13 AM
I definitely enjoying every little bit of it. It is a great website and nice share. I want to thank you. Good job! You guys do a great blog, and have some great contents. Keep up the good work.
Masters Dissertation Writing
on Saturday 22 July 2017 10:24 AM
Regardless of the possibility that this application as of now has a pratical usefullness, when androidScript will allow to peruse gadget contacts, a usefull overhaul will be to set a rundown of contact wfrom which rehash sms, yet this is another story
Coursework Help
on Saturday 22 July 2017 10:26 AM
Training has many confronts which are running in our general public. In the event that the understudy who needs to end up noticeably a specialist. So the understudy needs to examine the common sciences subject like science like it, these are additionally the branches of the instructive setup
Rsloolpo
on Sunday 10 December 2017 08:07 PM
Great artcile, yet it would be better if in future you can share more about this subject. Continue posting.
EDD phone number live person
kissanime
on Wednesday 13 December 2017 01:57 AM
This is truly a decent and instructive, containing all data furthermore greatly affects the new innovation.
backupbot
on Thursday 17 May 2018 06:27 AM
We know how to backup WordPress websites or any type of online website for you and the bot does simple website restores for you too. websitebackupbot
muzhiwandownload.com
on Thursday 02 August 2018 10:03 AM
Angry Birds is one of the most popular games. Angry Birds is physics based puzzle game with beautiful graphics. In this game you have to eliminate the evil pigs by slingshots using the birds and retrieve their eggs. You have different types of birds with different abilities to kill the pigs. This is a highly interesting game.
Health And Exercise Tips
on Monday 10 September 2018 05:16 AM
Your job ends with writing and submitting the articles.
AsharSeo
on Wednesday 12 September 2018 03:04 AM
This is the proper weblog for anyone who wishes to be familiar with this topic. You know a whole lot its practically challenging to argue on hand (not that When i would want…HaHa). You definitely put a brand new spin on the topic thats been discussing for several years. Great stuff, just wonderful! Thanksgiving Day Status
Robinjack
on Friday 14 September 2018 09:55 AM
Amazing site, Distinguished criticism that I can handle. Im pushing ahead and may apply to my present place of employment as a pet sitter, which is exceptionally charming, however I have to extra extend. Respects. Adhum Carter
pictaram
on Tuesday 25 September 2018 06:12 AM
So lucky to find this website. Thank you so much! Hope to hear more updates on the instagram technology information. Thanks!
Kratom samples pack
on Saturday 27 October 2018 03:13 AM
Incredible Article it its truly instructive and inventive update us as often as possible with new upgrades. its was truly important. much obliged.
Name  
(required)
Email  
(required - never shown publicly)
Web Site  
Notify me of new comments via email.
Notify me of replies via email.