Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create "ok glass" style menu, within glass app

I have just begun developing for Google Glass, and I knew the GDK if fairly new so this may not be possible yet, but here's what I'm trying to to:

As with the "make a call" prompt or the "send a message to" prompts on the "okay glass" screen, I would like my app to have more voice selected options when you select it with your voice. With the two examples, you will see a list of contacts, which you can nod your head up and down to see more of, and the app will only take further actions one you've selected one of the displayed choices. Is there currently any way to do that on my own app?

Any input is appreciated!

like image 831
tVoss42 Avatar asked Nov 24 '13 19:11

tVoss42


People also ask

How do I activate Google Glass?

To turn Glass on, press the power button for a moment. The white power LED behind the button will turn on and remain lit while Glass starts up. Once Glass boots, the display turns on, and a rising chime will sound.

What is Glass Explorer?

It was developed by X (previously Google X) with the mission of producing an ubiquitous computer. Google Glass displays information to the wearer using a head-up display. Wearers communicate with the Internet via natural language voice commands. Glass. Google Glass Explorer Edition.


2 Answers

You can call an intent to display the Voice Recognizer after your Activity has started. So, you could have your voice trigger and prompt from the launch, and then, in your Activity's onResume(), call the Voice Recognizer, with some kind of prompt (or you could just string the initial speech collected into this as the prompt):

    Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
    intent.putExtra( RecognizerIntent.EXTRA_PROMPT, "ok glass, here's my prompt" );
    startActivityForResult(intent, 0);

You then would need an onActivityResult() method to process the return form the VoiceRecognizer.

This is the described in the GDK docs: https://developers.google.com/glass/develop/gdk/input/voice

Not sure if there is any other way.

like image 82
Darren Avatar answered Sep 20 '22 07:09

Darren


I found this answer from another SO question that seems exactly like you want. I have tried it myself for my own Glassware and it works perfectly. As mentioned in the answer below, one caveat that other apps that use the same "ok glass" voice command will share the submenu; in the following example, for instance, some other app may add other games such as "golf." Another potential problem is that you must have an Activity or Service for each of the options you want in the submenu.

"If you have multiple activities/services installed on Glass that have the same voice trigger intent filter, all of their names (based on the android:label attribute of the <activity> or <service> tag in AndroidManifest.xml) will appear in a disambiguation "submenu" when you speak that voice trigger.

For example (assume that res/xml/play_a_game_trigger.xml represents a voice trigger for the string "play a game"):

<activity android:label="Tennis">
    <intent-filter>
        <action android:name="com.google.android.glass.action.VOICE_TRIGGER" />
    </intent-filter>
    <meta-data android:name="com.google.android.glass.VoiceTrigger"
        android:resource="@xml/play_a_game_trigger" />
</activity>
<activity android:label="Bowling">
    <intent-filter>
        <action android:name="com.google.android.glass.action.VOICE_TRIGGER" />
    </intent-filter>
    <meta-data android:name="com.google.android.glass.VoiceTrigger"
        android:resource="@xml/play_a_game_trigger" />
</activity>

would give you a voice menu flow that looks like

ok glass → play a game → Tennis
                         Bowling

Do note, however, that this menu would also include activities/services from other APKs that use the same voice trigger as well.

You can find more details at the Voice Input page of the GDK documentation."

like image 34
Tony Wickham Avatar answered Sep 24 '22 07:09

Tony Wickham