I'm trying to develop a cool application that uses the TTS
engine and speech recognition. So far it's ok but I want more. I would like to create a service (I think a service is the right way), that is always "listening" and when someone says "ok google"
or something else , the speech recognition starts, like google now. For example, if you say "ok google"
google now starts. I don't know where to start so I'm asking directly here if it's possible. I tried looking at this thread [here] (Listening for keywords at all times, like "Ok google" on 4.4) and the last answer talked about a service, as I thought. Can someone help me with my code?
For example this is the code to start speech recognition by tapping a button:
/**
* Instruct the app to listen for user speech input
*/
private void listenToSpeech() {
//start the speech recognition intent passing required data
Intent listenIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
//indicate package
listenIntent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, getClass().getPackage().getName());
//message to display while listening
listenIntent.putExtra(RecognizerIntent.EXTRA_PROMPT, "Say a word!");
//set speech model
listenIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
//specify number of results to retrieve
listenIntent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 10);
//start listening
startActivityForResult(listenIntent, VR_REQUEST);
}
Do you think it's possible to start that listenIntent
only with voice and without pressing any button? This is what i mean.
When using voice recognition to control actions on your computer or type for you, it's a type of input known as voice input.
You can activate this by going to Settings - Language and Input - Voice Input and touch the cog icon next to Enhanced Google Services. Choose "Offline Speech Recognition" and select the "All" tab to download your preferred language if it's not already installed.
Voice Recognition. Type with your voice. Dictation turns your Google Chrome into a speech recognition app. You can use Google Chrome as a voice recognition app and type long documents, emails and school essays without touching the keyboard.
A Speech-to-Text API synchronous recognition request is the simplest method for performing recognition on speech audio data. Speech-to-Text can process up to 1 minute of speech audio data sent in a synchronous request. After Speech-to-Text processes and recognizes all of the audio, it returns a response.
(Updated 06.01.2018: added some bits to previous answer)
you can have reference with Saiy, previously Utter
this app uses hot word detection as "Google Now".
and there is no such API provided by Android to perform such operation.
Saiy app is now opensource with repository here. From what little I saw in the code, it seems to have implemented the functionality using CMU Pocketshinx.
Don't forget to post your findings.
Note- its very CPU-intensive and battery consuming to listen all the time in background.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With