Sonde Health API Platform Documentation
Mental Fitness - iOS EDGE Use Case
Overview
The following use case is a guide for your app development. The below use case describes recording the audio sample and generating the score for Mental Fitness.
Notes:
Please check Sonde EDGE SDK setup at IOS EDGE SDK
As a developer, I want to measure voice characteristics of user’s mental-fitness health condition
Perform the below steps on the app side to generate the score:
STEP 1: Display the prompt and duration to the user
STEP 2: Record 30 seconds audio file
STEP 3: Generate the inference score for Mental Fitness
STEP 4: Display the score to the user.
STEP 1: Display the prompt and duration to the user
We recommend displaying the prompt along with the duration of the recording to the user before starting the actual recording. This will help the user to get ready to speak on the recording screen. Every health condition has its own prompt(s) and timer length of recording.
You can get the required prompt to be shown to the user on the instruction screen and timer length by referring Vocal Biomarkers - Health Checks
Refer to the screenshot below for your reference.
:
STEP 2: Record 30 seconds audio file
Before starting the audio recording, add the following check to make sure that the recording permission is enabled in the app. To access the
AVAudioSession
import AVFoundation in your respective file. If the audio permission is granted by the user, then audio recording can be initiated.import AVFoundation
func askForAudioPermission(){ let permission = AVAudioSession.sharedInstance().recordPermission switch permission { case AVAudioSession.RecordPermission.denied: print("Permission denied") default: AVAudioSession.sharedInstance().requestRecordPermission({ [weak self] (granted: Bool) -> Void in guard let self = self else { return } DispatchQueue.main.async { if granted { print("permissionGranted") } else{ print("Permission denied") } } }) } }
Create an instance of
AudioRecorder
class and callstartRecording()
function to start recording.
To access theAudioRecorder
class import Sonde_SDK in your project.import Sonde_SDK
To initialize the AudioRecorder
class, parameters: lengthInSec
,errorHandler
, and recordingFinishedHandler
are required.
lengthInSec
: the length of the audio recording in seconds, e.g. 30 secondserrorHandler
: callback when there is an error during recording
recordingFinishedHandler
: callback when done with recording for a given duration, and provides the file path of the recorded files.
STEP 3: Generate the inference score for Mental Fitness
After recording the audio file, scoring for Mental Fitness can be initiated. To generate the score, follow the below steps:
Create the
MetaData
instance; for that, you will be requiring the gender and year of birth of the user. You can pass the gender value as .male or .female, yearOfBirth and partnerId as String type. The partnerId should be a unique UDID that the Partner has assigned to the end user and should not be user's email, cell, or other identifying data).Create the instance of
InferenceEngine
class that accepts the metadata instance from the above step and callinferScore()
function withaudioFilePath
,healthCheckType
,scoreHandler
, anderrorHandler
as parameters.audioFilePath
: generated audio file from step 2healthCheckType
: health condition for which you want to generate the score, in this case, it will be MENTAL_FITNESSscoreHandler
: callback when the score is generatederrorHandler
: callback if there is an errorTypecast the score to
VFFinalScore
to get the other voice features scores.
Voice Sufficiency Check
We have introduce voice sufficiency checks in our SDK, enhancing the audio quality for Mental Fitness Score assessments, ensuring only audio files containing speech and meeting the SNR threshold are getting scored.
Developers needs to integrate error responses ( Low Speech; High Noise; Low Speech and High Noise) mentioned in section errorHandler
: callback if there is an error
STEP 4: Display the score to the user
The value of the generated score in step 3 varies between 0-100. Based on your application, once you get the score, you can display it to the user along with the interpretation message on the score screen. For some applications, scores may be uploaded and not shown to the users. However, the scores can be uploaded for an individual user or in bulk for further analysis through API function calls.
Refer Vocal Biomarkers - Health Checks for the interpretation message.
Below is the screenshot for your reference.
Related content
Sonde Health