treble_tsdk.scene.audio_sample_ref

Classes

AudioSampleReference

A serializable reference to an audio sample.

class treble_tsdk.scene.audio_sample_ref.AudioSampleReference

A serializable reference to an audio sample.

loader_key references a globally registered loader, while loader_url stores the original data source location for reproducibility. loader_kwargs carries the constructor keyword arguments needed to re-instantiate the loader in a fresh session without requiring an AudioDataset to be present.

__init__(id: str, loader_key: str, loader_url: str, length_s: float | None, transcript: str, metadata: dict[str, ~typing.Any], loader_kwargs: dict[str, ~typing.Any] = <factory>) None
classmethod from_json(json_str: str) AudioSampleReference

Reconstruct an instance from a JSON string produced by to_json().

Parameters:

json_str – JSON encoding of a struct as returned by to_struct().

Returns:

The reconstructed reference.

classmethod from_struct(data: dict[str, Any]) AudioSampleReference

Reconstruct an instance from a dictionary produced by to_struct().

Parameters:

data – Dict with keys id, loader_key, loader_url, length_s, transcript, metadata, and optionally loader_kwargs.

Returns:

The reconstructed reference.

load_audio_signal() AudioSignal

Load the audio signal via the registered loader for loader_key and loader_url.

Returns:

The decoded audio signal.

to_json() str

Serialize to a JSON string.

Returns:

JSON encoding of to_struct().

to_struct() dict[str, Any]

Convert to a JSON-serializable dictionary.

Returns:

A dict with keys id, loader_key, loader_url, length_s, transcript, metadata, and loader_kwargs.

id: str
length_s: float | None
loader_key: str
loader_kwargs: dict[str, Any]
loader_url: str
metadata: dict[str, Any]
transcript: str