Package net.idrnd.voicesdk.verify
Class VoiceVerifyStream
java.lang.Object
net.idrnd.voicesdk.common.VoiceSdkNativePeer
net.idrnd.voicesdk.verify.VoiceVerifyStream
- All Implemented Interfaces:
AutoCloseable
Enables voice verification in streaming scenario.
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
ConstructorsConstructorDescriptionVoiceVerifyStream(VoiceTemplateFactory voiceTemplateFactory, VoiceTemplateMatcher voiceTemplateMatcher, VoiceTemplate[] voiceTemplates, int sampleRate) VoiceVerifyStream(VoiceTemplateFactory voiceTemplateFactory, VoiceTemplateMatcher voiceTemplateMatcher, VoiceTemplate[] voiceTemplates, int sampleRate, int audioContextLengthSeconds) VoiceVerifyStream(VoiceTemplateFactory voiceTemplateFactory, VoiceTemplateMatcher voiceTemplateMatcher, VoiceTemplate[] voiceTemplates, int sampleRate, int audioContextLengthSeconds, float windowLengthSeconds) Sole constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddSamples(byte[] bytes) Adds audio samples for processing in PCM16 format.voidaddSamples(float[] floatSamples) Audio samples for processing encoded in normalized float format.voidaddSamples(short[] pcm16Samples) Adds audio samples for processing in PCM16 format.voidFinalizes input audio stream to process remaining audio samples and produce result if it's possibleRetrieves verification result from output queue containing one verify stream result for each reference template.Retrieves verification result from output queue consisting of single verify stream result corresponding to the zeroth reference template.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
-
VoiceVerifyStream
public VoiceVerifyStream(VoiceTemplateFactory voiceTemplateFactory, VoiceTemplateMatcher voiceTemplateMatcher, VoiceTemplate[] voiceTemplates, int sampleRate, int audioContextLengthSeconds, float windowLengthSeconds) Sole constructor. Initializes the stream VoiceVerifyStream 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 instancevoiceTemplates- Reference voice templates to match withsampleRate- Input audio stream sampling frequency in HzaudioContextLengthSeconds- Length of audio context for voice verification in seconds, must be at least windowLengthSeconds, default is 10windowLengthSeconds- Length of audio window passed to the template creation during stream processing, must be at least 0.5 seconds, default is 3- Throws:
VoiceSdkEngineException- wraps native exceptions
-
VoiceVerifyStream
public VoiceVerifyStream(VoiceTemplateFactory voiceTemplateFactory, VoiceTemplateMatcher voiceTemplateMatcher, VoiceTemplate[] voiceTemplates, int sampleRate, int audioContextLengthSeconds) -
VoiceVerifyStream
public VoiceVerifyStream(VoiceTemplateFactory voiceTemplateFactory, VoiceTemplateMatcher voiceTemplateMatcher, VoiceTemplate[] voiceTemplates, int sampleRate)
-
-
Method Details
-
addSamples
public void addSamples(byte[] bytes) Adds audio samples for processing in PCM16 format. If exception was thrown, then stream state is being reset except the accumulated results buffer.- Parameters:
bytes- Array of little-endian PCM16 audio bytes- Throws:
VoiceSdkEngineException- wraps native exceptions
-
addSamples
public void addSamples(short[] pcm16Samples) Adds audio samples for processing in PCM16 format. If exception was thrown, then stream state is being reset except the accumulated results buffer.- Parameters:
pcm16Samples- Array of PCM16 audio samples- Throws:
VoiceSdkEngineException- wraps native exceptions
-
addSamples
public void addSamples(float[] floatSamples) Audio samples for processing encoded in normalized float format. If exception was thrown, then stream state is being reset except the accumulated results buffer.- Parameters:
floatSamples- Array of float audio samples (in [-1, 1] range)- 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 verification result from output queue containing one verify stream result for each reference template. Use hasVerifyResult() to know if there are available results- Returns:
- verify result
- Throws:
VoiceSdkEngineException- wraps native exceptions
-
getVerifyResultForOneTemplate
Retrieves verification result from output queue consisting of single verify stream result corresponding to the zeroth reference template. Suitable for the case when the only one reference template was specified. Use hasVerifyResult() to know if there are available results Behaves the same as getVerifyResult in IDVoice earlier than 3.13, if only one reference template was set- Returns:
- verify result for zeroth reference voice template
- Throws:
VoiceSdkEngineException- wraps native exceptions
-