Speaker corrections: rename / merge / reassign + voice learning
Native editor to fix speaker-ID errors after transcription (modeled on recap-relay's correction UX): rename a speaker in the legend, merge two speakers, or reassign an individual transcript line. Saving rewrites speakers.json, re-renders transcript.md + recap.html, and updates the voiceprint memory — so a correction compounds: naming an "Unknown" speaker teaches that voice for future calls. - SpeakerEditing (pure, tested): replaceSpeaker (rename = merge-onto-existing), reassign, netNameMap (compose ops), and remap (apply a name map to a recap's structured fields + whole-word free text, so summaries/extras update without re-LLM). - RecapEditModel (@MainActor): loads speakers.json (+ optional recap.json + cluster_fingerprints.json); on save writes the resolved speakers.json, re-renders, and reconciles voiceprints — merge keeps the survivor's print; rename/name-an-Unknown enrolls the cluster's fingerprint under the new name. - TranscriptEditorView (SwiftUI) + EditorWindow (AppKit window for the LSUIElement app); menu gains "Edit speakers". - Pipeline now persists cluster_fingerprints.json (every cluster incl. Unknown) and recap.json (RecapFile) so the editor can learn voices + re-render offline. - RecapModels made Codable; TranscriptAssembler exposes allFingerprints; VoiceprintStore gains enroll() + merge(). 52/52 XCTest (6 new, incl. a full rename→artifacts→voiceprint round-trip on disk).
This commit is contained in:
@@ -2,7 +2,7 @@ import Foundation
|
||||
|
||||
/// One topic section: a contiguous run of transcript entries `[startIndex...endIndex]`
|
||||
/// (inclusive, indices into the canonical entries array) with an LLM title + summary.
|
||||
struct TopicSection: Equatable {
|
||||
struct TopicSection: Equatable, Codable {
|
||||
var title: String
|
||||
var summary: String
|
||||
var startIndex: Int
|
||||
@@ -12,12 +12,12 @@ struct TopicSection: Equatable {
|
||||
/// Structured "meeting extras" extracted from the named transcript. Mirrors
|
||||
/// recap-relay's schema; speakers are real names (we already have them from
|
||||
/// label-merge), not anonymous cluster ids.
|
||||
struct MeetingExtras: Equatable {
|
||||
struct TLDR: Equatable { var summary: String; var primarySpeakers: [String] }
|
||||
struct Decision: Equatable { var statement: String; var agreedBy: [String]; var supportingOffset: Int? }
|
||||
struct ActionItem: Equatable { var description: String; var owner: String?; var dueHint: String?; var supportingOffset: Int? }
|
||||
struct OpenQuestion: Equatable { var question: String; var raisedBy: String? }
|
||||
struct KeyQuote: Equatable { var speaker: String?; var offset: Int?; var quote: String; var whyNotable: String }
|
||||
struct MeetingExtras: Equatable, Codable {
|
||||
struct TLDR: Equatable, Codable { var summary: String; var primarySpeakers: [String] }
|
||||
struct Decision: Equatable, Codable { var statement: String; var agreedBy: [String]; var supportingOffset: Int? }
|
||||
struct ActionItem: Equatable, Codable { var description: String; var owner: String?; var dueHint: String?; var supportingOffset: Int? }
|
||||
struct OpenQuestion: Equatable, Codable { var question: String; var raisedBy: String? }
|
||||
struct KeyQuote: Equatable, Codable { var speaker: String?; var offset: Int?; var quote: String; var whyNotable: String }
|
||||
|
||||
var tldr: TLDR
|
||||
var decisions: [Decision]
|
||||
@@ -32,7 +32,24 @@ struct MeetingExtras: Equatable {
|
||||
|
||||
/// The assembled recap for one session: the topic sections + (optional) extras,
|
||||
/// over the session's transcript. Rendered to `transcript.md` / `recap.html`.
|
||||
struct RecapResult: Equatable {
|
||||
struct RecapResult: Equatable, Codable {
|
||||
var sections: [TopicSection]
|
||||
var extras: MeetingExtras?
|
||||
}
|
||||
|
||||
/// Persisted `recap.json` — the recap result plus its title, so the speaker editor
|
||||
/// can re-render `recap.html` / `transcript.md` after corrections without re-calling
|
||||
/// the LLM (a "Regenerate" action re-runs analysis when the user wants fresh summaries).
|
||||
struct RecapFile: Equatable, Codable {
|
||||
var title: String
|
||||
var result: RecapResult
|
||||
|
||||
func write(to url: URL) throws {
|
||||
let enc = JSONEncoder(); enc.outputFormatting = [.prettyPrinted, .sortedKeys]
|
||||
try enc.encode(self).write(to: url)
|
||||
}
|
||||
static func read(from url: URL) -> RecapFile? {
|
||||
guard let data = try? Data(contentsOf: url) else { return nil }
|
||||
return try? JSONDecoder().decode(RecapFile.self, from: data)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user