lacing.tracks#
High-level “track-shaped” facades on top of lacing.
A track is an opinionated bundle of tiers that shows up in the wild
together. subtitle is the canonical example: sections,
lines, words over one audio asset, with a builder that hides
the Annotation / MediaRef / Provenance plumbing and a
query layer that takes float seconds instead of RationalTime.
These facades sit on top of the core store/tier/annotation API — they don’t introduce new storage. Anything you can build with a track facade can be built with the raw API; the facade just makes the common case ergonomic and consistent.
Functions
Register permissive body validators for the subtitle URIs. |
Classes
|
Builder for |
|
Read-side facade for |
- class lacing.tracks.SubtitleBuilder(store, *, asset_id, rate=1000, was_generated_by='lacing.tracks.subtitle', was_attributed_to='lacing', ensure_tiers=True)[source]#
Bases:
objectBuilder for
(sections, lines, words)tiers over one asset.The builder is a context manager only as a convenience; it has no transactional semantics. Calling
.section()/.line()/.word()writes immediately, in the order given.- Parameters:
store (
IntervalAnnotationStore) – AnyIntervalAnnotationStore(memory, sqlite, postgres).asset_id (
str) – TheMediaRef.asset_idto attach every annotation to. Typically a path or content-hash of the audio file.rate (
int) – Tick rate for time intervals. Defaults to 1000 (ms).was_generated_by (
str) –Provenance.was_generated_by. Defaults to"lacing.tracks.subtitle".was_attributed_to (
str) –Provenance.was_attributed_to.ensure_tiers (
bool) – When True (default), creates the three tiers if they don’t exist. Pass False if your store uses different tier names and you’ve created them yourself.
- add(*, tier, body_schema_uri, body, start_s, end_s)[source]#
Add an annotation to
tierwith explicit schema/body.- Return type:
_BuiltAnnotation
- line(text, start_s, end_s, *, line_index=None, section='', words=(), extra=None)[source]#
Add a lyric line.
wordsis an optional list of(text, start, end)or(text, start, end, confidence)tuples that will be inserted on thewordstier.- Return type:
_BuiltAnnotation
- class lacing.tracks.SubtitleTrack(store, *, asset_id, rate=1000)[source]#
Bases:
objectRead-side facade for
(sections, lines, words)over an asset.Methods take
floatseconds; conversions toRationalTimeare handled internally. Returned annotations are sorted by start time.- Parameters:
store (
IntervalAnnotationStore) – AnyIntervalAnnotationStore.asset_id (
str|None) – When set, query results are filtered to annotations whoseMediaRef.asset_idequals this value. PassNoneto ignore asset filtering (rarely what you want).rate (
int) – Tick rate used to build query intervals.
- lacing.tracks.register_subtitle_schemas()[source]#
Register permissive body validators for the subtitle URIs.
Calling this is optional; the builder works fine without registered schemas. Use it when you want body-shape errors to surface at write time rather than later.
- Return type:
Modules
Subtitle / lyric / caption tracks — the (sections, lines, words) trio. |