Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The verification module is responsible for verifying the user’s audio against the voice used for enrollment, which was explained described in Sonde Edge Passive SDK Architecture. Additionally, before starting with the steps mentioned here, please go through review Android Sonde Edge Passive SDK Integration.

The following steps guide your app development and will . They provide detailed information for verifying the verification of the user’s voice and , describe collecting the audio sample, and generating generate the score for Mental Fitness.

...

  • Import the following classes in your Activity/Fragment

Code Block
languagekotlin
import com.sondeservices.common_passive.RecordingDataType
import com.sondeservices.passive.continuous.modelsanalysis.ScoreVoiceAnalysisCallback
import com.sondeservices.passive.continuous.verificationanalysis.IVerificationVoiceSegmentData
import com.sondeservices.passive.verificationmodels.RecordingDataScore
import com.sondeservices.sonde_passive.verification.VerificationCallback
import com.sondeservices.passive.verification.VerificationHandlerapplication_api.init.SondePassiveSdk
  • Before starting the verification, add the next check to make sure that the RECORD_AUDIO permission is enabled in your app App :

  • Declare the following code.

...

Code Block
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 recording.")
  }
}

 

  • Declare IVerification in the declaration section of Activity/Fragment,

private var verificationHandler: IVerification? = null

  • Initialize verificationHandler and call the startVerificationInitialize continuous analysis in your Activity/Fragment/Service

Code Block
SondePassiveSdk.initContinuousVoiceAnalysis(context = this,
    callback = object : SondePassiveSdk.SondeInitCallback {
        override fun onError(error: Throwable) {
            Log.d("VoiceAnalysisService", "onError==>${error.message}")
        }

        override fun onSuccess(msg: String) {
            Log.d("VoiceAnalysisService", "onSuccess==>${msg}")
        }

    })
  • Call the startContinuousVoiceAnalysis() function to start verification.

verificationHandler = VerificationHandler.createVerification(requireContext()) verificationHandler?.startVerification(
Code Block
languagekotlin
SondePassiveSdk.startContinuousVoiceAnalysis(
            this,
            object : VerificationCallbackVoiceAnalysisCallback {
                override fun onError(throwable: Throwable) {
                  Log.d(TAG, "onErrorError==>${throwable.message}>$throwable")
                }

                override fun onScoreonSessionScoreReady(score: Score) {
                    Log.d(TAG, "Score==>$score")
                    //Get callback when score is ready.
                }

                override fun onSegmentFormedonSegmentAnalysed(recordingDatavoiceSegmentData: RecordingDataVoiceSegmentData) {
                    //Get callback when 3 sec segment formed and you will get
                    //recordingDatavoiceSegmentData as datatype in which you will be having following member
                    //isUserVerified:Boolean, 3 sec segment is verified or not.
                    //noOfSecond:Int, How much second user's verified voice is there.
                    //recordingDataType:RecordingDataType, you will get enum as NO_VOICE,ACTIVE_VOICE,INSUFFICIENT_VOICE,RECORDING.
                    //segmentNumber:Int, which segment is this from 10 segment of 3 sec each.
 
          }              override fun onVerificationStopped() {
                //Get call back when recording stop.
            }
            
        })
  • Typecast the score to VFFinalScore to get the other voice feature's scores.

...