treble_tsdk.scene.audio_sample_ref
Classes
A serializable reference to an audio sample. |
- class treble_tsdk.scene.audio_sample_ref.AudioSampleReference
A serializable reference to an audio sample.
loader_keyreferences a globally registered loader, whileloader_urlstores the original data source location for reproducibility.loader_kwargscarries the constructor keyword arguments needed to re-instantiate the loader in a fresh session without requiring anAudioDatasetto 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 optionallyloader_kwargs.- Returns:
The reconstructed reference.
- load_audio_signal() AudioSignal
Load the audio signal via the registered loader for
loader_keyandloader_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, andloader_kwargs.
- id: str
- loader_key: str
- loader_url: str
- transcript: str