Package net.idrnd.voicesdk.media
Class SpeechSummaryStreamOpus
java.lang.Object
net.idrnd.voicesdk.common.VoiceSdkNativePeer
net.idrnd.voicesdk.media.SpeechSummaryStreamOpus
- All Implemented Interfaces:
AutoCloseable
Calculates
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
-
Constructor Summary
ConstructorsConstructorDescriptionSpeechSummaryStreamOpus(String initPath, int sampleRate) Initializes the stream, allocating native memory. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddPacket(byte[] bytes) Adds Opus packet for processing.voidFinalizes input audio stream to process remaining audio samples and produce result if it's possiblefloatRetrieves accumulated background length metricRetrieves a single speech event from output FIFO queue.Fetches accumulated list of speech events, removing them from stream queue.Retrieves accumulated speech info data.Retrieves accumulated speech summary data.booleanChecks if there are available speech events in output queuevoidreset()Resets stream state: clears buffer, resets speech summaryMethods inherited from class net.idrnd.voicesdk.common.VoiceSdkNativePeer
close, equals, hashCode
-
Constructor Details
-
SpeechSummaryStreamOpus
Initializes the stream, allocating native memory.- Parameters:
initPath- path to the initialization folder containing the required binaries and configuration filessampleRate- audio stream sampling rate, Hz- Throws:
VoiceSdkEngineException- wraps native exceptions
-
-
Method Details
-
addPacket
public void addPacket(byte[] bytes) Adds Opus packet for processing. If exception was thrown, then stream state is being reset except the accumulated results buffer.- Parameters:
bytes- Array containing single Opus packet. It is expected that packet contains data for single mono stream.- Throws:
VoiceSdkEngineException- wraps native exceptions
-
getTotalSpeechSummary
Retrieves accumulated speech summary data.- Returns:
SpeechSummary- Throws:
VoiceSdkEngineException- wraps native exceptions
-
getTotalSpeechInfo
Retrieves accumulated speech info data.- Returns:
SpeechInfo- Throws:
VoiceSdkEngineException- wraps native exceptions
-
getCurrentBackgroundLength
public float getCurrentBackgroundLength()Retrieves accumulated background length metric- Returns:
- amount of non-speech signal length in seconds
- Throws:
VoiceSdkEngineException- wraps native exceptions- See Also:
-
hasSpeechEvents
public boolean hasSpeechEvents()Checks if there are available speech events in output queue- Returns:
- true if there is available speech event, false otherwise
-
getSpeechEvent
Retrieves a single speech event from output FIFO queue. UsehasSpeechEvents()to check if there is available speech event.- Returns:
- A single speech event
- Throws:
VoiceSdkEngineException- wraps native exceptions
-
getSpeechEvents
Fetches accumulated list of speech events, removing them from stream queue.- Returns:
- list of speech events
- 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 -
reset
public void reset()Resets stream state: clears buffer, resets speech summary
-