Skip to main content

clika_runtime.io functions

encode_audio

encode_audio(*args, **kwargs)

encode_audio(samples: clika_runtime._core.Tensor, sample_rate: int) -> bytes

Encode a waveform as a 16-bit PCM WAV payload (bytes); the same accepted shapes and dtypes as save_audio, and save_audio writes exactly these bytes.

load_audio

load_audio(*args, **kwargs)

load_audio(path: str, target_sample_rate: int = 0, target_channels: int = 0) -> tuple

Decode an audio file (WAV / MP3 / FLAC / OGG / ...) to a host Float32 tensor: returns (samples, sample_rate, channels, frames); samples is [frames] for mono or [frames, channels] interleaved. A target_sample_rate / target_channels of 0 keeps the file's native value; a non-zero value resamples / remixes to it.

load_gguf

load_gguf(*args, **kwargs)

load_gguf(path: str, device: clika_runtime._core.Device = Device(CPU:-1)) -> tuple

Load a .gguf checkpoint: returns (tensors as dict[str, Tensor], the file's metadata key/value pairs as JSON text, e.g. general.architecture).

load_npy

load_npy(*args, **kwargs)

load_npy(path: str, device: clika_runtime._core.Device = Device(CPU:-1)) -> clika_runtime._core.Tensor

Load a .npy file as one tensor.

load_safetensors

load_safetensors(*args, **kwargs)

load_safetensors(path: str, device: clika_runtime._core.Device = Device(CPU:-1)) -> dict

Load a .safetensors file as dict[str, Tensor] on device.

save_audio

save_audio(*args, **kwargs)

save_audio(samples: clika_runtime._core.Tensor, sample_rate: int, path: str) -> None

Write a waveform as a 16-bit PCM WAV file at path (created / truncated). samples is [frames] (mono) or [frames, channels] interleaved: a float tensor holds values in [-1, 1] (values outside clip); an Int16 tensor is written as is. sample_rate is in Hz.

save_npy

save_npy(*args, **kwargs)

save_npy(tensor: clika_runtime._core.Tensor, path: str) -> None

Write one tensor to a .npy file.

save_safetensors

save_safetensors(*args, **kwargs)

save_safetensors(tensors: dict, path: str) -> None

Write a dict[str, Tensor] to a .safetensors file.