Reputation: 1658
I'm trying to implement an Android application that has a conversation with the user via a text-to-speech and Android's speech recognition activity.
The following code starts the activity, as documented in the tutorial:
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_PROMPT, "Speech recognition demo");
startActivityForResult(intent, VOICE_RECOGNITION_REQUEST_CODE);
The problem is the activity takes sometime between 0.5 to 1 seconds to start recording the user's voice. This doesn't seem like a lot, but this often means the user has already started talking before the speech recognition activity has begun recording, meaning the application will miss part of what the user says.
Is there a good way to get around this delay so that I can start speech recognition as soon as text to speech is done speaking?
Possibilities I've considered:
If you have any other idea of how this could be properly done or a way to get around any of the above problems that would be awesome.
Upvotes: 3
Views: 2464
Reputation: 1658
Looks like there is a lower level way to control the Speech Recognition activity.
Create an object called SpeechRecognizer, call SpeechRecognizer.setRecognitionListener() and pass it a RecognitionListener. Then pass a RecognizerIntent.ACTION_RECOGNIZE_SPEECH Intent to SpeechRecognizer.startListening() which will start listening and perform speech recognition without waiting for a popup.
From: How can I use speech recognition without the annoying dialog in android phones
Upvotes: 1
Reputation: 12169
One thing you can do is to encourage your users to speak longer commands. That way, if they start speaking too soon, the system can recognize the later part of a command.
For example, instead of having the system recognize "Open email" you could encourage the users to say "System open email" That way if the system only hears the "open email" part it can still recognize the command.
It might add unnecessary words to commands, but I believe it is less awkward than making the user pause. As you describe that delay is problematic.
Upvotes: 1