Phases 2-6: detection, visual timeline, backend hand-off, voiceprints

Phase 2 (call detection): CallDetector using CoreAudio per-process mic
attribution (anarlog technique) — robust start+stop for Zoom/Teams/Signal/Meet,
ignoring our own recording; auto-record toggle. Built; pending live multi-app
confirmation by the user.

Phase 3 (visual timeline foundation): AppAdapter protocol + SpeakerObservation,
TimelineBuilder (hysteresis/overlap/self-merge/aliases), VisualTimeline (schema
1.1), TextRecognizer (Vision OCR), FrameSampler + GridCallAnalyzer (name OCR +
saturated-highlight active-speaker attribution), SignalAdapter, VisualObserver
(window capture; frames released, never saved; minimized->visual_gap, idle != gap).
Synthetic-frame tested; adapter geometry pending real Signal fixtures + live
VisualObserver validation.

Phase 5 (backend hand-off): SparkControlClient (multipart label-merge, sequential,
TLS-skip, 503 Retry-After/413), SessionPackager (chunk plan + WAV slice + timeline
slice/rebase), TranscriptAssembler + SpeakersFile, TranscriptPipeline. Validated
END-TO-END against the live backend (chunk -> label-merge -> speakers.json).

Phase 6 (voiceprints): VoiceprintStore (known_voiceprints, persist named
fingerprints, skip Unknown). Wired: 'Send to backend' button + transcript status,
auto-send toggle (default off) + self-name setting.

All adversarial-review findings fixed. App + XCTest suite build; tests pass.
This commit is contained in:
Grant Gilliam
2026-06-06 00:15:49 -05:00
parent fd7e1a5907
commit 863136aeec
27 changed files with 2108 additions and 22 deletions
@@ -0,0 +1,62 @@
import XCTest
import CoreGraphics
import CoreText
@testable import Ten31Transcripts
/// Validates the visual adapter against synthetic call frames (no real
/// screenshots needed): OCR anchors the tiles and the highlight is attributed to
/// the correct speaker, tracking it as it moves.
final class GridCallAnalyzerTests: XCTestCase {
private func drawText(_ s: String, _ ctx: CGContext, center: CGPoint, size: CGFloat) {
let font = CTFontCreateWithName("Helvetica-Bold" as CFString, size, nil)
let attrs = [kCTFontAttributeName: font,
kCTForegroundColorAttributeName: CGColor(red: 1, green: 1, blue: 1, alpha: 1)] as CFDictionary
let line = CTLineCreateWithAttributedString(CFAttributedStringCreate(nil, s as CFString, attrs)!)
let b = CTLineGetBoundsWithOptions(line, [])
ctx.textPosition = CGPoint(x: center.x - b.width / 2, y: center.y - b.height / 2)
CTLineDraw(line, ctx)
}
private func frame(speakingIndex: Int) -> CGImage {
let W = 800, H = 600
let ctx = CGContext(data: nil, width: W, height: H, bitsPerComponent: 8, bytesPerRow: 0,
space: CGColorSpaceCreateDeviceRGB(),
bitmapInfo: CGImageAlphaInfo.premultipliedLast.rawValue)!
ctx.setFillColor(CGColor(red: 0.1, green: 0.1, blue: 0.12, alpha: 1))
ctx.fill(CGRect(x: 0, y: 0, width: W, height: H))
let rects: [(String, CGRect)] = [
("GRANT", CGRect(x: 40, y: 320, width: 340, height: 230)),
("SARAH", CGRect(x: 420, y: 320, width: 340, height: 230)),
("DMITRI", CGRect(x: 40, y: 50, width: 340, height: 230)),
("ALEX", CGRect(x: 420, y: 50, width: 340, height: 230)),
]
for (i, (name, rect)) in rects.enumerated() {
ctx.setFillColor(CGColor(red: 0.18, green: 0.18, blue: 0.2, alpha: 1)); ctx.fill(rect)
if i == speakingIndex {
ctx.setStrokeColor(CGColor(red: 0.1, green: 0.85, blue: 0.2, alpha: 1)); ctx.setLineWidth(14)
ctx.stroke(rect.insetBy(dx: 7, dy: 7))
}
drawText(name, ctx, center: CGPoint(x: rect.midX, y: rect.midY), size: 54)
}
return ctx.makeImage()!
}
func testReadsNamesAndPicksHighlightedSpeaker() {
let obs = SignalAdapter().analyze(cgImage: frame(speakingIndex: 1), at: 0) // SARAH
XCTAssertGreaterThanOrEqual(obs.count, 2)
let speaking = obs.filter { $0.speaking }
XCTAssertEqual(speaking.count, 1)
// SARAH tile center in top-left pixels (590, 165)
XCTAssertEqual(speaking.first?.bbox.midX ?? 0, 590, accuracy: 160)
XCTAssertEqual(speaking.first?.bbox.midY ?? 0, 165, accuracy: 160)
}
func testHighlightTracksToAnotherTile() {
let obs = SignalAdapter().analyze(cgImage: frame(speakingIndex: 2), at: 1) // DMITRI
let speaking = obs.filter { $0.speaking }
XCTAssertEqual(speaking.count, 1)
XCTAssertEqual(speaking.first?.bbox.midX ?? 0, 210, accuracy: 160)
XCTAssertEqual(speaking.first?.bbox.midY ?? 0, 435, accuracy: 160)
}
}