RecogniseListener works fine when there's continuous talk, but whenever there are 5-10seconds of silence, the listener's onReadyForSpeech() method is called, but onBegginingOfSpeech() is never called.
Here's my listener:
sr = SpeechRecognizer.createSpeechRecognizer(this);
sr.setRecognitionListener(new RecognitionListener() {
@Override
public void onReadyForSpeech(Bundle params) {
}
@Override
public void onBeginningOfSpeech() {
}
@Override
public void onRmsChanged(float rmsdB) {
}
@Override
public void onBufferReceived(byte[] buffer) {
}
@Override
public void onEndOfSpeech() {
startRecognising();
}
@Override
public void onError(int error) {
}
@Override
public void onResults(Bundle results) {
adapter.add(new MessageData(MessageData.TYPE_VOICE, recognisedText.getText().toString()), 0);
recyclerView.scrollToPosition(0);
recognisedText.setText("");
}
@Override
public void onPartialResults(Bundle partialResults) {
ArrayList data = partialResults.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);
String word = (String) data.get(data.size() - 1);
recognisedText.setText(word);
}
@Override
public void onEvent(int eventType, Bundle params) {
}
});
The startRecognising() method:
private void startRecognising(){
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_SPEECH_INPUT_MINIMUM_LENGTH_MILLIS, 20000000);
intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE,"voice.recognition.test");
intent.putExtra(RecognizerIntent.EXTRA_PARTIAL_RESULTS, true);
intent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS,1);
sr.startListening(intent);
}
By the way, are there any free alternatives that can recognise speech in real-time continuously?