kcode-speaker-types 0.1.0

Validated shared speaker-classification data types for Kennedy.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# kcode-speaker-types

Validated shared values for speaker-classification package boundaries.

## API

- `FEATURE_COUNT: usize = 35`.
- `Key::parse(&str) -> Result<Key, TypeError>` accepts 1–128 ASCII bytes containing only letters, digits, `.`, `_`, `-`, `/`, or `:`. `Key` exposes its value through `AsRef<str>`.
- `ObjectId::parse(&str) -> Result<ObjectId, TypeError>` accepts exactly eight base64url characters (`A-Z`, `a-z`, `0-9`, `-`, `_`). Pending and other locator forms are invalid. `ObjectId` exposes its value through `AsRef<str>`.
- `FeatureVector::new([u8; 35]) -> Result<FeatureVector, TypeError>` accepts values `0..=100`, except index 11 (`perceived_age`), which accepts `0..=120`. Its order is the frozen Proposed 35-field Gemini speaker schema: indices 0–10 are the behavioral/core fields through `vocal_gender_presentation`, index 11 is `perceived_age`, and indices 12–34 continue through `aspiration_intensity`. The array is available through `AsRef<[u8; 35]>`.
- `FeatureMask::from_bits(u64) -> Result<FeatureMask, TypeError>` requires at least one set bit and permits only bits 0–34. `u64::from(mask)` returns the bits.
- `SegmentRef::validate(&self) -> Result<(), TypeError>` requires `ordinal < segment_count` and `start_ms < end_ms`.

`RecordingKind` has `VoiceNote`, `Meeting`, `Call`, and `Other` variants. `SegmentRef` and `LabeledSample` expose the fields in their Rust definitions; these types and their nested value types support Serde serialization and deserialization.

Validated value representations are private. Deserializing a validated value applies the same checks as its constructor. `SegmentRef` fields remain directly editable, so callers must invoke `validate` after construction or mutation and before use at a receiving boundary. Cross-record consistency and maximum-duration policy require external context and are enforced by register or system boundaries, not this library. Errors are returned as `TypeError`; this library performs no I/O or persistence.