Package net.idrnd.voicesdk.media
Class SpeechSummaryStream
java.lang.Object
net.idrnd.voicesdk.common.VoiceSdkNativePeer
net.idrnd.voicesdk.media.SpeechSummaryStream
- All Implemented Interfaces:
AutoCloseable
Calculates
SpeechSummary in the streaming scenarios.
This class is stateful and the SpeechSummary statistics is being recalculated after every addSamples(byte[]) method.
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
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddSamples(byte[] bytes) Adds audio samples for processing in PCM16 formatvoidaddSamples(float[] floatSamples) Adds audio samples for processing encoded in normalized float formatvoidaddSamples(short[] pcm16Samples) Adds audio samples for processing in PCM16 formatvoidFinalizes 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
-
Method Details
-
addSamples
public void addSamples(byte[] bytes) Adds audio samples for processing in PCM16 format- Parameters:
bytes- Array of little-endian PCM16 audio bytes- Throws:
VoiceSdkEngineException- wraps native exceptions
-
addSamples
public void addSamples(short[] pcm16Samples) Adds audio samples for processing in PCM16 format- Parameters:
pcm16Samples- Array of PCM16 audio samples- Throws:
VoiceSdkEngineException- wraps native exceptions
-
addSamples
public void addSamples(float[] floatSamples) Adds audio samples for processing encoded in normalized float format- Parameters:
floatSamples- Array of float audio samples (in [-1, 1] range)- 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
-