Android
This part of guide describes best practices and common development pitfalls when implementing IDVoiceSDK-based products for Android.
Recording setup¶
When one needs to record raw incoming sound in Android ecosystem it will inevitably lead to AudioRecord class or its derivatives. There are quite many parameters that can be fed into this class in order to initialize recording session, their significance from IDVoice SDK perspective and recommended values are described below:
-
READ_BLOCKING
/READ_NON_BLOCKING
- parameter which manages whetherread
call will block or only fill buffer with what's available in audio device at the moment. Please pickREAD_BLOCKING
here as some devices don't supportREAD_NON_BLOCKING
or fail to produce valid buffers. -
AudioFormat
- format in which recording is done. Please pickENCODING_PCM_16BIT
as it is best supported option for both Android and IDVoice SDK. Channel selection should beCHANNEL_IN_MONO
as Android microphones are always centered and single. If you have custom microphone and pickCHANNEL_IN_STEREO
be advised that sampling output in resulting buffer will be interleaved, which IDVoice SDK doesn't support. -
MediaRecorder.AudioSource
- audio source which produces sound samples. Android can perform quite many preprocessing steps such as denoising, gain increase or echo removal. Unfortunately these steps interfere with IDVoice SDK's own internal features such as voice liveness. Don't pickDEFAULT
here, useUNPROCESSED
, or, if unavailable, useVOICE_RECOGNITION
.
Quiet audio records¶
Some devices have a quiet audio recording when they use the UNPROCESSED
mode. It's OK because when device uses the UNPROCESSED
mode it may disable an audio amplification to prevent an audio signal changing.
Useful resources¶
As a first step in implementing your own Android application with IDVoice SDK you can take a look at the basic Android recorder example that we have available for sharing (MIT license).