Class LivenessEngine

java.lang.Object
net.idrnd.voicesdk.common.VoiceSdkNativePeer
net.idrnd.voicesdk.liveness.LivenessEngine
All Implemented Interfaces:
AutoCloseable

public class LivenessEngine extends VoiceSdkNativePeer
Performs voice liveness check.

This class serves as gateway to native Voice SDK implementation and allocates resources on native heap. To release the allocated memory, AutoCloseable.close() method should be invoked when the instance is no longer needed.

Any method that delegates to native call may throw VoiceSdkEngineException

  • Constructor Details

    • LivenessEngine

      public LivenessEngine(String initPath)
      Creates the instance and allocates native memory.
      Parameters:
      initPath - full path to the directory with init data
      Throws:
      VoiceSdkEngineException - wraps native exceptions
  • Method Details

    • checkLiveness

      public LivenessResult checkLiveness(byte[] pcm16Bytes, int sampleRate)
      Checks voice liveness from the given audio bytes.
      Parameters:
      pcm16Bytes - Array of little-endian PCM16 audio bytes
      sampleRate - Sample rate of the audio, Hz
      Returns:
      LivenessResult
      Throws:
      VoiceSdkEngineException - wraps native exceptions
    • checkLiveness

      public LivenessResult checkLiveness(short[] pcm16Samples, int sampleRate)
      Checks voice liveness from the given PCM16 audio samples.
      Parameters:
      pcm16Samples - Array of PCM16 audio samples
      sampleRate - Sample rate of the audio, Hz
      Returns:
      LivenessResult
      Throws:
      VoiceSdkEngineException - wraps native exceptions
    • checkLiveness

      public LivenessResult checkLiveness(float[] floatSamples, int sampleRate)
      Checks voice liveness from the given float audio samples.
      Parameters:
      floatSamples - Array of float audio samples (in [-1, 1] range)
      sampleRate - Sample rate of the audio, Hz
      Returns:
      LivenessResult
      Throws:
      VoiceSdkEngineException - wraps native exceptions
    • checkLiveness

      public LivenessResult checkLiveness(String audioFile)
      Checks voice liveness from the given audio file.
      Parameters:
      audioFile - Path to the audio file
      Returns:
      LivenessResult
      Throws:
      VoiceSdkEngineException - wraps native exceptions