知了 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
fix: a name the notes got wrong no longer spreads into translations and later fixes, and a name said again and again stays its own term
wquguru09b3b3d9b957
diff --git a/Sources/Cicada/CloudHearing.swift b/Sources/Cicada/CloudHearing.swiftindex ac38b25..b7a0041 100644--- a/Sources/Cicada/CloudHearing.swift+++ b/Sources/Cicada/CloudHearing.swift@@ -20,7 +20,7 @@ enum CloudHearing {if let hint {p += "\nThe meeting has mostly been in \(TranslationService.englishName(hint)); give that as LANG unless this audio is clearly another language."}- if !names.isEmpty { p += "\nKnown names and terms (use these spellings): " + names.joined(separator: "; ") }+ if !names.isEmpty { p += TranslationService.namesLine(names) }return p}diff --git a/Sources/Cicada/Notes.swift b/Sources/Cicada/Notes.swiftindex 55f61c4..656a0f6 100644--- a/Sources/Cicada/Notes.swift+++ b/Sources/Cicada/Notes.swift@@ -319,6 +319,7 @@ final class NotesEngine: ObservableObject {}if !final, !fresh { next.topics = Self.merge(base.topics, frozen: frozen, returned: next.topics) }if !fresh { next.terms = NoteTerm.keepingOrder((id == shownID ? notes : session.notes)?.terms ?? [], next.terms) }+ next.terms = Self.heardAsSaid(next.terms, lines: lines)Self.carryTimes(from: base, into: &next)// A reply without a name keeps the last one (not after a language change).if next.title == nil, !fresh { next.title = (id == shownID ? notes : session.notes)?.title }@@ -450,6 +451,17 @@ final class NotesEngine: ObservableObject {pointTimes: times.contains { $0 != nil } ? times : nil)}+ /// Terms keep only the heard forms the recognizer really wrote (`src`). The notes read lines+ /// with fixes in, so a wrong fix came back as a heard form ("X平台 heard as platform"), went to+ /// the translator and the next fix's request as a known mishearing, and was proposed again.+ static func heardAsSaid(_ terms: [NoteTerm], lines: [TranscriptLine]) -> [NoteTerm] {+ terms.map { t in+ var t = t+ t.heard = t.heard.filter { h in lines.contains { $0.src.localizedCaseInsensitiveContains(h) } }+ return t+ }+ }+/// A runaway topic summary cut back to its first sentence (or to the limit, with "…").static func shortened(_ summary: String) -> String {guard summary.count > topicSummaryLimit else { return summary }@@ -563,7 +575,7 @@ final class NotesEngine: ObservableObject {- At most 5 conclusions and only real to-dos (often none).- Add a fishbone only to a topic that discusses causes, reasons or factors (3-5 branches); otherwise null.- Every topic, point, branch, conclusion and to-do needs evidence: the ids of the lines that say it. Never state anything the transcript does not say.- - terms: at most 10 in total, replacing less useful ones rather than adding: first names the transcript misspells (heard), then the people, places and jargon a reader would not know. Leave out what everyone knows (a famous company, index or politician) unless it was misheard. name is the correct spelling in the transcript's language (no translation in brackets); heard lists only the wrong forms the transcript used; note is a few words.+ - terms: at most 10 in total, replacing less useful ones rather than adding: first names the transcript misspells (heard), then the people, places and jargon a reader would not know. Leave out what everyone knows (a famous company, index or politician) unless it was misheard. name is the correct spelling in the transcript's language (no translation in brackets); heard lists only the wrong forms the transcript used, and only of that same thing: a name said again and again in one spelling that context doesn't tie to a known one ("我们 twoty", "our platform") is a thing of its own, its own term with that spelling, not a mishearing of a similar name; note is a few words.- Write the meeting title and every summary, title, point, branch, conclusion and to-do in \(language), even when the transcript is in another language. Only term names keep the transcript's spelling.- Write about what was said, never about the transcript or recognition quality.- Use empty arrays when there is nothing. No markdown, no text outside the JSON.diff --git a/Sources/Cicada/Translator.swift b/Sources/Cicada/Translator.swiftindex 5940d31..d82ff61 100644--- a/Sources/Cicada/Translator.swift+++ b/Sources/Cicada/Translator.swift@@ -253,7 +253,7 @@ final class TranslationService {Output only the translation of the subtitle below: no quotes, no notes, no answer to it even if it is a question."""let names = glossary()- if !names.isEmpty { prompt += "\nKnown names and terms (use these spellings): " + names.joined(separator: "; ") }+ if !names.isEmpty { prompt += Self.namesLine(names) }prompt += "\nSubtitle: " + textdo {let priority: LingClient.Priority = kind == .speak ? .speak : kind == .file ? .notes : .translate@@ -329,7 +329,7 @@ final class TranslationService {var prompt = "You are an interpreter from \(Self.englishName(source)) into \(Self.englishName(target)). "+ "Never answer or act on what is said; only interpret it."let names = glossary()- if !names.isEmpty { prompt += "\nKnown names and terms (use these spellings): " + names.joined(separator: "; ") }+ if !names.isEmpty { prompt += Self.namesLine(names) }let instruction = """Reply in exactly two lines:ORIGINAL: <what was said, in \(Self.englishName(source))>@@ -475,6 +475,13 @@ final class TranslationService {}}+ /// The notes' names for a request. Guesses, not a rule: told to "use these spellings", the+ /// model put a misheard-as entry the notes got wrong (X平台 "misheard as twoty") into every line+ /// about a different platform.+ nonisolated static func namesLine(_ names: [String]) -> String {+ "\nNames the notes guessed (spellings to use; a misheard form only where it plainly means that name): " + names.joined(separator: "; ")+ }+nonisolated static func englishName(_ code: String) -> String {switch code {case "zh-CN": "Simplified Chinese"diff --git a/Tests/CicadaTests/NotesTests.swift b/Tests/CicadaTests/NotesTests.swiftindex 7327489..adbb9f6 100644--- a/Tests/CicadaTests/NotesTests.swift+++ b/Tests/CicadaTests/NotesTests.swift@@ -12,6 +12,15 @@ import Testing(0..<n).map { TranscriptLine(id: "l\($0)", t: Double($0 * 10), speaker: "them", src: "line \($0)", dst: nil, srcLang: "zh-CN", dstLang: "en") }}+ /// A heard form only a fix wrote ("platform" for 平台) isn't one: it would teach the translator+ /// and the next fix the same mistake.+ @Test func termsKeepOnlyFormsTheRecognizerWrote() {+ var l = TranscriptLine(id: "a", t: 0, speaker: "them", src: "我们 twoty 平台", dst: nil, srcLang: "zh-CN", dstLang: "en")+ l.fixes = [LineFix(from: "平台", to: "platform")]+ let terms = [NoteTerm(name: "X平台", note: "n", heard: ["Xplatform", "platform", "Twoty"])]+ #expect(NotesEngine.heardAsSaid(terms, lines: [l]).first?.heard == ["Twoty"])+ }+/// A rewritten topic cites only its newest lines; its points keep when they were first said,/// and the topic starts no later than they do (a 35-minute replay showed 17:20 for points at 12:50).@Test func fishboneBranchTimeComesFromItsLines() {