知了 Cicada · 任何会议和直播的实时字幕、同声传译、AI 会议纪要,Mac、Windows、Linux、Android 免费开源。Live subtitles, interpreting and meeting notes for any call or stream, on Mac, Windows, Linux and Android.
Swift androidlinuxlive-captionsmacosmeeting-notesmenubar-appsimultaneous-interpretationspeech-recognitionsubtitlesswiftswiftuitranslationwindows
refactor(speakers): keep the five-line rule for typed names; short lines only suggest
wquguru216411fb9eab
diff --git a/Resources/en.lproj/Localizable.strings b/Resources/en.lproj/Localizable.stringsindex 32fe63c..333bc4f 100644--- a/Resources/en.lproj/Localizable.strings+++ b/Resources/en.lproj/Localizable.strings@@ -1476,7 +1476,7 @@"名字" = "Name";"%lld 段样本 · 最近 %@" = "%lld samples · last seen %@";"改名" = "Rename";-"共 %lld 个人" = "%lld people";+"共 %lld 个人" = "%lld saved";"全部删除" = "Delete all";"删除“%@”的声纹?" = "Delete the voiceprint for “%@”?";"之后的会议不会再自动认出这个人;已经生成的记录保持原样。" = "Future meetings won't recognize this person automatically. Existing records stay unchanged.";@@ -1484,8 +1484,8 @@"之后所有会议都不会再自动认出人;已有记录保持原样。" = "All future meetings will stop recognizing people automatically. Existing records stay unchanged.";"还没在新会议里出现" = "Not seen in a new meeting yet";"记住说话人" = "Remember speakers";-"按本机声纹认出以前见过的人;不会上传声音" = "Recognize people you've met by voice, on this Mac; audio is never uploaded";-"%lld 个人" = "%lld people";+"按本机声纹认出以前见过的人;不会上传声音" = "Recognizes people by voice, on this Mac only";+"%lld 个人" = "%lld saved";"管理" = "Manage";"声纹库:可能是 %@(%lld%%)" = "Voice library: possibly %@ (%lld%%)";"声音像,但还不够确定。确认后,下次会议会直接认出。" = "It sounds similar, but isn't certain yet. Confirming makes the next meeting recognize them.";@@ -1503,7 +1503,7 @@"没有可用的录音" = "No usable recording";"打开“保存会议录音”,或用导入的录音文件建立声纹。" = "Turn on Save meeting audio, or use an imported recording to create a voiceprint.";"记住“%@”的声音?" = "Remember the voice of “%@”?";-"声纹只保存在这台 Mac,用于以后会议自动认出这个人;可以随时在声纹库里删除。" = "The voiceprint stays only on this Mac and is used to recognize this person in future meetings. You can delete it from the voice library anytime.";+"请先确认对方知道。声纹只保存在这台 Mac,用于以后会议认出这个人,可随时在声纹库里删除。" = "Make sure they know first. The voiceprint stays only on this Mac, is used to recognize this person in later meetings, and can be deleted from the voice library anytime.";"记住" = "Remember";"不用" = "Not now";"这个声音还不够清楚" = "This voice isn't clear enough";diff --git a/Resources/ja.lproj/Localizable.strings b/Resources/ja.lproj/Localizable.stringsindex 474695a..35e7b32 100644--- a/Resources/ja.lproj/Localizable.strings+++ b/Resources/ja.lproj/Localizable.strings@@ -1503,7 +1503,7 @@"没有可用的录音" = "使用できる録音がありません";"打开“保存会议录音”,或用导入的录音文件建立声纹。" = "「会議音声を保存」をオンにするか、取り込んだ録音から声紋を作成してください。";"记住“%@”的声音?" = "「%@」の声を記憶しますか?";-"声纹只保存在这台 Mac,用于以后会议自动认出这个人;可以随时在声纹库里删除。" = "声紋はこのMacだけに保存され、今後の会議でこの人を認識するために使います。声紋ライブラリからいつでも削除できます。";+"请先确认对方知道。声纹只保存在这台 Mac,用于以后会议认出这个人,可随时在声纹库里删除。" = "まず相手に知らせてください。声紋はこのMacだけに保存され、今後の会議でこの人を認識するために使います。声紋ライブラリからいつでも削除できます。";"记住" = "記憶";"不用" = "今はしない";"这个声音还不够清楚" = "この声は十分に明瞭ではありません";diff --git a/Resources/ko.lproj/Localizable.strings b/Resources/ko.lproj/Localizable.stringsindex ccb5840..0ee7c3c 100644--- a/Resources/ko.lproj/Localizable.strings+++ b/Resources/ko.lproj/Localizable.strings@@ -1503,7 +1503,7 @@"没有可用的录音" = "사용할 수 있는 녹음이 없습니다";"打开“保存会议录音”,或用导入的录音文件建立声纹。" = "'회의 오디오 저장'을 켜거나 가져온 녹음으로 음성 지문을 만드세요.";"记住“%@”的声音?" = "“%@”의 목소리를 기억할까요?";-"声纹只保存在这台 Mac,用于以后会议自动认出这个人;可以随时在声纹库里删除。" = "음성 지문은 이 Mac에만 저장되며 앞으로 이 사람을 인식하는 데 사용됩니다. 음성 지문 보관함에서 언제든지 삭제할 수 있습니다.";+"请先确认对方知道。声纹只保存在这台 Mac,用于以后会议认出这个人,可随时在声纹库里删除。" = "먼저 상대방에게 알려 주세요. 음성 지문은 이 Mac에만 저장되며 앞으로 이 사람을 인식하는 데 사용됩니다. 음성 지문 보관함에서 언제든지 삭제할 수 있습니다.";"记住" = "기억";"不用" = "나중에";"这个声音还不够清楚" = "이 목소리가 충분히 선명하지 않습니다";diff --git a/Resources/zh-Hans.lproj/Localizable.strings b/Resources/zh-Hans.lproj/Localizable.stringsindex 8770cfe..5c0afca 100644--- a/Resources/zh-Hans.lproj/Localizable.strings+++ b/Resources/zh-Hans.lproj/Localizable.strings@@ -1411,7 +1411,7 @@"没有可用的录音" = "没有可用的录音";"打开“保存会议录音”,或用导入的录音文件建立声纹。" = "打开“保存会议录音”,或用导入的录音文件建立声纹。";"记住“%@”的声音?" = "记住“%@”的声音?";-"声纹只保存在这台 Mac,用于以后会议自动认出这个人;可以随时在声纹库里删除。" = "声纹只保存在这台 Mac,用于以后会议自动认出这个人;可以随时在声纹库里删除。";+"请先确认对方知道。声纹只保存在这台 Mac,用于以后会议认出这个人,可随时在声纹库里删除。" = "请先确认对方知道。声纹只保存在这台 Mac,用于以后会议认出这个人,可随时在声纹库里删除。";"记住" = "记住";"不用" = "不用";"这个声音还不够清楚" = "这个声音还不够清楚";diff --git a/Sources/Cicada/SpeakerID.swift b/Sources/Cicada/SpeakerID.swiftindex 884a7cf..f048ad4 100644--- a/Sources/Cicada/SpeakerID.swift+++ b/Sources/Cicada/SpeakerID.swift@@ -260,9 +260,12 @@ enum SpeakerLabels {}/// The voices a meeting already knows by name; `Session.voiceProfiles` is the snapshot.+ /// A name the user typed is not enough by itself: the five-line rule is shared with the ports+ /// and the share document. The exception is a one-to-one call's only voice, which the user named.static func knownVoices(_ s: Session) -> Set<Int> {- Set((s.voiceProfiles ?? [:]).keys.compactMap(Int.init))- .union((s.voiceNames ?? [:]).keys.compactMap(Int.init))+ var known = Set((s.voiceProfiles ?? [:]).keys.compactMap(Int.init))+ if let only = singleVoice(s.lines), let name = s.voiceNames?[String(only)], !name.isEmpty { known.insert(only) }+ return known}static func voiceNumbers(_ s: Session) -> [Int: Int] {@@ -442,9 +445,15 @@ final class SpeakerTagger {}var voice: Int?var matched = profiles?.match(embedding, policy: policy)+ // A short line's voiceprint is unsteady (the clusterer won't start a voice from one+ // either): it may suggest a name, never put one on a voice by itself.+ if let match = matched, match.kind == .auto, seconds < VoiceClusterer.newSeconds {+ matched = SpeakerProfileMatch(profile: match.profile, similarity: match.similarity, kind: .suggested)+ }if let match = matched, match.kind == .auto {if let existing = voiceProfiles.first(where: { $0.value == match.profile.id })?.key {voice = existing+ clusterer.adopt(embedding, into: existing)matched = nil // already named in this meeting} else if let nearby = clusterer.closest(to: match.profile.embedding, minimum: VoiceClusterer.join),let bound = voiceProfiles[nearby] {@@ -456,7 +465,10 @@ final class SpeakerTagger {} else {let nearby = clusterer.closest(to: match.profile.embedding, minimum: VoiceClusterer.join)voice = nearby ?? clusterer.seed(match.profile.embedding)- if let voice { voiceProfiles[voice] = match.profile.id }+ if let voice {+ voiceProfiles[voice] = match.profile.id+ clusterer.adopt(embedding, into: voice) // this line counts towards it too+ }}} else {voice = clusterer.label(embedding, seconds: seconds)diff --git a/Sources/Cicada/SpeakerProfiles.swift b/Sources/Cicada/SpeakerProfiles.swiftindex f1b78cb..74c8297 100644--- a/Sources/Cicada/SpeakerProfiles.swift+++ b/Sources/Cicada/SpeakerProfiles.swift@@ -11,7 +11,7 @@ struct SpeakerProfile: Codable, Identifiable, Equatable {var createdAt: Datevar updatedAt: Datevar lastSeenAt: Date?- /// When the user agreed to keep this voice. Absent for a profile made before this field existed.+ /// When the user agreed to keep this voice (the 记住 alert).var consentAt: Date?/// Notes the user keeps about this person: company, role, what to remember.var notes: String? = nil@@ -123,7 +123,6 @@ final class SpeakerProfileStore: @unchecked Sendable {cached = Self.load(from: url)try? Self.protectDirectory(url.deletingLastPathComponent())try? Self.protectFile(url)- for p in cached where p.consentAt == nil { try? markConsent(p.id, at: p.createdAt) }}func all() -> [SpeakerProfile] {@@ -245,12 +244,6 @@ final class SpeakerProfileStore: @unchecked Sendable {}}- private func markConsent(_ id: UUID, at date: Date) throws {- mutate { profiles in- guard let i = profiles.firstIndex(where: { $0.id == id }), profiles[i].consentAt == nil else { return }- profiles[i].consentAt = date- }- }private func mutate(_ change: (inout [SpeakerProfile]) -> Void) {lock.lock()diff --git a/Tests/CicadaTests/SpeakerProfileTests.swift b/Tests/CicadaTests/SpeakerProfileTests.swiftindex 51018a1..7a4a0c8 100644--- a/Tests/CicadaTests/SpeakerProfileTests.swift+++ b/Tests/CicadaTests/SpeakerProfileTests.swift@@ -70,6 +70,20 @@ import Testing#expect(SpeakerLabels.names(s) == [1: "张总"])}+ /// A typed name alone keeps the five-line rule (the share document and the ports rely on it),+ /// except for a one-to-one call's only voice.+ @Test func aTypedNameDoesNotSkipTheFiveLineRule() {+ func line(_ id: String, _ voice: Int) -> TranscriptLine {+ TranscriptLine(id: id, t: 1, speaker: "them", src: "我们周四上线", dst: nil, srcLang: "zh-CN", dstLang: "en", voice: voice)+ }+ var s = Session(id: "s", title: "t", startedAt: Date(), endedAt: nil, lines: [line("a", 1), line("b", 2)],+ hasAudio: false, notes: nil, voiceNames: ["2": "Kenji"])+ #expect(SpeakerLabels.numbers(s).isEmpty)+ s.lines = [line("a", 2)]+ #expect(SpeakerLabels.numbers(s) == ["a": 1])+ #expect(SpeakerLabels.names(s) == [1: "Kenji"])+ }+@Test func oldSessionJSONStillDecodes() throws {let json = """{"id":"old","title":"会议","startedAt":"2026-01-01T00:00:00Z","lines":[],"hasAudio":false}