Communicate with Google Assistant offline,Or make a look like app

586 views
Skip to first unread message

Steve Moretz

unread,
Jan 26, 2018, 2:12:31 PM1/26/18
to MIT App Inventor Forum
Hello as far as I know get communications with Google assistant is not that practical specially offline but if any has anything about it please inform me.The second part is how to make a system like Google assistant the point is using the,say dialog from MIT app inventor we need to wait till the user says and completes the sentence and then we can get the value but in Google now and Google Assistant,you see the text on the screen constantly while you're speaking not after its done it's writing that at the exact same time that's what I want to do how can I do that please help Tnx.

SteveJG

unread,
Jan 26, 2018, 3:02:53 PM1/26/18
to MIT App Inventor Forum
You cannot do everything with the Speech Recognizer professional developers do with Android Studio.   App Inventor can do something similar:


Use the SpeechRecognizer along with a Clock to simulate continuous dictation. It does not show everything instantaneously but is 'continuous dictation'   Perhaps the code in the link can be adapted to what you intend to do?

Does this help?

Regards,
Steve

Steve Moretz

unread,
Jan 27, 2018, 6:38:11 AM1/27/18
to MIT App Inventor Forum
Hello Steve,the link you have given me doesn't work out directs me to:
https://groups.google.com/forum/m/#!overview
What did you mean by using the clock?Getting data continuously from the user you mean?but how can I hide the dialog and mean while get the text of the voice?You are talking about stoping,taking,continue,stop,take?There's a noticeable delay is between of this actions if you mean that.I don't think so you mean that so please explain more and in details.tnx.

Steve Moretz

unread,
Jan 27, 2018, 7:40:31 AM1/27/18
to MIT App Inventor Forum
I'm going to learn Android studio BTW do you have any links representing Google assistant style for Android studio?I would love to see a code a description a tutorial anything would be great Tnx.

SteveJG

unread,
Jan 27, 2018, 8:25:18 AM1/27/18
to MIT App Inventor Forum
Try the link (   https://groups.google.com/forum/#!searchin/mitappinventortest/dictation%7Csort:date/mitappinventortest/YSFDMbgcLHg/rLau2cJYBgAJ  ) again Steve.  It works here and points to a Forum discussion. 

What do I mean...?   Well, if the link completed, you would have an aia.  Try it again.

Google assistant ? ... here is the sdk    If anything exists w.r.t a tutorial  just Google  'Google assistant  Android Studio'  or   'Google assistant Java'   I imagine.
Good luck. 

--Steve


Steve Moretz

unread,
Jan 27, 2018, 9:18:38 AM1/27/18
to MIT App Inventor Forum
I tried your link again if just directs me to the page I mentioned before.i can't get to the page you mean!

SteveJG

unread,
Jan 27, 2018, 9:48:47 AM1/27/18
to mitappinv...@googlegroups.com
I don't understand why the link fails on your PC.  

Here is a work around for continuous dictation with App Inventor and the SpeechRecognizer component.  




The very basic app has no error control.  It uses a Clock with TimerInterval settings made using a ListPicker selectable from one to five seconds (programmed as 1000  to 5000 ms).  The default delay time is 2000ms.



This example simulates continuous dictation using the SpeechRecognizer component.  If the speaker pauses for more than 2 seconds (or another interval the user selects, the Speech Recognition icon re appears (see the image)  Start talking again to continue the dictation.  If you want a period (   .   )  in English, just say clearly   period.   If you want an exclamation point (    !    )  say  exclamation point.  

To start dictation, press  START.  To stop, STOP.  To change delay use the Speech Recognizer Delay listpicker and select ms from the menu.  To clear text, press Clear Text.    To save the text, you must write your own code.

The app can be made to respond to certain words you program if you use conditional statements and the contains text block but you have to code that. Something like this might work 





Can you read this version?

--Steve

SpeechRecognizerContinuous (1).aia

Steve Moretz

unread,
Jan 27, 2018, 10:59:43 AM1/27/18
to MIT App Inventor Forum
Thank you.I just got a few questions,whenever I call get text from speech I can get it?Even when the speaker is still speaking or it waits till the speak finishes that way I'll be able to use clock component with interval if 50 mil or something about that to check whether a new thing is been said if yes get it to.afterpicking if no wait 50 more milliseconds.Another question is can I disable or hide the "say" dialog?my own UI is going to figure that part out.

SteveJG

unread,
Jan 27, 2018, 11:43:50 AM1/27/18
to MIT App Inventor Forum
Lots of questions Steve, no specific answers.   The SpeechRecognizer is a fussy tool so one has to experiment with the Clock interval to get the code to elicit the behavior you require.

Oh, "whenever I call get text from speech I can get it" ... well yes, realizing their probably will be 'collisions' and forcing get text might result in a non response.  If you want to do that, you might have to set Clock.enabled to false then later reinstate it's monitoring to true.  Simply, you can override the Clock code as the example is shown but with unpredictable result unless you provide additional code.  The example has no code to handle errors that might occur, the developer has to add that.


50 ms is 1/8th the time it takes for an eye blink.  The SpeechRecognizer you will be using is in the Cloud, so consider that the tool takes a while to process.  Go ahead and try 50ms.  I believe that short a time interval is impractical for a number of reasons.  Experiment.

" can I disable or hide the "say"  dialog?my own UI is going to figure that part out."   This will be your app, the code "you said cat" is a place holder.  You can call a Procedure there 
or use your own Blocks.   See a similar thread  https://groups.google.com/forum/#!category-topic/mitappinventortest/8_bSPerEIWw   where I posted an ugly diagram of what one can do.instead of that use of conditional statements.  Also you might want to read 
The article has a lot of great ideas.

You should also be aware there are limits about how many conditional statements one can place in an event handler. AfterGettingText is an event handler.  The issue is App Inventor apps process data asynchronously.  Refreshing too often or processing too much information will interfere with what you timing you use on the Clock at some point.


You seem in doubt about how one can modify existing code to suit your purposes.  Have you used the following resources to help you learn to use the AI2 tools?  A very good way to learn App Inventor is to read the free Inventor's Manual here in the AI2 free online eBook   http://www.appinventor.org/book2 ... the links are at the bottom of the Web page.  The book 'teaches' users how to program with AI2 blocks.  

There is a free programming course here http://www.appinventor.org/content/CourseInABox/Intro  and the aia files for the projects in the book are here:  http://www.appinventor.org/bookFiles  

How to do a lot of basic things with App Inventor are described here:  http://www.appinventor.org/content/howDoYou/eventHandling  .

Steve Moretz

unread,
Jan 27, 2018, 3:28:38 PM1/27/18
to MIT App Inventor Forum
Nice details Steve,Love the way you explain things.Yeah I've been reading a book about 300 pages about MIT app inventor.Tnx for all you said from this point it's just experiencing to get the results I'm looking for You really helped me out.Though your main advise thought me here to go and learn Android studio because mit app inventor and lots of other similars are limited in some professional cases.So I'm going to learn that thank you if you didn't tell me that I might never go and learn it Steve.
Reply all
Reply to author
Forward
0 new messages