hearing.types¶
Shared data model for the hearing pipeline.
This is the SSOT data spine that every concern (capture, STT, diarization,
agents) speaks. A transcript is standoff interval annotation over the audio:
segments reference the audio by time (a TimeSpan) and never carry the
samples themselves. Time is integer milliseconds — never bare float seconds —
so it is accumulation-safe, hashable, and round-trippable.
See the hearing-architecture skill for the rationale behind every choice
here, and the annotation-systems skill for the standoff-annotation theory.
Functions
|
Merge several segment sequences into one list ordered by start time. |
Classes
|
Which capture channel a segment came from. |
|
A half-open interval |
|
A finished transcript: an ordered collection of segments plus metadata. |
|
The data spine — a standoff interval annotation over the audio. |
|
Optional word-level timing (WhisperX / |
- class hearing.types.Channel(*values)[source]¶
-
Which capture channel a segment came from.
The channel is the “me vs them” signal, for free:
MICis the local user,SYSTEMis everyone else (audio that came out of the speakers).MIXEDis a single-channel / unknown source.
- class hearing.types.TimeSpan(start_ms, end_ms)[source]¶
Bases:
objectA half-open interval
[start_ms, end_ms)in integer milliseconds.Integer time, never float seconds — accumulation-safe and hashable.
>>> TimeSpan(0, 1500).duration_ms 1500
- class hearing.types.Transcript(segments=(), sample_rate=None, meta=<factory>)[source]¶
Bases:
objectA finished transcript: an ordered collection of segments plus metadata.
Iterable and
len-able, so it stands in for aSequenceof segments wherever the architecture’s facades return “segments”. Adds convenience accessors the CLI/agents need.>>> t = Transcript((TranscriptSegment("a", TimeSpan(0, 1000), speaker=ME), ... TranscriptSegment("b", TimeSpan(1000, 2000), speaker=THEM))) >>> t.text 'a b' >>> len(t) 2 >>> sorted(t.speakers) ['me', 'them']
- formatted(*, speakers=True, timestamps=True)[source]¶
Render as a human-readable transcript, one line per segment.
- Return type:
- class hearing.types.TranscriptSegment(text, span, channel=Channel.MIXED, speaker=None, confidence=None, words=(), meta=<factory>)[source]¶
Bases:
objectThe data spine — a standoff interval annotation over the audio.
Required fields are
textandspan. Everything else is optional metadata that a concern enriches: STT setstext/span/confidence; capture setschannel; diarization setsspeaker. Segments are frozen — enrich by copying (with_speaker/with_channel), never mutate.>>> seg = TranscriptSegment("hello", TimeSpan(0, 500)) >>> seg.with_speaker(ME).speaker 'me' >>> seg.text 'hello'
- with_channel(channel)[source]¶
Return a copy carrying a channel label (frozen -> copy, don’t mutate).
- Return type:
- class hearing.types.Word(text, span, confidence=None)[source]¶
Bases:
objectOptional word-level timing (WhisperX /
word_timestamps=True).Lets an agent trigger on a keyword mid-utterance instead of waiting for the end of a turn. Purely optional metadata on a
TranscriptSegment.