public class SpeechEndpointDetectorOpus extends VoiceSdkNativePeer
Enables streaming scenario for end detection when Opus audio data is processed by packets. Intended usage scenario is following:
SpeechEndpointDetector
addPacket(byte[])
methods with incoming Opus packetsisSpeechEnded()
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
nativeId
Constructor and Description |
---|
SpeechEndpointDetectorOpus(int minSpeechLengthMs,
int maxSilenceLengthMs,
int sampleRate)
Initializes Opus speech endpoint detector.
|
Modifier and Type | Method and Description |
---|---|
void |
addPacket(byte[] bytes)
Adds Opus packet for processing
|
protected static long |
init(int minSpeechLengthMs,
int maxSilenceLengthMs,
int sampleRate) |
boolean |
isSpeechEnded()
Checks if speech end is detected after the previous
addPacket(byte[]) call |
protected void |
release()
This method should release resources on native layer (indirectly using nativeId)
|
void |
reset()
Resets detector, clearing all the accumulated statistics
|
close, equals, finalize, hashCode
public SpeechEndpointDetectorOpus(int minSpeechLengthMs, int maxSilenceLengthMs, int sampleRate)
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 streamVoiceSdkEngineException
- wraps native exceptionspublic void reset()
VoiceSdkEngineException
- wraps native exceptionspublic void addPacket(byte[] bytes)
bytes
- Array containing single Opus packet. It is expected that packet contains data for single mono streamVoiceSdkEngineException
- wraps native exceptionspublic boolean isSpeechEnded()
addPacket(byte[])
callprotected static long init(int minSpeechLengthMs, int maxSilenceLengthMs, int sampleRate)
protected void release()
VoiceSdkNativePeer
release
in class VoiceSdkNativePeer