segment_args

ketos.audio.utils.misc.segment_args(rate, offset, window, step, duration)[source]

Computes input arguments for audio.utils.misc.make_segment() to produce a centered spectrogram with properties as close as possible to those specified.

Args:
rate: float

Sampling rate in Hz

offset: float

Offset in seconds

window: float

Window size in seconds

step: float

Window size in seconds

duration: float

Duration in seconds

Returns:
: dict
Dictionary with following keys and values:
  • win_len: Window size in number of samples (int)

  • step_len: Step size in number of samples (int)

  • num_segs: Number of steps (int)

  • offset_len: Offset in number of samples (int)

Example:
>>> from ketos.audio.utils.misc import segment_args
>>> args = segment_args(rate=1000., duration=3., offset=0., window=0.1, step=0.02)
>>> for key,value in sorted(args.items()):
...     print(key,':',value)
num_segs : 150
offset_len : -40
step_len : 20
win_len : 100