Voice recognition - with templates (android wear) - android

I am trying to develop an application for Android wear that on a button click will ask the user to speak something and send it to a webserver. I also need to have a list of pre-defined templates, similar to what Hangouts works.
What I have tried:
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_PROMPT, "Send to server");
startActivityForResult(intent, SPEECH_REQUEST_CODE);
This works, but I cannot supply the user a set of pre-defined templates.
Reading this - https://developer.android.com/training/wearables/notifications/voice-input.html I see that it is possible to do this in a notification... but this will not be in the front, I need this UI to be modal/blocking, so a notification is not good for my use case.
What are my options? How can I implement this?

Unfortunately, other than Receiving Voice Input in a Notification there is no way to use voice recognition with pre-defined text responses.
Based on the documentation : Adding Voice Capabilities
Voice actions are an important part of the wearable experience. They let users carry out actions hands-free and quickly. Wear provides two types of voice actions:
System-provided
These voice actions are task-based and are built into the Wear platform. You filter for them in the activity that you want to start when the voice action is spoken. Examples include "Take a note" or "Set an alarm".
App-provided
These voice actions are app-based, and you declare them just like a launcher icon. Users say "Start " to use these voice actions and an activity that you specify starts.
Also as discussed in 24543484 and 22630600, both implemented a notification in their android to get the voice input.
Hope this helps.

Related

what is the purpose of EXTRA_CALLING_PACKAGE in android studio

im now writing STT in android studio and i have a question for some code lines.
intent=new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE,getPackageName());
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE,"en-US");
The first line is set intent fot getting input of user's speech and the last one is for setting language that we going to use. but what about a second line?
Even though i read public documentation, cannot understand.
'The extra key used in an intent to the speech recognizer for voice search'
i understand that like this: after getting input of speech from the first line, use the input in the intent - and what kind of intent? - to the speech recognizer for voice search.
but still not sure..
can you give me an explanation?4
Thank you in advance
it's a flag that is used by voice search API to identify the called to this API (your application) so the voice search implements the callbacks and ... based on your package name...

Intent to simulate google now voice command with query

I am trying to use the googlequicksearchbox to do some actions directly, without the click button confirmation...
for example:
When I click at the mic of Google Now and say "Me acorde às 9:00" (Wake-up me at 9)... Google now makes an alarm for 9 without needing confirmation. Like this:
But if I use this intent:
String query = "Me acorde às 9:00";
final Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);
intent.setPackage("com.google.android.googlequicksearchbox");
intent.putExtra(SearchManager.QUERY, query);
startActivity(intent);
to start googlequicksearchbox with the same text that was recognized, Google Now makes the alarm, but now requires confirmation click at the blue button (reminders, etc, also requires). Like that Screenshot >> Screenshot alarm require confirmation
Someone knows some way of make the intent start google search with a query and not requires the click confirmation? like "simulate a google now voice command"??
P.S1.: I am using my own voice recognition inside of my app for other purposes, and I am trying to make the Google Now interpret the voice for just some commands... So, unfortunately, I can't execute the google now voice recog...
P.S2.: I don't know how to interpret the voice (get the hour, minutes, etc.) and make the alarm by the direct intent... then, use the google now to interpret is the best option for me.

Start Google Now on Music Recognition

Is there a way to automatically start Google Now on Music Recognition? I'd need it to create a DashClock extension that start Music Recognizing...
As far as I speak, I can start package com.google.android.googlequicksearchbox successfully but I cannot start voice input... I would not use startActivity for result since I would not need a result, I would really just start Google Now voice recognition feature, is there a way to do it programmatically?
Otherwise, to simply launch Google Now Song Recognition service (without having to tap on "Listen to Music", to be clear), you can create an Intent with the string
"com.google.android.googlequicksearchbox.MUSIC_SEARCH";
that would launch directly the proper interface.
I just found a way to achieve my goal:
Intent intent = new Intent();
intent.setClassName("com.google.android.googlequicksearchbox","com.google.android.googlequicksearchbox.VoiceSearchActivity");
starting this intent will bring up voice search window.

Sony SmartWatch - invoke app on Smart Watch when it gets an event

I'd like to write an app that monitors incoming SMS and notify me on the watch if the content of SMS contains a predefined text (e.g. "go home").
I know I can use the notification API to add an event. It will vibrate and show a small app icon on the watch. What if I want to use control API to flash LED and show the whole text and an image on the watch when it receives the SMS, how should I do?
It's very similar to the "Call handling" add-on. Can Sony open the source of "Call handling" for reference?
I think you have two options. Either, as you say, 1) implement an extension that uses both the notification API and the control API. Or 2) just implement a control extension.
For 1), you could add a custom action that starts your control extension using the START_REQUEST intent below. See the doAction1 method in the SampleNotificationExtension code. This would mean that a standard notification will be shown on the watch, then you will be able to present a custom view to the user, if the user clicks the custom action button.
And for 2), implement your functionality completely as a control extension and request for it to be started when you get the SMSs that is found by your filter. Drawback is that you need to present the SMS text yourself, which in case 1) is done by the framework for you.
START_REQUEST-intent example:
Intent intent = new Intent(Control.Intents.CONTROL_START_REQUEST_INTENT);
intent.putExtra(Control.Intents.EXTRA_AEA_PACKAGE_NAME, "your.package.name");
intent.setPackage(hostAppPackageName);
sendBroadcast(intent, Registration.HOSTAPP_PERMISSION);

Voice Recognition Commands Android

So I've searched far and wide for some sort of solution to the issue regarding removing Google's Voice Recognition UI dialog when a user wants to perform a Voice Command but have been unable to find any solution. I am trying to implement an app which displays a menu to the user and the user can either click on the options or say the options out loud which will open the new pages. So far ive been unable to implement this unless I use Googles RecognizerIntent but I dont want the dialog box to pop up. Anyone have any ideas? Or has anyone solved this issue or found a workaround? Thanks
EDIT: As a compromise maybe there is a way to move the dialog to the bottom of the screen while still being able to view my menu?
Does How can I use speech recognition without the annoying dialog in android phones help?
I'm pretty sure the Nuance/Dragon charges for production or commercial applications that use their services. If this is just a demo, you may be fine with the developer account. Android speech services are free for all Android applications.
You know that you can do this with google's APIs.
You've probably been looking at the documentation for the speech recognition intent. Look instead at the RecognitionListener interface to the speech recognition APIs.
Here's some code to help you
public class SpeechRecognizerExample extends Activity implements RecognitionListener{
//This would go down in your onCreate
SpeechRecognizer recognizer = SpeechRecognizer.createSpeechRecognizer(this);
recognizer.setRecognitionListener(this);
//Then you'd need to start it when the user clicks or selects a text field or something
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
//intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "zh");
intent.putExtra("calling_package",
"yourcallingpackage");
recognizer.startListening(intent);
//Then you'd need to implement the RecognitionListener functions - basically works just like a click listener
Here's the docs for a RecognitionListener:
http://developer.android.com/reference/android/speech/RecognitionListener.html

Categories

Resources