public class SpeechSummaryStreamOpus extends VoiceSdkNativePeer
SpeechSummary
in the streaming scenario for Opus stream input.
This class is stateful and the SpeechSummary
statistics is being recalculated after every addPacket(byte[])
method call.
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 |
---|
SpeechSummaryStreamOpus(java.lang.String initPath,
int sampleRate)
Initializes the stream, allocating native memory.
|
Modifier and Type | Method and Description |
---|---|
void |
addPacket(byte[] bytes)
Adds Opus packet for processing.
|
void |
finalizeStream()
Finalizes input audio stream to process remaining audio samples and produce result if it's possible
|
float |
getCurrentBackgroundLength()
Retrieves accumulated background length metric
|
SpeechEvent |
getSpeechEvent()
Retrieves a single speech event from output FIFO queue.
|
java.util.List<SpeechEvent> |
getSpeechEvents()
Fetches accumulated list of speech events, removing them from stream queue.
|
SpeechInfo |
getTotalSpeechInfo()
Retrieves accumulated speech info data.
|
SpeechSummary |
getTotalSpeechSummary()
Retrieves accumulated speech summary data.
|
boolean |
hasSpeechEvents()
Checks if there are available speech events in output queue
|
protected static long |
init(java.lang.String initPath,
int sampleRate) |
protected void |
release()
This method should release resources on native layer (indirectly using nativeId)
|
void |
reset()
Resets stream state: clears buffer, resets speech summary
|
close, equals, finalize, hashCode
public SpeechSummaryStreamOpus(java.lang.String initPath, int sampleRate)
initPath
- path to the initialization folder containing the required binaries and configuration filessampleRate
- audio stream sampling rate, HzVoiceSdkEngineException
- wraps native exceptionsprotected static long init(java.lang.String initPath, int sampleRate)
public void addPacket(byte[] bytes)
bytes
- Array containing single Opus packet. It is expected that packet contains data for single mono stream.VoiceSdkEngineException
- wraps native exceptionspublic SpeechSummary getTotalSpeechSummary()
SpeechSummary
VoiceSdkEngineException
- wraps native exceptionspublic SpeechInfo getTotalSpeechInfo()
SpeechInfo
VoiceSdkEngineException
- wraps native exceptionspublic float getCurrentBackgroundLength()
VoiceSdkEngineException
- wraps native exceptionsSpeechInfo.getBackgroundLengthMs()
public boolean hasSpeechEvents()
public SpeechEvent getSpeechEvent()
hasSpeechEvents()
to check if there is available speech event.VoiceSdkEngineException
- wraps native exceptionspublic java.util.List<SpeechEvent> getSpeechEvents()
VoiceSdkEngineException
- wraps native exceptionspublic void finalizeStream()
public void reset()
protected void release()
VoiceSdkNativePeer
release
in class VoiceSdkNativePeer