decipher.featurise
Audio-to-feature extraction: mel-patch features, frequency-adaptive FFT parameters, SSL input preparation.
decipher.featurise.MEL_DIM MEL_DIM: int # default total dimension of mel_patch_feature output Output dimension of mel_patch_feature at default
parameters: flattened log-mel patch + auxiliary scalars.
decipher.featurise.mel_dim def mel_dim(n_mels: int = ..., patch_t: int = ...) -> int Compute the output dimension of mel_patch_feature for
non-default n_mels / patch_t.
decipher.featurise.auto_mel_params def auto_mel_params(
sr: int,
f_lo: float,
f_hi: float,
*,
n_mels: int = 64,
) -> dict Pick frequency-adaptive FFT parameters (n_fft, hop, fmin, fmax, n_mels)
for a target frequency band. Use this for infrasonic blue-whale calls
or very narrow-band high-frequency clicks.
decipher.featurise.mel_patch_feature def mel_patch_feature(
samples: np.ndarray,
sr: int,
*,
n_mels: int = ...,
patch_t: int = ...,
fmin: float | None = None,
fmax: float | None = None,
n_fft: int | None = None,
hop: int | None = None,
) -> np.ndarray Compute a fixed-length feature vector from a single clip:
time-normalised log-mel patch (resampled to patch_t frames)
flattened and concatenated with auxiliary scalars (duration, peak
frequency, bandwidth).
decipher.featurise.prepare_for_ssl def prepare_for_ssl(
samples: np.ndarray,
sr: int,
*,
target_sr: int = 16000,
clip_seconds: float = 1.0,
) -> np.ndarray Resample to target_sr and center-pad/crop to a
fixed-length clip. Use this to prepare units for AVESEncoder.embed_clip.