Package net.idrnd.voicesdk.verify
Class VoiceVerifyStreamOpus
java.lang.Object
net.idrnd.voicesdk.common.VoiceSdkNativePeer
net.idrnd.voicesdk.verify.VoiceVerifyStreamOpus
- All Implemented Interfaces:
AutoCloseable
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 Summary
ConstructorsConstructorDescriptionVoiceVerifyStreamOpus(VoiceTemplateFactory voiceTemplateFactory, VoiceTemplateMatcher voiceTemplateMatcher, VoiceTemplate voiceTemplate, int sampleRate) VoiceVerifyStreamOpus(VoiceTemplateFactory voiceTemplateFactory, VoiceTemplateMatcher voiceTemplateMatcher, VoiceTemplate voiceTemplate, int sampleRate, int audioContextLengthSeconds) Sole constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddPacket(byte[] bytes) Adds Opus packet for processing.voidFinalizes input audio stream to process remaining audio samples and produce result if it's possibleRetrieves one verify results from stream queue.Fetches accumulated list of verify results, removing them from stream queue.booleanChecks if any verify results are present in stream queuevoidreset()Resets internal stream stateMethods inherited from class net.idrnd.voicesdk.common.VoiceSdkNativePeer
close, equals, hashCode
-
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 byVoiceTemplateFactory.getMinimumAudioSampleRate(). Voice template matcher, voice template factory and voice template should have the same init data ID.- Parameters:
voiceTemplateFactory- Voice template factory instancevoiceTemplateMatcher- Voice template matcher instancevoiceTemplate- Reference voice template to match withsampleRate- 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
Retrieves one verify results from stream queue.- Returns:
- verify result
- Throws:
VoiceSdkEngineException- wraps native exceptions
-
getVerifyResults
Fetches accumulated list of verify results, removing them from stream queue.- Returns:
- list of verify results
- Throws:
VoiceSdkEngineException- wraps native exceptions
-