hearing.storage

Transcript persistence via key-value stores (python-storage / dol).

A transcript is standoff annotation data — persist the whole transcript (not just a rolling window) so post-meeting agents see everything (see the hearing-agents and annotation-systems skills). MeetingStore saves/loads transcripts as JSON keyed by meeting id, over any MutableMapping — a plain dict (tests), a dol store (e.g. TextFiles), or the dependency-free filesystem fallback here. Meeting audio, being large binary blobs, goes to a separate bytes store (MeetingStore(..., recordings=...)).

Functions

get_bytes_store([path])

Return a bytes-valued MutableMapping (for recordings).

get_store([path])

Return a string-valued MutableMapping for transcripts.

transcript_from_json(s)

Reconstruct a Transcript from transcript_to_json() output.

transcript_to_json(transcript)

Serialize a Transcript to a JSON string (round-trippable).

Classes

MeetingStore([store, recordings])

Save/load transcripts keyed by meeting id, over any text MutableMapping.

class hearing.storage.MeetingStore(store=None, *, recordings=None)[source]

Bases: object

Save/load transcripts keyed by meeting id, over any text MutableMapping.

>>> store = MeetingStore({})                       # in-memory
>>> from hearing.types import Transcript, TranscriptSegment, TimeSpan
>>> _ = store.save("m1", Transcript([TranscriptSegment("hi", TimeSpan(0, 500))]))
>>> store.load("m1").text
'hi'
>>> list(store)
['m1']

Recordings (the meeting audio) live in a separate bytes store, given as recordings (a MutableMapping or a directory), under <meeting id> plus the audio’s extension when the id does not already end with it:

>>> store = MeetingStore({}, recordings={})
>>> store.save_recording("m1", b"RIFF...", ext=".wav")
'm1.wav'
>>> store.recording("m1")
b'RIFF...'
load(meeting_id)[source]

Load the transcript stored under meeting_id.

Return type:

Transcript

meeting_ids()[source]

Sorted ids of stored meetings.

Return type:

list[str]

recording(meeting_id)[source]

The meeting’s audio bytes, as stored by save_recording().

Return type:

bytes

recording_key(meeting_id)[source]

The key of the meeting’s recording (KeyError if there is none).

Return type:

str

save(meeting_id, transcript)[source]

Persist transcript under meeting_id; return the storage key.

Return type:

str

save_recording(meeting_id, audio, *, ext='')[source]

Store the meeting’s audio bytes; return the key (<id><ext>).

Return type:

str

hearing.storage.get_bytes_store(path=None)[source]

Return a bytes-valued MutableMapping (for recordings).

None -> an in-memory dict; a path -> a dol.Files store if dol is installed, else the dependency-free _FileBytesStore over that directory.

Return type:

MutableMapping

hearing.storage.get_store(path=None)[source]

Return a string-valued MutableMapping for transcripts.

None -> an in-memory dict. A path -> a dol.TextFiles store if dol is installed (pip install 'hearing[storage]'), else the dependency-free _FileTextStore over that directory.

Return type:

MutableMapping

hearing.storage.transcript_from_json(s)[source]

Reconstruct a Transcript from transcript_to_json() output.

Return type:

Transcript

hearing.storage.transcript_to_json(transcript)[source]

Serialize a Transcript to a JSON string (round-trippable).

Return type:

str