Class SpeechSummaryStreamOpus

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

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

    • SpeechSummaryStreamOpus

      public SpeechSummaryStreamOpus(String initPath, int sampleRate)
      Initializes the stream, allocating native memory.
      Parameters:
      initPath - path to the initialization folder containing the required binaries and configuration files
      sampleRate - 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

      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