Class SpeechEndpointDetectorOpus

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

public class SpeechEndpointDetectorOpus extends VoiceSdkNativePeer
Provides the functionality of speech end detection in Opus audio stream.

Enables streaming scenario for end detection when Opus audio data is processed by packets. Intended usage scenario is following:

End detection is parameterized with 2 thresholds: minimum speech length and maximum silence length. End detection is triggered when minimum speech length is accumulated and then uninterrupted silence longer that 'max silence length' occurs.

This class is stateful and is not thread safe.

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

    • SpeechEndpointDetectorOpus

      public SpeechEndpointDetectorOpus(int minSpeechLengthMs, int maxSilenceLengthMs, int sampleRate)
      Initializes Opus speech endpoint detector.
      Parameters:
      minSpeechLengthMs - the threshold for required accumulated speech duration
      maxSilenceLengthMs - the threshold for the duration of continuous silence that triggers the end detection if the required amount of speech is accumulated
      sampleRate - sample rate of incoming audio data stream
      Throws:
      VoiceSdkEngineException - wraps native exceptions
  • Method Details

    • reset

      public void reset()
      Resets detector, clearing all the accumulated statistics
      Throws:
      VoiceSdkEngineException - wraps native exceptions
    • addPacket

      public void addPacket(byte[] bytes)
      Adds Opus packet for processing
      Parameters:
      bytes - Array containing single Opus packet. It is expected that packet contains data for single mono stream
      Throws:
      VoiceSdkEngineException - wraps native exceptions
    • isSpeechEnded

      public boolean isSpeechEnded()
      Checks if speech end is detected after the previous addPacket(byte[]) call
      Returns:
      true if speech end is detected