We have developed an audio/video calling feature using the OpenTok SDK in our Android app. Now, we need to integrate the SpeechRecognizer API to transcribe voice to text during an ongoing OpenTok call.
The challenge is that the OpenTok SDK has already acquired the microphone (via the RECORD_AUDIO permission) for the call. When we trigger the speech recognizer using:
speechRecognizer.startListening(intent);
We receive a system message indicating that "Speech Recognizer cannot record as [app name] is currently recording." The logs confirm that speech recognition is disabled due to the ongoing audio capture by OpenTok.
Question:
Is it possible to use OpenTok (for audio/video calling) and SpeechRecognizer (for voice transcription) simultaneously in Android? If yes, what are the possible solutions or workarounds to achieve this?
This issue could apply to any scenario where multiple components require exclusive access to the microphone (RECORD_AUDIO permission). Specifically, how can we manage microphone access between OpenTok and the SpeechRecognizer in such a way that both can function simultaneously?
What We've Tried:
Disabling audio publishing in OpenTok (
mPublisher.publishAudio(false)) before starting the SpeechRecognizer.Pausing the SpeechRecognizer after finishing a short transcription and resuming audio in OpenTok.
However, these approaches interrupt the flow of the call or transcription, which isn't ideal for a seamless user experience.
Any guidance or suggestions would be greatly appreciated!