I am trying to build an application in Android that uses the Google library SpeechRecognizer for retrieving speech to text on device for free. I also want to record the user while he speaks, so I can have in text and in an audio file.
The issue is that when I try to record using the microphone while the SpeechRecognizer is active, the SpeechRecognizer breaks and stops working.
When I am not trying to record using MediaRecorder/AudioRecorder it works like a charm. As soon as I start recording it breaks.
What are the solutions for this problem? Is it possible to make this work?
I am initializing the SpeechRecognizer service like so:
val recognizer = SpeechRecognizer.createOnDeviceSpeechRecognizer(context)
recognizer.setRecognitionListener{
// deal with recognized events (partial and complete)
...
}
recognizer.startListening(
Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH)
.putExtra(EXTRA_LANGUAGE_MODEL, LANGUAGE_MODEL_FREE_FORM)
.putExtra(EXTRA_LANGUAGE, ENGLISH_LOCALE)
.putExtra(EXTRA_PARTIAL_RESULTS, true)
.putExtra(EXTRA_REQUEST_WORD_CONFIDENCE, true)
.putExtra(EXTRA_BIASING_STRINGS, biasString.toTypedArray())
)