Activity starter: launch android built-in speech recognizer

440 views
Skip to first unread message

bianca fenice

unread,
Dec 21, 2017, 9:46:51 PM12/21/17
to MIT App Inventor Forum
I know that app inventor has its own speech recogniser but I'm curious to know if is it possible to start the android built-in speech recogniser with the activity starter of an app inventor app if already installed into the android device?
If yes, how?

Thanks in advance.

TimAI2

unread,
Dec 22, 2017, 3:31:42 AM12/22/17
to MIT App Inventor Forum
It is the same one....

But if you want to use activity starter to launch it you will have to use adb/logcat to find the parameters to launch it.

bianca fenice

unread,
Dec 22, 2017, 2:24:46 PM12/22/17
to mitappinv...@googlegroups.com
TimAI2 thanks for response.
Sorry I don't understand: the app inventor has a huge "over-layer" and a mic icon that overlap everything under them on the screen. The android's has just an icon into the keyboard that let the user to keep an eye on what is writing.
Also it doesn't allow the user to see the results in "real time" while dictating.
Also the timing is pretty different: android's if you stop talking stands a while waiting for further input before automatically stop listening: this gives you more time to think about what to say after. While app inventor's stops in few secs.
And also with the android's it is possible to insert text everywhere while with the app inventor's it is possible just to add at the end the new text (at least as far as I know). 
So they seem to me they behave pretty differently. Perhaps "underground" is the same engine that does the math but the "user interface" that gives the use experience is pretty different

SteveJG

unread,
Dec 22, 2017, 5:48:00 PM12/22/17
to mitappinv...@googlegroups.com
Perhaps this haystack of Forum discussions will help:  https://groups.google.com/forum/#!searchin/mitappinventortest/speech$20recognizer%7Csort:date  Tim is correct, there is one SpeechRecognizer ... Google has two versions..one requires an Internet connection, the other works in conjunction with a downloaded SR engine on your device.  I don't believe App Invetor can choose which to use.  The online version has limitations, placed by Google on the length of dictation and how the tool can be used.

The SpeechRecognize component is the AI tool available to developers.  Other 'methods' are discussed of 'controlling the SR are discussed in the haystack.  Sorry, one cannot get the 'same' performance that developers using perhaps the professional Android Studio can provide.    Look at some of the 'work' around things that can improve SR performance.  Unfortunately, you will not get the performance of software that allows seamless speech recognition, transcription to text.  Here is how to get 'relief' using Android Studio  https://www.google.com/search?q=android+speech+recognizer&oq=android+speech+recognizer&aqs=chrome..69i57.6207j0j7&sourceid=chrome&ie=UTF-8  

You might try 

App Inventor Extensions: Speech Recognizer | Pura Vida Apps 


Show some code blocks and perhaps someone can offer specific advice.  Or perhaps you will find something in the haystacks ...let us know.

Regards,

Steve

bianca fenice

unread,
Dec 26, 2017, 3:08:42 PM12/26/17
to mitappinv...@googlegroups.com
Sorry but after reading your precious answers I googled a bit more for further information quest using some informations got from the above answers and I found that I need to reformulate the question as follows, hoping the new formulation will be more aimed to my purposes:
Is that possible to start with "AI activity starter" the gboard speech recognition UI?

In other words I mean the speech recognition UI that is attainable touching the mic icon on the google keyboard i(f installed on the device).

---------------------------------------
The following "self answer" is related with the first formulation of my original question:
The following block allows the user to start the speech recognition engine with the activity starter, without having any speech recognizer component. Nevertheless, though, it still is a work in progress because I'm still trying to understand if and how it is possible to get back the recognized text from it:

SteveJG

unread,
Dec 26, 2017, 5:20:01 PM12/26/17
to MIT App Inventor Forum
The ActivityStarter can launch the SpeechRecognizer.  When a developer launches an app (like SpeechRecognizer), the developer loses total control.  The ActivityStarter can be used for elaborate activities when coded using Java based compilers using INTENTS and it API.  The best AI can do is launch the Recognizer using intents (ActivityStarter).  Once launched, the developer no longer has the ability to control that launched instance of the SR.      Try this link for Java programmers:        

RecognizerIntent | Android Developers

 
Control like this requires the supplemental intent commands...like EXTRAS ... Yes, App Inventor can work with EXTRAS  (ExtraValue..ExtraKey e.g.)  http://appinventor.mit.edu/explore/ai2/activity-starter.html

You want to add a delay so that in the absence of sound, the SpeechRecognizer does not turn of for pauses of perhaps 5 seconds  or in Dictation mode.   App Inventor's SpeechRecgognizer object cannot control these functions;  Android Studio and other professional compilers can .

Here is how to completely control the SpeechRecognizer to do anything it is capable of doing https://developer.android.com/reference/android/speech/SpeechRecognizer.html using the API    and here, using INTENTS  https://developer.android.com/reference/android/speech/RecognizerIntent.html  

It is NOT possible to get back the recognized text from an ActivityStarter launched Speech Recognizer  using the ActivityStarter  AND App Inventor. This SR instance cannot communicate with the main AI app labels and textboxes.

You have limited ability using Android Studio.

Regards,
Steve


bianca fenice

unread,
Dec 26, 2017, 9:07:40 PM12/26/17
to mitappinv...@googlegroups.com
In other words, if I did understand correctly the point, I can't start specifically the gboard speech recognition UI within a text field by using app inventor activity starter but I have to start gboard and its speech recogniser by hands or I have to use normally the app inventor speech recognition component.

Am I right?

Look at the picture bellow to see what I mean...
Immagine correlata

SteveJG

unread,
Dec 27, 2017, 11:14:42 AM12/27/17
to MIT App Inventor Forum
You must use the App Inventor  SpeechRecognizer component  if you want to use the Speech Recognizer in an App Inventor app  .

Google's Speech Recognition Engine is not designed for continuation 'listening'.    The Speech Recognizer component can only do the following:

SpeechRecognizer

Picture of Speech Recognizer component

Use a speech recognizer component to listen to the user speaking and convert the spoken sound into text using Android's speech recognition feature.

Properties

Result
The last text produced by the recognizer.

Methods

GetText()
Asks the user to speak, and converts the speech to text. Signals the AfterGettingText event when the result is available.

Events

AfterGetting(Text result)
Signaled after the recognizer has produced text. The argument is the text result that was produced.
BeforeGettingText()
Signaled just before the recognizer is called.

A simple Speech Recognizer basic app is:


SteveJG

unread,
Dec 27, 2017, 12:03:26 PM12/27/17
to MIT App Inventor Forum
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.


Merry Christmas and Happy New Year.

--Steve
SpeechRecognizerContinuous.aia

cristian alcantara

unread,
Dec 27, 2017, 2:13:42 PM12/27/17
to MIT App Inventor Forum
grasiaa

bianca fenice

unread,
Dec 28, 2017, 10:58:34 PM12/28/17
to mitappinv...@googlegroups.com
@SteveJG
Thanks Steve for your suggestions: I'm already using that approach (with timer) in my experiments and in the meantime I'm trying to get more because unfortunately that approach doesn't grant a satisfactory continuous speeching feature as I would like to.
In fact I'm trying to use a similar approach to make it work with the gboard or the android built-on board (AOSP) that have the mic on them.
I'm right now tuning it but it appears to be more complex I thought. But some results are going on...

Thank you for a... and Merry Christmas and Happy New Year to all.
Reply all
Reply to author
Forward
0 new messages