Package net.idrnd.voicesdk.media
Class SpeechEndpointDetectorOpus
java.lang.Object
net.idrnd.voicesdk.common.VoiceSdkNativePeer
net.idrnd.voicesdk.media.SpeechEndpointDetectorOpus
- All Implemented Interfaces:
AutoCloseable
Provides the functionality of speech end detection in Opus audio stream.
Enables streaming scenario for end detection when Opus audio data is processed by packets. Intended usage scenario is following:
- initialize
SpeechEndpointDetector - call 1 or more
addPacket(byte[])methods with incoming Opus packets - call
isSpeechEnded() - if false, repeat
- if true, stop processing and
VoiceSdkNativePeer.close()
End detection is parameterized with 2 thresholds: minimum speech length and maximum silence length. End detection is triggered when minimum speech length is accumulated and then uninterrupted silence longer that 'max silence length' occurs.
This class is stateful and is not thread safe.
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
ConstructorsConstructorDescriptionSpeechEndpointDetectorOpus(int minSpeechLengthMs, int maxSilenceLengthMs, int sampleRate) Initializes Opus speech endpoint detector. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddPacket(byte[] bytes) Adds Opus packet for processingbooleanChecks if speech end is detected after the previousaddPacket(byte[])callvoidreset()Resets detector, clearing all the accumulated statisticsMethods inherited from class net.idrnd.voicesdk.common.VoiceSdkNativePeer
close, equals, hashCode
-
Constructor Details
-
SpeechEndpointDetectorOpus
public SpeechEndpointDetectorOpus(int minSpeechLengthMs, int maxSilenceLengthMs, int sampleRate) Initializes Opus speech endpoint detector.- Parameters:
minSpeechLengthMs- the threshold for required accumulated speech durationmaxSilenceLengthMs- the threshold for the duration of continuous silence that triggers the end detection if the required amount of speech is accumulatedsampleRate- sample rate of incoming audio data stream- Throws:
VoiceSdkEngineException- wraps native exceptions
-
-
Method Details
-
reset
public void reset()Resets detector, clearing all the accumulated statistics- Throws:
VoiceSdkEngineException- wraps native exceptions
-
addPacket
public void addPacket(byte[] bytes) Adds Opus packet for processing- Parameters:
bytes- Array containing single Opus packet. It is expected that packet contains data for single mono stream- Throws:
VoiceSdkEngineException- wraps native exceptions
-
isSpeechEnded
public boolean isSpeechEnded()Checks if speech end is detected after the previousaddPacket(byte[])call- Returns:
- true if speech end is detected
-