iOS Enrollment Module

Sonde Health API Platform Documentation

iOS Enrollment Module

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 local cache, which the SDK uses for subsequent analysis.


📦 Prerequisites

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

  • iOS app has microphone permissions properly declared and granted.

 

📥 Step 1: Import Required Classes

Add the following imports in your ViewController:

import AVFAudio import SondePassiveSDK

🔐 Step 2: Handle Microphone Permission

  • Get microphone usage permission from iOS. To request microphone permission in iOS, you can follow these steps:

    • Open your Xcode project, and locate the Info.plist file, and add the following key-value pair:Key: "Privacy - Microphone Usage Description"

  • Request Microphone Permission:
    In your code, you can use the AVAudioSession class to request microphone permission. Here's an example in Swift:

Refer ViewController from shared code base for below code

import AVFAudio @objc func requestMicrophonePermission() { switch AVAudioSession.sharedInstance().recordPermission { case .undetermined: AVAudioSession.sharedInstance().requestRecordPermission { [self] granted in if granted { } else { //show permission denied alert } } case .denied: //show permission denied alert case .granted: break @unknown default: break } }
  • Handle User Response:

    • Inside the completion block, you can handle the user's response to the microphone permission request. If permission is granted, you can proceed with using the microphone in your app. If permission is denied, you can handle it accordingly, such as by showing an alert.

🧩 Step 3: Initialise the SDK Engine

Refer EnrollmentController from shared code base for below references

Declare the enrolment variable in your ViewController:

var enrolment: EnrolmentHandler?

Then, initialise it

do { enrolment = try SondeFactory.shared.enrolmentHandler() } catch { }

 

🎤 Step 4: Start Voice Enrollment

Use the following snippet to begin enrollment:

do { enrolment?.delegate = self enrolment?.startEnrollment() } catch { }

🎤 Step 5: Add Required Delegate Methods

Implement delegate methods from EnrolementDelegateProtocol:

func lowSNRDetected() { //triggered when there is a background noise } func didReceiveEnrolmentSpeechLength(length: Double) { //triggered each second (up to 20 seconds) of active voice captured //length - it is duration of active voice captured in seconds } func didReceiveEnrolmentLength(length: Double) { //triggered each second while enrollment is progressing //length - it is duration in seconds } func didReceiveErrorInEnrolment(error: any Error) { // Handle error scenarios } func didFinishEnrolment() { // triggered when enrollment is successfully completed } func didReceiveLongSilence() { //triggered when there is no voice for long duration } func didRecieveInterruptionInEnrolmentForAudioResource() { //triggered when enrollment in interupted }

 

📣 Real-Time Feedback Messages

During enrollment, the SDK may trigger delegate methods like:

  • lowSNRDetected

    • In case of 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.

  • didReceiveLongSilence

    • In case of no voice is captured for longer duration


✅ 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 Module:

Sonde Health