Repository navigation
feat(memos): speaker sampling and per-label embeddings - #1562
Merged
Merged
Conversation
The planner and service phase 3.2 consumes: plan each diarized label's cleanest turns, cut only those ranges with ffmpeg, and embed one 192-d vector per label. Shipped dark: no comparison, no speaker_matches write, no route. SPEAKER_MIN_SECONDS (default 3) is the sampling floor; no caller reads it until 3.2. Refs #1561
…rder The review found the first-speech case used equal starts, so it could not tell time order from input order. Labels are now sorted by their earliest start, and the case lists a later turn first so input order would answer the wrong label. Refs #1561
This was referenced Dec 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1561
Refs #1404
Refs #1400
What
The first half of phase 3's matching, shipped dark: a diarized label's cleanest turns become one 192-d embedding. No comparison, no
speaker_matcheswrite, no route, no processor change — 3.2 injects the sampler and 3.3 owns the precedence.Why a library and not a pipeline. The issue cuts phase 3 into four sessions: 3.1 samples and embeds, 3.2 compares and writes, 3.3 makes
resolveSpeakersread the matches, 3.4 adds usage and cross-workspace tests. Wiring the sampler intomemos.processor.tsnow would ship a worker that computes vectors nobody reads, so this PR ships the two pieces 3.2 needs and proves them alone:planSpeakerSamples(pure) andSpeakerSamplingService.sample(cut + embed), provided and exported byVoiceEmbeddingModule, the module a worker-side matching service will import.The floor and the caps, with their sources.
SPEAKER_MIN_SECONDSdefaults to3: the doc names the key but deliberately fixes no value ("the least voiced audio a label needs before it may be compared at all — not a decision line"), and 3 s matches the 3–10 s turns its real-call paragraph describes; phase 5 re-measures real recordings and may move it, which is why the key is env. The sample cap isSPEAKER_SAMPLE_SECONDS = 20— every probe clip the model was measured on is 20.000 s (§ Chosen model) — andSPEAKER_SAMPLE_MAX_TURNS = 8bounds the ffmpeg calls. Both are constants, not env: another value would silently change what the model sees.Range cuts, not a whole-file decode. A memo may be
MEMO_MAX_MINUTES(120 min); decoding it would hold ~460 MB of float32 and time out the worker. The sampler cuts each planned range with its ownffmpeg -ss … -t …into a throwawayf32lefile at 16 kHz mono, joins the label's ranges in time order, and removes every temp directory on every path. The plan bounds the work at 20 s and eight cuts per label.A skip is not a failure; a missing model is. A cut that fails, or comes back shorter than the transcript claimed (concatenated PCM under
minSeconds × 16000), leaves that label out of the result — it stays unknown, which is the doc's fallback — and one bad label never costs the others. But a missing artifact (available()false) or a failing graph throws: a zero vector would count as a match, and a wrong name is worse than "Speaker 2".voicedSecondsis the planned total (what 3.4 bills and the floor was checked against), never the decoded sample count.The env group.
SPEAKER_files undermemosin the env report besideVOICE_, and the spec pins it: the console's "no key underother" assertion fails otherwise. It is the same feature's knob — a talk about voices in recordings is a memo.The gated cosines. The real case runs only where
~/.hermes/artifacts/voice-1557/exists (CI has no artifact). Locally, three 20 s clips each planned as two "Speaker 1" turns gave one 192-d unit vector each, and:ru_milena_a×ru_milena_b(same speaker)ru_milena_a×ru_chulsky_a(different)ru_milena_b×ru_chulsky_a(different)CI's skip line: the artifact directory is absent on the runner, so
describe.skipIfreports the gated case as skipped there and the pure and fake-cut cases carry the gate; locally it ran and printed the cosines above.Acceptance criteria (3.1)
planSpeakerSamples (#1561) > plans every label above the floor and leaves a short one outtakes the longest turns up to the cap and returns them in time order,trims the turn that reaches the cap,never plans two ranges over the same secondthe real artifact (#1561); cosines aboveskips a label whose decoded audio is under the floor,skips the label whose cut fails; diff touches no processor, schema, route orspeaker_matchesmake verify356 passed (356)files, `5544 passedWhat 3.2 inherits
SpeakerSamplingService.sample(file, segments): Promise<SpeakerSample[]>— one{ label, embedding, voicedSeconds }per surviving label, in first-speech order.SpeakerSampleand the pureplanSpeakerSamples, both exported fromspeaker-sampling.ts.SPEAKER_MIN_SECONDS(env, default 3), read by the service; no caller exists until 3.2 wires it.No schema, migration, enum, route, graph call, processor change,
resolveSpeakerschange or UI.Review
Independent review before opening this PR (spec + work, fresh context): three slices over the committed range, then two spec slices over the test file, then one delta review over the fix.
da9c488dorders labels by their earliest start and lists a later turn first.Mutation checks (each flip restores the file to the same SHA): shortest-first choice reddens
takes the longest turns up to the cap; floor-by-span reddensmeasures the floor by the sum; removing the short-PCM skip reddensskips a label whose decoded audio is under the floor; removing the time-order sort reddensjoins a label's cuts in time order; label order by input reddenskeeps labels in the order they first speak.