Class SpeechSummaryStream

java.lang.Object
net.idrnd.voicesdk.common.VoiceSdkNativePeer
net.idrnd.voicesdk.media.SpeechSummaryStream
All Implemented Interfaces:
AutoCloseable

public class SpeechSummaryStream extends VoiceSdkNativePeer
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 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

      public SpeechSummary getTotalSpeechSummary()
      Retrieves accumulated speech summary data.
      Returns:
      SpeechSummary
      Throws:
      VoiceSdkEngineException - wraps native exceptions
    • getTotalSpeechInfo

      public SpeechInfo 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

      public SpeechEvent getSpeechEvent()
      Retrieves a single speech event from output FIFO queue. Use hasSpeechEvents() to check if there is available speech event.
      Returns:
      A single speech event
      Throws:
      VoiceSdkEngineException - wraps native exceptions
    • getSpeechEvents

      public List<SpeechEvent> 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