0

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!

1 Answer 1

0

Capture the mic audio yourself and pass the audio stream into both the SpeechRecognizer and the OpenTok session.

For SpeechRecognizer, use EXTRA_AUDIO_SOURCE.

For OpenTok, use AudioDeviceManager#setAudioDevice.

Sign up to request clarification or add additional context in comments.

1 Comment

I have used AudioRecord to generate the audio stream and pass it to opentok but how can speech recognizer native accept the audio stream?. Do you have any snippet for the same.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.