Android Enrollment Module

Sonde Health API Platform Documentation

Android Enrollment Module

🎙️ Module 2: User Voice Enrollment

Overview

This module guides you through implementing user voice enrollment using the Passive SDK. The enrollment process captures a 20-second voice sample and stores it in cache memory, which the SDK uses for subsequent analysis.


📦 Prerequisites

  • Passive SDK is initialized (see Module 1: Initialization).

  • Android app has microphone and other permissions properly declared and granted.

 

📥 Step 1: Import Required Classes

Add the following imports in your Activity or Fragment:

import sonde_passive.client.SondeSdk import sonde_passive.client.VoiceAnalysisEngine import com.sondeservices.passive.enrollment.EnrollmentCallback

 

🔐 Step 2: Handle Microphone Permission

Declare a constant for permission request code:

private val REQUEST_CODE_RECORD_AUDIO = 11111

 

Check and request the RECORD_AUDIO permission:

if (ContextCompat.checkSelfPermission( requireContext(), android.Manifest.permission.RECORD_AUDIO ) != PackageManager.PERMISSION_GRANTED ) { val permissions = arrayOf(android.Manifest.permission.RECORD_AUDIO) ActivityCompat.requestPermissions( requireActivity(), permissions, REQUEST_CODE_RECORD_AUDIO ) }

Override onRequestPermissionsResult to ensure permission is granted:

override fun onRequestPermissionsResult( requestCode: Int, permissions: Array<String>, grantResults: IntArray ) { super.onRequestPermissionsResult(requestCode, permissions, grantResults) if (requestCode == REQUEST_CODE_RECORD_AUDIO && grantResults.isNotEmpty() && grantResults[0] != PackageManager.PERMISSION_GRANTED) { throw RuntimeException("Record Audio permission is required to start enrollment.") } }

 

🧩 Step 3: Initialize the SDK Engine

Declare the VoiceAnalysisEngine variable in your Activity or Fragment:

private lateinit var voiceAnalysisEngine: VoiceAnalysisEngine

Then, initialize it in onCreate() (Activity) or onViewCreated() (Fragment):

voiceAnalysisEngine = SondeSdk.voiceAnalysisEngine

 

🎤 Step 4: Start Voice Enrollment

Use the following snippet to begin enrollment:

voiceAnalysisEngine.startEnrollment( requireContext(), object : EnrollmentCallback { override fun onEnrollmentSuccess() { Log.d(TAG, "onEnrollmentSuccess ==>") Snackbar.make(requireView(), "Enrollment Successful", Snackbar.LENGTH_LONG).show() } override fun finishEnrollment() { // Called when enrollment is fully complete } override fun onSecondCaptured(seconds: Int) { // Called each second (up to 20 seconds) of active voice captured Log.d(TAG, "onSecondCaptured ==> $seconds") } override fun onMessage(message: String) { // Inform user about warnings (e.g., background noise) Snackbar.make(requireView(), message, Snackbar.LENGTH_LONG).show() } override fun onError(throwable: Throwable) { // Handle error scenarios Log.e(TAG, "Enrollment error", throwable) } } )

 

📣 Real-Time Feedback Messages

During enrollment, the SDK may send feedback messages, such as:

  • High Background Noise

    “High background noise detected; please move to a quieter location.”

    This occurs if background noise is detected within the first 20 seconds of audio input.


✅ Final Notes

  • Ensure the user is in a quiet environment during enrollment.

  • Do not interrupt the process once started.

  • Enrollment only needs to be done once per user.

✅ Next Steps

Continue with:

Module 3: User Voice Verification

Sonde Health