Class VoiceVerifyStreamOpus

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

public class VoiceVerifyStreamOpus extends VoiceSdkNativePeer
Enables voice verification in streaming scenario for Opus stream input.

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

    • VoiceVerifyStreamOpus

      public VoiceVerifyStreamOpus(VoiceTemplateFactory voiceTemplateFactory, VoiceTemplateMatcher voiceTemplateMatcher, VoiceTemplate voiceTemplate, int sampleRate, int audioContextLengthSeconds)
      Sole constructor. Initializes the stream VoiceVerifyStreamOpus and allocates the native resources. Sampling frequency should be equal to or greater than the value returned by VoiceTemplateFactory.getMinimumAudioSampleRate(). Voice template matcher, voice template factory and voice template should have the same init data ID.
      Parameters:
      voiceTemplateFactory - Voice template factory instance
      voiceTemplateMatcher - Voice template matcher instance
      voiceTemplate - Reference voice template to match with
      sampleRate - Input audio stream sampling frequency in Hz. Must be one of 16000, 24000 or 48000.
      audioContextLengthSeconds - Length of audio context for voice verification in seconds, must be at least 3 seconds, default is 10
      Throws:
      VoiceSdkEngineException - wraps native exceptions
    • VoiceVerifyStreamOpus

      public VoiceVerifyStreamOpus(VoiceTemplateFactory voiceTemplateFactory, VoiceTemplateMatcher voiceTemplateMatcher, VoiceTemplate voiceTemplate, int sampleRate)
  • Method Details

    • addPacket

      public void addPacket(byte[] bytes)
      Adds Opus packet for processing. If exception was thrown, then stream state is being reset except the accumulated results buffer.
      Parameters:
      bytes - Array containing single Opus packet. It is expected that packet contains data for single mono stream.
      Throws:
      VoiceSdkEngineException - wraps native exceptions
    • reset

      public void reset()
      Resets internal stream state
      Throws:
      VoiceSdkEngineException - wraps native exceptions
    • finalizeStream

      public void finalizeStream()
      Finalizes input audio stream to process remaining audio samples and produce result if it's possible
      Throws:
      VoiceSdkEngineException - wraps native exceptions
    • hasVerifyResults

      public boolean hasVerifyResults()
      Checks if any verify results are present in stream queue
      Returns:
      true if any results are present
      Throws:
      VoiceSdkEngineException - wraps native exceptions
    • getVerifyResult

      public VerifyStreamResult getVerifyResult()
      Retrieves one verify results from stream queue.
      Returns:
      verify result
      Throws:
      VoiceSdkEngineException - wraps native exceptions
    • getVerifyResults

      public List<VerifyStreamResult> getVerifyResults()
      Fetches accumulated list of verify results, removing them from stream queue.
      Returns:
      list of verify results
      Throws:
      VoiceSdkEngineException - wraps native exceptions