Class VoiceTemplateFactory

java.lang.Object
net.idrnd.voicesdk.common.VoiceSdkNativePeer
net.idrnd.voicesdk.verify.VoiceTemplateFactory
All Implemented Interfaces:
AutoCloseable

public class VoiceTemplateFactory extends VoiceSdkNativePeer
Provides capabilities for creating and comparing VoiceTemplate.

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

See Also:
  • Constructor Details

    • VoiceTemplateFactory

      public VoiceTemplateFactory(String initDataPath)
      Sole constructor. Initializes the Engine object and allocates the native resources.
      Parameters:
      initDataPath - full path to the directory with SDK data
      Throws:
      VoiceSdkEngineException - wraps native exceptions
  • Method Details

    • createVoiceTemplate

      public VoiceTemplate createVoiceTemplate(String audioPath, ChannelType channelType)
      Creates VoiceTemplate object from audio file. Sampling frequency should be equal to or greater than the value returned by getMinimumAudioSampleRate().
      Parameters:
      audioPath - path to audio file
      channelType - audio record source channel
      Returns:
      VoiceTemplate
      Throws:
      VoiceSdkEngineException - wraps native exceptions
    • createVoiceTemplate

      public VoiceTemplate createVoiceTemplate(String audioPath)
    • createVoiceTemplate

      public VoiceTemplate createVoiceTemplate(byte[] buffer, int sampleRate, ChannelType channelType)
      Creates VoiceTemplate from byte-array PCM16 encoded audio. Sampling frequency should be equal to or greater than the value returned by getMinimumAudioSampleRate().
      Parameters:
      buffer - input array of byte samples
      sampleRate - sample frequency, Hz
      channelType - audio record source channel
      Returns:
      VoiceTemplate
      Throws:
      VoiceSdkEngineException - wraps native exceptions
    • createVoiceTemplate

      public VoiceTemplate createVoiceTemplate(byte[] buffer, int sampleRate)
    • createVoiceTemplate

      public VoiceTemplate createVoiceTemplate(short[] buffer, int sampleRate, ChannelType channelType)
      Creates VoiceTemplate from PCM16 encoded audio. Sampling frequency should be equal to or greater than the value returned by getMinimumAudioSampleRate().
      Parameters:
      buffer - input array of PCM16 samples
      sampleRate - sample frequency, Hz
      channelType - audio record source channel
      Returns:
      VoiceTemplate
      Throws:
      VoiceSdkEngineException - wraps native exceptions
    • createVoiceTemplate

      public VoiceTemplate createVoiceTemplate(short[] buffer, int sampleRate)
    • createVoiceTemplate

      public VoiceTemplate createVoiceTemplate(float[] buffer, int sampleRate, ChannelType channelType)
      Creates VoiceTemplate from audio data encoded in 'truncated' float format Sampling frequency should be equal to or greater than the value returned by getMinimumAudioSampleRate().
      Parameters:
      buffer - input array of float samples, values are limited by range [-1; 1]
      sampleRate - sample frequency, Hz
      channelType - audio record source channel
      Returns:
      VoiceTemplate
      Throws:
      VoiceSdkEngineException - wraps native exceptions
    • createVoiceTemplate

      public VoiceTemplate createVoiceTemplate(float[] buffer, int sampleRate)
    • mergeVoiceTemplates

      public VoiceTemplate mergeVoiceTemplates(VoiceTemplate[] voiceTemplates)
      Merges multiple VoiceTemplate objects into single template. All the templates should have the same init data ID as the factory instance.
      Parameters:
      voiceTemplates - input VoiceTemplate objects
      Returns:
      VoiceTemplate
      Throws:
      VoiceSdkEngineException - wraps native exceptions
    • getInitDataId

      public String getInitDataId()
      Returns ID of the init data, which was used to create the factory
      Returns:
      A string containing init data ID
    • getMinimumAudioSampleRate

      public int getMinimumAudioSampleRate()
      Returns Returns minimum supported input audio sampling frequency in Hz
      Returns:
      A minimum sampling rate in Hz