Interface AudioReceiver


public interface AudioReceiver
Interface for receiving audio data from Discord voice connections. Plugins implementing audio recording or speech-to-text functionality should implement this interface.

Note: Receiving audio from Discord requires the bot to have the appropriate permissions and the connection to be DAVE-compliant.

  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    Called when the audio receiver is being closed.
    void
    handleAudio(long userId, byte[] audioData)
    Called when audio data is received from a user.
    default void
    handleCombinedAudio(byte[] audioData)
    Called when combined audio from all users is received.
    default void
    Called when a user starts speaking.
    default void
    Called when a user stops speaking.
    default boolean
    Check if this receiver wants Opus-encoded audio (true) or decoded PCM (false).
  • Method Details

    • handleAudio

      void handleAudio(long userId, byte[] audioData)
      Called when audio data is received from a user.
      Parameters:
      userId - the ID of the user speaking
      audioData - the received audio data (Opus-encoded)
    • handleCombinedAudio

      default void handleCombinedAudio(byte[] audioData)
      Called when combined audio from all users is received. This is useful for recording the entire voice channel.
      Parameters:
      audioData - the combined audio data
    • handleUserStartSpeaking

      default void handleUserStartSpeaking(long userId)
      Called when a user starts speaking.
      Parameters:
      userId - the ID of the user who started speaking
    • handleUserStopSpeaking

      default void handleUserStopSpeaking(long userId)
      Called when a user stops speaking.
      Parameters:
      userId - the ID of the user who stopped speaking
    • wantsOpus

      default boolean wantsOpus()
      Check if this receiver wants Opus-encoded audio (true) or decoded PCM (false).
      Returns:
      true for Opus data, false for decoded PCM
    • close

      default void close()
      Called when the audio receiver is being closed. Clean up any resources here.