Skip to content

hikariwave.config

Configuration

BufferMode

Bases: IntEnum

Frame storage buffer modes.

MEMORY class-attribute instance-attribute

MEMORY = 0

All buffered frames will be stored in memory (RAM) - Only recommended for high-RAM servers/devices.

DISK class-attribute instance-attribute

DISK = 1

All buffered frames will be stored on the disk (storage) with configurable values and amounts - Recommended for most setups.

BufferConfig

BufferConfig(
    mode: BufferMode = BufferMode.MEMORY,
    *,
    duration: int = None
)

Configure the frame storage buffer system.

Create a new frame storage buffer configuration.

PARAMETER DESCRIPTION
mode

The frame storage buffer mode - DISK is recommended for most devices, MEMORY is set by default as it's expected behavior (all audio stored in RAM).

TYPE: BufferMode DEFAULT: BufferMode.MEMORY

duration

If mode is BufferMode.DISK, configures the amount of seconds of audio to be stored in each chunk file. 15-30 seconds is recommended, with lower values better for low-RAM and higher for high-RAM.

TYPE: int DEFAULT: None

Note

If mode is BufferMode.DISK, duration must be specified.

RAISES DESCRIPTION
TypeError
  • If mode is not BufferMode.
  • If duration is provided and is not int.
ValueError
  • If mode is BufferMode.DISK and duration is not provided.
  • If duration is provided and is less than 1 while mode is BufferMode.DISK.

duration property

duration: int

If provided, the amount of seconds of audio each buffer cache file contains.

mode property

mode: BufferMode

The frame storage buffer mode.

FFmpegConfig

FFmpegConfig(
    max_per_core: int = 1,
    max_total: int = 8,
    path: str = "ffmpeg",
)

Configure the FFmpeg system.

Create a new FFmpeg configuration. This configuration only affects the global state of the voice system, not per-connection.

PARAMETER DESCRIPTION
path

The system filepath to the FFmpeg executable/installation.

TYPE: str DEFAULT: 'ffmpeg'

max_per_core

The maximum amount of spawned FFmpeg processes per logical CPU/processor core.

TYPE: int DEFAULT: 1

max_total

The maximum amount of spawned FFmpeg processes that can exist at any one time.

TYPE: int DEFAULT: 8

max_per_core property

max_per_core: int

The maximum amount of spawned FFmpeg processes per logic CPU/processor core.

max_total property

max_total: int

The maximum amount of spawned FFmpeg processes that can exist at any one time.

ffmpeg property

ffmpeg: str

The system filepath to the FFmpeg executable/installation.

Config

Config(
    *,
    bitrate: str = "96k",
    buffer: BufferConfig = None,
    channels: int = 2,
    ffmpeg: FFmpegConfig = None,
    max_history: int = None,
    max_queue: int = None,
    record: bool = False,
    volume: float | int | str = 1.0
)

Global or per-connection configuration settings.

Create a global or per-connection configuration object.

PARAMETER DESCRIPTION
bitrate

If provided, the playback bitrate of all audio in KB/s.

TYPE: str DEFAULT: '96k'

buffer

If provided, the frame storage buffer configuration.

TYPE: BufferConfig DEFAULT: None

channels

If provided, the amount of audio channels that are used.

TYPE: int DEFAULT: 2

ffmpeg

If provided, the FFmpeg system configuration.

TYPE: FFmpegConfig DEFAULT: None

max_history

If provided, the maximum amount of audio sources recorded in audio player history.

TYPE: int DEFAULT: None

max_queue

If provided, the maximum amount of audio sources that can be in audio player queues.

TYPE: int DEFAULT: None

record

If provided, sets if you can collect/handle/record members' voice packets and handle via MemberSpeechEvent.

TYPE: bool DEFAULT: False

volume

If provided, the volume of all audio - Reference FFmpeg volume audio filtering.

TYPE: float | int | str DEFAULT: 1.0

RAISES DESCRIPTION
TypeError
  • If bitrate is provided and is not str.
  • If buffer is provided and is not BufferConfig.
  • If channels is provided and is not int.
  • If ffmpeg is provided and is not FFmpegConfig.
  • If max_history is provided and is not int.
  • If max_queue is provided and is not int.
  • If record is provided and is not bool.
  • If volume is provided and is not float, int, or str.
ValueError
  • If bitrate is provided and not between 6k and 510k.
  • If channels is provided and not 1 or 2.
  • If max_history is provided and not at least 1.
  • If max_queue is provided and not at least 1.
  • If volume is provided and is float or int and is not positive or is str and doesn't contain a number, doesn't end with dB, or (if provided) doesn't start with '-' or '+'.

bitrate property

bitrate: str

The playback bitrate of all audio in KB/s.

buffer property

buffer: BufferConfig

The frame storage buffer configuration.

channels property

channels: int

The amount of audio channels that are used.

ffmpeg property

ffmpeg: FFmpegConfig

The FFmpeg system configuration - Only applicable globally, not per-connection.

max_history property

max_history: int | None

If set, the maximum amount of audio sources that can be recorded in audio player history.

max_queue property

max_queue: int | None

If set, the maximum amount of audio sources that can be queued in the audio player.

record property

record: bool

If you are collecting/handling/recording members' voice packets and handling via MemberSpeechEvent.

volume property

volume: float | int | str

The default volume of all audio sources.

validate_bitrate

validate_bitrate(bitrate: object) -> str

Validate a user-provided bitrate to specific contraints.

PARAMETER DESCRIPTION
bitrate

The user-provided bitrate.

TYPE: object

RETURNS DESCRIPTION
str

The sanitized bitrate.

RAISES DESCRIPTION
TypeError

If bitrate is not a str.

ValueError
  • If bitrate does not end with k.
  • If bitrate is not an integer before the k.
  • If bitrate integer is not between 6k and 510k.

validate_channels

validate_channels(channels: object) -> int

Validate user-provided channels to specific constraints.

PARAMETER DESCRIPTION
channels

The user-provided channels.

TYPE: object

RETURNS DESCRIPTION
int

The sanitized channels.

RAISES DESCRIPTION
TypeError

If channels is not int.

ValueError

If channels is not 1 or 2.

validate_volume

validate_volume(volume: object) -> float | int | str

Validate user-provided volume to specific contraints.

PARAMETER DESCRIPTION
volume

The user-provided volume.

TYPE: object

RETURNS DESCRIPTION
float | int | str

The sanitized volume.

RAISES DESCRIPTION
TypeError

If volume isn't float, int, or str.

ValueError
  • If volume is float or int and is not positive.
  • If volume is str and doesn't contain a number, doesn't end with dB, or (if provided) doesn't start with - or +.