public class SpeechEndpointDetector extends VoiceSdkNativePeer
Enables streaming scenario for end detection when audio data is processed by continuous buffers. Intended usage scenario is following:
SpeechEndpointDetector
addSamples(byte[])
methods with incoming audio dataisSpeechEnded()
VoiceSdkNativePeer.close()
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 |
---|
SpeechEndpointDetector(int minSpeechLengthMs,
int maxSilenceLengthMs,
int sampleRate)
Initializes speech endpoint detector.
|
Modifier and Type | Method and Description |
---|---|
void |
addSamples(byte[] bytes)
Adds audio samples for processing in PCM16 format
|
void |
addSamples(float[] floatSamples)
Audio samples for processing encoded in normalized float format
|
void |
addSamples(short[] pcm16Samples)
Adds audio samples for processing in PCM16 format
|
protected void |
addSamples1(byte[] bytes) |
protected void |
addSamples2(short[] bytes) |
protected void |
addSamples3(float[] bytes) |
protected static long |
init(int minSpeechLengthMs,
int maxSilenceLengthMs,
int sampleRate) |
boolean |
isSpeechEnded()
Checks if speech end is detected after the previous
addSamples(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 SpeechEndpointDetector(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 addSamples(byte[] bytes)
bytes
- Array of little-endian PCM16 audio bytesVoiceSdkEngineException
- wraps native exceptionspublic void addSamples(short[] pcm16Samples)
pcm16Samples
- Array of PCM16 audio samplesVoiceSdkEngineException
- wraps native exceptionspublic void addSamples(float[] floatSamples)
floatSamples
- Array of float audio samples (in [-1, 1] range)VoiceSdkEngineException
- wraps native exceptionsprotected void addSamples1(byte[] bytes)
protected void addSamples2(short[] bytes)
protected void addSamples3(float[] bytes)
public boolean isSpeechEnded()
addSamples(byte[])
callprotected static long init(int minSpeechLengthMs, int maxSilenceLengthMs, int sampleRate)
protected void release()
VoiceSdkNativePeer
release
in class VoiceSdkNativePeer