知了 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(android): meeting records from the Mac keep their fixed words, and show, search and export the fixed text
wquguru481ef8d0900a
diff --git a/android/app/src/main/kotlin/com/wquguru/cicada/FaceActivity.kt b/android/app/src/main/kotlin/com/wquguru/cicada/FaceActivity.ktindex 1f50e33..93821b1 100644--- a/android/app/src/main/kotlin/com/wquguru/cicada/FaceActivity.kt+++ b/android/app/src/main/kotlin/com/wquguru/cicada/FaceActivity.kt@@ -113,17 +113,17 @@ class FaceActivity : Activity() {val their = l.theirLanguageval mineLang = app.settings.targetCodeval line: TranscriptLine? = NotesViews.currentLines(app).lastOrNull()- val key = listOf(line?.id, line?.src, line?.dst, l.holding, l.saying, app.voice.speaking, l.sayProblem, their).joinToString("|")+ val key = listOf(line?.id, line?.shown, line?.dst, l.holding, l.saying, app.voice.speaking, l.sayProblem, their).joinToString("|")if (key == shown) returnshown = key// What each side reads, in their own language.val mine = line?.speaker == "me"- val translated = line?.dst?.takeIf { it.isNotEmpty() && it != line.src }+ val translated = line?.dst?.takeIf { it.isNotEmpty() && it != line.shown }theirLabel.text = NotesViews.languageName(their)- theirText.text = when { line == null -> "…"; mine -> translated ?: "…"; else -> line.src }+ theirText.text = when { line == null -> "…"; mine -> translated ?: "…"; else -> line.shown }// My line was said with 我说: the other side heard its translation (同传, as on the Mac).myLabel.text = (if (mine) L("你 · 同传") else if (line == null) L("你") else L("对方")) + " · " + NotesViews.languageName(mineLang)- myText.text = when { line == null -> L("按住下面的按钮说话,松开后对方会听到译文"); mine -> line.src; else -> translated ?: line.src }+ myText.text = when { line == null -> L("按住下面的按钮说话,松开后对方会听到译文"); mine -> line.shown; else -> translated ?: line.shown }myText.setTextColor(if (line == null) Palette.secondary else Palette.ink)val live = l.holding || app.voice.speakingstatus.text = l.sayProblem ?: when {diff --git a/android/app/src/main/kotlin/com/wquguru/cicada/ListenService.kt b/android/app/src/main/kotlin/com/wquguru/cicada/ListenService.ktindex 1a1c329..5d31d64 100644--- a/android/app/src/main/kotlin/com/wquguru/cicada/ListenService.kt+++ b/android/app/src/main/kotlin/com/wquguru/cicada/ListenService.kt@@ -108,7 +108,7 @@ class ListenService : Service() {else -> L("知了 · 正在听手机里的声音")}val text = if (file != null) "${cicada.Languages.clock(file.done)} / ${cicada.Languages.clock(file.total)}"- else if (ending != null) app.endingDetail(ending) else blocking ?: listen.problem ?: line?.let { it.dst ?: it.src } ?: L("等有人说话…")+ else if (ending != null) app.endingDetail(ending) else blocking ?: listen.problem ?: line?.let { it.dst ?: it.shown } ?: L("等有人说话…")val b = Notification.Builder(context, CHANNEL).setSmallIcon(R.drawable.ic_notification).setContentTitle(title)@@ -141,7 +141,7 @@ class ListenService : Service() {fun refresh(context: Context) {val app = context.cicadaif (!app.listen.listening || (app.listen.sourceKind == "file" && app.importing == null)) { lastText = null; return }- val text = app.importing?.let { "${it.done.toInt()}" } + app.listen.sessionId?.let { app.store.lines(it).lastOrNull()?.let { l -> l.dst ?: l.src } } + "|" + app.listen.problem ++ val text = app.importing?.let { "${it.done.toInt()}" } + app.listen.sessionId?.let { app.store.lines(it).lastOrNull()?.let { l -> l.dst ?: l.shown } } + "|" + app.listen.problem +"|" + app.ling.blocking + "|" + app.ending?.let { app.endingLeft(it) }if (text == lastText) returnlastText = textdiff --git a/android/app/src/main/kotlin/com/wquguru/cicada/MainActivity.kt b/android/app/src/main/kotlin/com/wquguru/cicada/MainActivity.ktindex dae1de3..c8552a5 100644--- a/android/app/src/main/kotlin/com/wquguru/cicada/MainActivity.kt+++ b/android/app/src/main/kotlin/com/wquguru/cicada/MainActivity.kt@@ -110,7 +110,7 @@ class MainActivity : Activity() {clockText = statusval card = ui.card(ui.row(8, ui.dot(Palette.accent), status), gap = 12)card.addView(ui.helper(NotesViews.sourceLine(app)), ui.lp(top = 4))- NotesViews.currentLines(app).lastOrNull()?.let { l -> card.addView(ui.text(l.dst ?: l.src, 18f, Palette.ink, bold = true, lines = 3).apply { leading(1.4f) }, ui.lp(top = 12)) }+ NotesViews.currentLines(app).lastOrNull()?.let { l -> card.addView(ui.text(l.dst ?: l.shown, 18f, Palette.ink, bold = true, lines = 3).apply { leading(1.4f) }, ui.lp(top = 12)) }card.addView(ui.button(L("回到正在听"), "primary", R.drawable.i_waves) { app.openLive() }, ui.lp(top = 16))return card}diff --git a/android/app/src/main/kotlin/com/wquguru/cicada/NotesViews.kt b/android/app/src/main/kotlin/com/wquguru/cicada/NotesViews.ktindex 426b1b2..9093c41 100644--- a/android/app/src/main/kotlin/com/wquguru/cicada/NotesViews.kt+++ b/android/app/src/main/kotlin/com/wquguru/cicada/NotesViews.kt@@ -30,7 +30,7 @@ object NotesViews {val listen = app.listenval line = listen.sessionId?.let { app.store.lines(it).lastOrNull() }return listOf(listen.listening, listen.sourceKind, listen.sessionId, listen.pending > 0, listen.problem, app.startProblem, silent(app), app.micSilenced,- line?.id, line?.src, line?.dst, app.notes.status, app.notes.notes.updatedAt, app.notes.notes.covered,+ line?.id, line?.shown, line?.dst, app.notes.status, app.notes.notes.updatedAt, app.notes.notes.covered,app.ending?.deadline, app.ling.blocking, listen.problemKind, app.ling.provider.id, customOnlyUntranslated(app)).joinToString("|")}@@ -210,9 +210,9 @@ object NotesViews {// An initial only for someone known (你, a numbered or named voice); 对方 has no face.val head = ui.text("$who · ${Languages.clock(line.t)}", 12f, Palette.secondary, lines = 1)card.addView(if (line.speaker == "me" || numbers[line.id] != null) ui.row(8, avatar(ui, line, numbers, who), head) else head)- val translated = !line.dst.isNullOrEmpty() && line.dst != line.src- if (translated) card.addView(ui.text(line.src, Ui.Type.ORIGINAL, Palette.secondary).apply { leading(1.45f) })- card.addView(ui.text(line.dst?.takeIf { translated } ?: line.src, Ui.Type.TRANSLATION, Palette.ink).apply { leading(1.5f) })+ val translated = !line.dst.isNullOrEmpty() && line.dst != line.shown+ if (translated) card.addView(ui.text(line.shown, Ui.Type.ORIGINAL, Palette.secondary).apply { leading(1.45f) })+ card.addView(ui.text(line.dst?.takeIf { translated } ?: line.shown, Ui.Type.TRANSLATION, Palette.ink).apply { leading(1.5f) })if (newest) card.accessibilityLiveRegion = View.ACCESSIBILITY_LIVE_REGION_POLITEreturn card}@@ -252,7 +252,7 @@ object NotesViews {}for (l in lines.dropLast(1).takeLast(earlier)) {val texts = ui.stack(2, ui.text(said(l), 13f, Palette.secondary))- if (!l.dst.isNullOrEmpty() && l.dst != l.src) texts.addView(ui.text(l.dst!!, 16f, Palette.ink), ui.lp(top = 2))+ if (!l.dst.isNullOrEmpty() && l.dst != l.shown) texts.addView(ui.text(l.dst!!, 16f, Palette.ink), ui.lp(top = 2))box.addView(LinearLayout(ui.context).apply {orientation = LinearLayout.HORIZONTALaddView(ui.text(Languages.clock(l.t), 12f, Palette.secondary, bold = true), LinearLayout.LayoutParams(-2, -2).apply { topMargin = ui.dp(1); rightMargin = ui.dp(10) })@@ -265,17 +265,17 @@ object NotesViews {/// The newest line as a card, with the "still listening" dots under it./// The original as shown above its translation: mine is marked, so it's clear who said it.- fun said(l: TranscriptLine) = if (l.speaker == "me") L("你 · 同传") + " · " + l.src else l.src+ fun said(l: TranscriptLine) = if (l.speaker == "me") L("你 · 同传") + " · " + l.shown else l.shownfun liveCard(ui: Ui, app: CicadaApp, line: TranscriptLine, big: Float, bg: Int = Palette.card, lines: Int = 0, dots: Boolean = true): LinearLayout {val card = ui.stack(0)card.background = ui.rounded(bg, 20)card.setPadding(ui.dp(18), ui.dp(16), ui.dp(18), ui.dp(16))card.accessibilityLiveRegion = View.ACCESSIBILITY_LIVE_REGION_POLITE- val translated = !line.dst.isNullOrEmpty() && line.dst != line.src+ val translated = !line.dst.isNullOrEmpty() && line.dst != line.shownif (!translated && line.speaker == "me") card.addView(ui.text(L("你 · 同传"), 14f, Palette.secondary))if (translated) card.addView(ui.text(said(line), 14f, Palette.secondary, lines = if (lines > 0) lines - 1 else 0))- card.addView(ui.text(line.dst ?: line.src, big, Palette.ink, bold = true, lines = lines).apply { leading(1.25f) }, ui.lp(top = if (translated || line.speaker == "me") 8 else 0))+ card.addView(ui.text(line.dst ?: line.shown, big, Palette.ink, bold = true, lines = lines).apply { leading(1.25f) }, ui.lp(top = if (translated || line.speaker == "me") 8 else 0))if (dots && app.listen.listening) card.addView(LinearLayout(ui.context).apply {orientation = LinearLayout.HORIZONTALgravity = Gravity.CENTER_VERTICALdiff --git a/android/app/src/main/kotlin/com/wquguru/cicada/OnboardingActivity.kt b/android/app/src/main/kotlin/com/wquguru/cicada/OnboardingActivity.ktindex a41a2e1..862add4 100644--- a/android/app/src/main/kotlin/com/wquguru/cicada/OnboardingActivity.kt+++ b/android/app/src/main/kotlin/com/wquguru/cicada/OnboardingActivity.kt@@ -409,7 +409,7 @@ class OnboardingActivity : Activity() {// apart, and showing only the newest made the first one flash by.lines.dropLast(1).takeLast(2).forEachIndexed { i, l ->val row = ui.stack(2, ui.text(NotesViews.said(l), 13f, Palette.secondary))- if (!l.dst.isNullOrEmpty() && l.dst != l.src) row.addView(ui.text(l.dst!!, 15f, Palette.ink))+ if (!l.dst.isNullOrEmpty() && l.dst != l.shown) row.addView(ui.text(l.dst!!, 15f, Palette.ink))card.addView(row, 1 + i, ui.lp(top = 10))}content.addView(card, ui.lp(top = 12))diff --git a/android/app/src/main/kotlin/com/wquguru/cicada/Overlay.kt b/android/app/src/main/kotlin/com/wquguru/cicada/Overlay.ktindex 501daab..a6be199 100644--- a/android/app/src/main/kotlin/com/wquguru/cicada/Overlay.kt+++ b/android/app/src/main/kotlin/com/wquguru/cicada/Overlay.kt@@ -332,9 +332,9 @@ class Overlay(private val app: CicadaApp) {dark -> {val col = ui.stack(4)// My line (我说) says so, as the Mac's subtitle bar does.- if (!line.dst.isNullOrEmpty() && line.dst != line.src) col.addView(ui.text(NotesViews.said(line), 13f, Palette.onScrim, lines = 2))+ if (!line.dst.isNullOrEmpty() && line.dst != line.shown) col.addView(ui.text(NotesViews.said(line), 13f, Palette.onScrim, lines = 2))else if (line.speaker == "me") col.addView(ui.text(L("你 · 同传"), 13f, Palette.onScrim))- col.addView(ui.text(line.dst ?: line.src, 20f, Color.WHITE, bold = true, lines = 3).apply { leading(1.2f) })+ col.addView(ui.text(line.dst ?: line.shown, 20f, Color.WHITE, bold = true, lines = 3).apply { leading(1.2f) })box.addView(col)}else -> box.addView(NotesViews.liveCard(ui, app, line, 18f, Palette.ground, lines = 3, dots = false).apply { setPadding(ui.dp(14), ui.dp(12), ui.dp(14), ui.dp(12)) })diff --git a/android/app/src/main/kotlin/com/wquguru/cicada/RecordsActivity.kt b/android/app/src/main/kotlin/com/wquguru/cicada/RecordsActivity.ktindex bcc8863..2d29b0e 100644--- a/android/app/src/main/kotlin/com/wquguru/cicada/RecordsActivity.kt+++ b/android/app/src/main/kotlin/com/wquguru/cicada/RecordsActivity.kt@@ -84,7 +84,7 @@ class RecordsActivity : Activity() {val q = query.lowercase()return SessionStore.displayTitle(s).lowercase().contains(q) ||s.notes?.let { n -> (n.summary + n.topics.joinToString { it.title + it.points.joinToString() } + n.terms.joinToString { it.name }).lowercase().contains(q) } == true ||- s.lines.any { it.src.lowercase().contains(q) || it.dst?.lowercase()?.contains(q) == true }+ s.lines.any { it.shown.lowercase().contains(q) || it.dst?.lowercase()?.contains(q) == true }}private fun render() {@@ -371,9 +371,9 @@ class RecordActivity : Activity() {visibility = if (who) View.VISIBLE else View.GONEsetTextColor(if (l.speaker == "me") Palette.ink else NotesViews.voiceColor(numbers[l.id]).second.takeIf { numbers[l.id] != null } ?: Palette.secondary)}- val translated = !l.dst.isNullOrEmpty() && l.dst != l.src- (texts.getChildAt(1) as TextView).apply { text = l.src; visibility = if (translated) View.VISIBLE else View.GONE }- (texts.getChildAt(2) as TextView).text = if (translated) l.dst else l.src+ val translated = !l.dst.isNullOrEmpty() && l.dst != l.shown+ (texts.getChildAt(1) as TextView).apply { text = l.shown; visibility = if (translated) View.VISIBLE else View.GONE }+ (texts.getChildAt(2) as TextView).text = if (translated) l.dst else l.shownreturn row}}diff --git a/android/cli/src/main/kotlin/cicada/cli/FixTests.kt b/android/cli/src/main/kotlin/cicada/cli/FixTests.ktnew file mode 100644index 0000000..8a11451--- /dev/null+++ b/android/cli/src/main/kotlin/cicada/cli/FixTests.kt@@ -0,0 +1,114 @@+// 改正听错的词: the Mac's CorrectionTests, VocabularyTests and LiveFixesTests (cases from a+// 21-minute meeting recording), and records with fixes read and written as the Mac does.+package cicada.cli++import cicada.*++object FixTests {+ val tests: List<Pair<String, () -> Unit>> = listOf(+ "fixesReadAndWrittenLikeTheMac" to ::recordWithFixes,+ "recordFormatUnchangedWithoutFixes" to ::recordFormatUnchangedWithoutFixes,+ "exportsShowTheFixedText" to ::exportsShowTheFixedText,+ "applyReplacesAndMarks" to ::applyReplacesAndMarks,+ "applyKeepsEarlierMarksWhenLaterFixesShift" to ::applyKeepsEarlierMarks,+ "fixWhoseWordsWentAwayIsSkipped" to ::fixWhoseWordsWentAwayIsSkipped,+ )++ private fun check(ok: Boolean, what: String) { if (!ok) throw AssertionError(what) }+ private fun <T> equal(expected: T, actual: T, what: String) { if (expected != actual) throw AssertionError("$what: expected «$expected», got «$actual»") }++ // MARK: Records++ /// As the Mac writes a line with fixes (JSONEncoder, sorted keys, nil left out).+ val MAC_WITH_FIXES = """+{+ "endedAt" : "2026-11-07T08:24:12Z",+ "hasAudio" : false,+ "id" : "20261107-031639",+ "lines" : [+ {+ "dst" : "I explained Morpho, and Curve.",+ "dstLang" : "en",+ "fixes" : [+ {+ "from" : "莫拉",+ "to" : "Morpho",+ "user" : true+ },+ {+ "ask" : true,+ "from" : "开布特",+ "to" : "Curve"+ },+ {+ "from" : "质压",+ "off" : true,+ "to" : "质押"+ }+ ],+ "id" : "h1-1",+ "speaker" : "them",+ "src" : "解释这个莫拉的,质压和开布特",+ "srcLang" : "zh-CN",+ "t" : 2.5+ },+ {+ "dst" : "Fine.",+ "dstLang" : "en",+ "id" : "h2-2",+ "speaker" : "them",+ "src" : "好的。",+ "srcLang" : "zh-CN",+ "t" : 6+ }+ ],+ "startedAt" : "2026-11-07T08:16:39Z",+ "title" : "会议 11月7日 03:16"+}""".trimStart()++ fun recordWithFixes() {+ val s = Session.read(MAC_WITH_FIXES)!!+ val l = s.lines[0]+ equal(3, l.fixes!!.size, "fixes read")+ equal(LineFix("开布特", "Curve", ask = true), l.fixes!![1], "a waiting fix")+ equal("解释这个莫拉的,质压和开布特", l.src, "src stays what was heard")+ equal("解释这个Morpho的,质压和开布特", l.shown, "shown: applied fixes only")+ equal(null, s.lines[1].fixes, "a line without fixes has none")+ equal(MAC_WITH_FIXES, Json.write(s.toJson()), "written back byte for byte")+ // A copy (what the screens read) keeps them, apart from the record's own.+ val c = l.copy(); c.fixes!![0].off = true+ equal(null, l.fixes!![0].off, "copies are deep")+ }++ fun recordFormatUnchangedWithoutFixes() {+ val line = TranscriptLine(id = "1", src = "a", srcLang = "zh", dstLang = "en")+ check(!Json.write(line.toJson()).contains("fixes"), "no fixes key")+ line.fixes = mutableListOf(LineFix("a", "b"))+ val back = TranscriptLine.from(Json.parseObject(Json.write(line.toJson()))!!)+ equal("b", back.shown, "shown")+ equal("a", back.src, "src")+ }++ fun exportsShowTheFixedText() {+ val s = Session.read(MAC_WITH_FIXES)!!+ check(TranscriptExport.markdown(s).contains("解释这个Morpho的,质压和开布特\n> I explained Morpho, and Curve.\n"), "markdown")+ check(TranscriptExport.srt(s).contains("解释这个Morpho的,质压和开布特\nI explained"), "srt")+ }++ fun applyReplacesAndMarks() {+ val fixes = listOf(LineFix("莫拉", "Morpho"), LineFix("质压", "质押"), LineFix("开布特", "Curve", ask = true), LineFix("ropax", "RoPax", off = true))+ val a = Correction.apply(fixes, "解释这个莫拉的,质压和开布特,ropax")+ equal("解释这个Morpho的,质押和开布特,ropax", a.text, "text")+ equal(listOf("Morpho", "质押"), a.marks.map { a.text.substring(it.first, it.last + 1) }, "marks")+ }++ fun applyKeepsEarlierMarks() {+ val a = Correction.apply(listOf(LineFix("质压", "质押"), LineFix("莫拉", "Morpho")), "莫拉说质压")+ equal("Morpho说质押", a.text, "text")+ equal(listOf("Morpho", "质押"), a.marks.map { a.text.substring(it.first, it.last + 1) }, "marks")+ }++ fun fixWhoseWordsWentAwayIsSkipped() {+ equal("解释这个摩托的", Correction.apply(listOf(LineFix("莫拉", "Morpho")), "解释这个摩托的").text, "skipped")+ }+}diff --git a/android/cli/src/main/kotlin/cicada/cli/Tests.kt b/android/cli/src/main/kotlin/cicada/cli/Tests.ktindex 7270582..efae1b1 100644--- a/android/cli/src/main/kotlin/cicada/cli/Tests.kt+++ b/android/cli/src/main/kotlin/cicada/cli/Tests.kt@@ -90,7 +90,7 @@ object Tests {"notesPromptNamesTheVoices" to ::notesPromptNamesTheVoices,"aHalfSentenceJoinsOnlyTheSameVoice" to ::aHalfSentenceJoinsOnlyTheSameVoice,"slowVoiceprintsNeverHoldSubtitlesBack" to ::slowVoiceprintsNeverHoldSubtitlesBack,- ) + ProviderTests.tests + AICheckTests.tests+ ) + ProviderTests.tests + AICheckTests.tests + FixTests.testsvar passed = 0; var failed = 0for ((name, test) in tests) {try { test(); passed++ } catch (e: Throwable) { failed++; println("FAIL $name: ${e.message ?: e.javaClass.simpleName}") }diff --git a/android/core/src/main/kotlin/cicada/Correction.kt b/android/core/src/main/kotlin/cicada/Correction.ktnew file mode 100644index 0000000..e1a1c47--- /dev/null+++ b/android/core/src/main/kotlin/cicada/Correction.kt@@ -0,0 +1,50 @@+package cicada++/// A word the AI service said speech recognition got wrong in a finished line ("莫拉" → "Morpho"),+/// field for field the Mac's LineFix. The line keeps what was heard (`src`) and carries its fixes,+/// so a record moves between the platforms unchanged.+data class LineFix(+ var from: String,+ var to: String,+ /// Waiting for the user (a name sound can't check): not applied until confirmed.+ var ask: Boolean? = null,+ /// The user said no (改回 or 不对): kept so the same line isn't fixed that way again.+ var off: Boolean? = null,+ /// The user's own: said 对, or wrote it (改这句…). A later pass never drops or overrides it.+ var user: Boolean? = null,+) {+ val applied: Boolean get() = ask != true && off != true++ fun toJson(): Map<String, Any?> = mapOf("from" to from, "to" to to, "ask" to ask, "off" to off, "user" to user)++ companion object {+ fun from(o: Map<String, Any?>) = LineFix(o["from"].str() ?: "", o["to"].str() ?: "", o["ask"].bool(), o["off"].bool(), o["user"].bool())+ }+}++/// 改正听错的词 (the Mac's Correction.swift): which of the service's proposed fixes to take, and+/// the line as shown once they are in.+object Correction {+ /// The line as shown: each applied fix replaces its words where they still are. `marks` are+ /// the replaced words (start, end in UTF-16 units), for the dotted underline.+ class Applied(val text: String, val marks: List<IntRange>)++ fun apply(fixes: List<LineFix>, src: String): Applied {+ var text = src+ val spans = mutableListOf<Pair<String, Int>>() // replacement and its offset, kept valid as text changes+ // The user's own last: written against the line as it was shown, other fixes in.+ val ordered = fixes.filter { it.user != true } + fixes.filter { it.user == true }+ for (f in ordered) {+ if (!f.applied || f.from.isEmpty()) continue+ val start = text.indexOf(f.from)+ if (start < 0) continue+ val delta = f.to.length - f.from.length+ for (k in spans.indices) if (spans[k].second > start) spans[k] = spans[k].first to spans[k].second + delta+ text = text.substring(0, start) + f.to + text.substring(start + f.from.length)+ spans.add(f.to to start)+ }+ val marks = spans.filter { (w, o) -> o + w.length <= text.length && w.isNotEmpty() }+ .map { (w, o) -> o until o + w.length }.sortedBy { it.first }+ return Applied(text, marks)+ }+}diff --git a/android/core/src/main/kotlin/cicada/Export.kt b/android/core/src/main/kotlin/cicada/Export.ktindex f6b8bd1..605863a 100644--- a/android/core/src/main/kotlin/cicada/Export.kt+++ b/android/core/src/main/kotlin/cicada/Export.kt@@ -112,8 +112,8 @@ object TranscriptExport {for (l in s.lines) {// An imported file has no "other side" to name.val who = if (s.sourceFile == null) " ${SpeakerLabels.speakerName(l, numbers, names)}" else ""- b.append("**[${Languages.clock(l.t)}]$who** \n${l.src}\n")- l.dst?.takeIf { it != l.src && it.isNotEmpty() }?.let { b.append("> $it\n") }+ b.append("**[${Languages.clock(l.t)}]$who** \n${l.shown}\n")+ l.dst?.takeIf { it != l.shown && it.isNotEmpty() }?.let { b.append("> $it\n") }b.append("\n")}return b.toString()@@ -130,8 +130,8 @@ object TranscriptExport {val end = maxOf(l.t + 1, minOf(next, l.t + 8))// Your own lines (我说) say so, as the record does.val tag = if (l.speaker == "me") "[${Strings.L("同传")}] " else ""- b.append("${i + 1}\n${ts(l.t)} --> ${ts(end)}\n$tag${l.src}\n")- l.dst?.takeIf { it != l.src && it.isNotEmpty() }?.let { b.append("$it\n") }+ b.append("${i + 1}\n${ts(l.t)} --> ${ts(end)}\n$tag${l.shown}\n")+ l.dst?.takeIf { it != l.shown && it.isNotEmpty() }?.let { b.append("$it\n") }b.append("\n")}return b.toString()@@ -170,8 +170,8 @@ object TranscriptExport {val numbers = SpeakerLabels.numbers(s.lines); val names = SpeakerLabels.names(s)for (l in s.lines) {add("[${Languages.clock(l.t)}]" + if (s.sourceFile == null) " ${SpeakerLabels.speakerName(l, numbers, names)}" else "", 9.0, bold = true, color = "555555", after = 2.0)- add(l.src, 11.0, after = 2.0)- l.dst?.takeIf { it != l.src && it.isNotEmpty() }?.let { add(it, 11.0, color = "4D4D4D", after = 10.0) }+ add(l.shown, 11.0, after = 2.0)+ l.dst?.takeIf { it != l.shown && it.isNotEmpty() }?.let { add(it, 11.0, color = "4D4D4D", after = 10.0) }}val doc = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" +"<w:document xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\"><w:body>$body" +diff --git a/android/core/src/main/kotlin/cicada/Models.kt b/android/core/src/main/kotlin/cicada/Models.ktindex 8a28ee0..dc2eb98 100644--- a/android/core/src/main/kotlin/cicada/Models.kt+++ b/android/core/src/main/kotlin/cicada/Models.kt@@ -31,12 +31,19 @@ class TranscriptLine(/// "room": heard by the Mac's room microphone in a 电脑和会议室 meeting; kept so a Mac record/// opened here keeps its 现场 / 线上.var via: String? = null,+ /// Words the AI service or the user fixed (Correction.kt); `src` stays what was heard. Absent+ /// when none, as the Mac writes it.+ var fixes: MutableList<LineFix>? = null,) {- fun copy() = TranscriptLine(id, t, speaker, src, dst, srcLang, dstLang, voice, via)+ fun copy() = TranscriptLine(id, t, speaker, src, dst, srcLang, dstLang, voice, via, fixes?.map { it.copy() }?.toMutableList())++ /// What the line says once its fixes are in: shown, searched, exported and read by the notes.+ val shown: String get() = fixes?.let { Correction.apply(it, src).text } ?: srcfun toJson(): Map<String, Any?> = mapOf("id" to id, "t" to t, "speaker" to speaker, "src" to src, "dst" to dst,"srcLang" to srcLang, "dstLang" to dstLang, "voice" to voice, "via" to via,+ "fixes" to fixes?.map { it.toJson() },)companion object {@@ -44,6 +51,7 @@ class TranscriptLine(id = o["id"].str() ?: "", t = o["t"].num() ?: 0.0, speaker = o["speaker"].str() ?: "them",src = o["src"].str() ?: "", dst = o["dst"].str(), srcLang = o["srcLang"].str() ?: "",dstLang = o["dstLang"].str() ?: "", voice = o["voice"].int(), via = o["via"].str(),+ fixes = (o["fixes"] as? List<*>)?.mapNotNull { it.obj()?.let(LineFix::from) }?.toMutableList(),)}}diff --git a/android/core/src/main/kotlin/cicada/Notes.kt b/android/core/src/main/kotlin/cicada/Notes.ktindex 4c84752..a6fffa2 100644--- a/android/core/src/main/kotlin/cicada/Notes.kt+++ b/android/core/src/main/kotlin/cicada/Notes.kt@@ -319,7 +319,7 @@ class NotesEngine(private val ling: LingClient, private val store: SessionStore)val l = lines[i]val n = numbers[l.id]val who = if (l.speaker == "me") "你" else if (n != null) names[n] ?: "说话人$n" else if (numbers.isEmpty()) "对方" else "未识别"- return "[L${i + 1} ${Languages.clock(l.t)} $who] ${l.src}"+ return "[L${i + 1} ${Languages.clock(l.t)} $who] ${l.shown}"}val current = if (notes.isEmpty) "{}" else compactJson(notes, frozen)val context = maxOf(0, from - 2)diff --git a/android/core/src/main/kotlin/cicada/Speakers.kt b/android/core/src/main/kotlin/cicada/Speakers.ktindex ad71caa..70218ab 100644--- a/android/core/src/main/kotlin/cicada/Speakers.kt+++ b/android/core/src/main/kotlin/cicada/Speakers.kt@@ -149,7 +149,7 @@ class SpeakerNamer(private val ling: LingClient, private val store: SessionStorefor ((i, l) in lines.takeLast(400).withIndex()) {val n = if (l.speaker == "them") l.voice?.let { numbers[it] } else nullval who = if (l.speaker == "me") "你" else if (n != null) "说话人$n" else "对方"- sb.append("[L${i + 1} ${Languages.clock(l.t)} $who] ${l.src}\n")+ sb.append("[L${i + 1} ${Languages.clock(l.t)} $who] ${l.shown}\n")}return sb.toString()}@@ -180,7 +180,7 @@ class SpeakerNamer(private val ling: LingClient, private val store: SessionStorefound.remove(other)}val l = lines[i]- val quote = if (l.src.length > 60) l.src.take(60) + "…" else l.src+ val quote = if (l.shown.length > 60) l.shown.take(60) + "…" else l.shownfound[v] = VoiceGuess(name, "${Languages.clock(l.t)} “$quote”")}return found to refuted@@ -192,7 +192,7 @@ class SpeakerNamer(private val ling: LingClient, private val store: SessionStoreval at = g.evidence.substringBefore("“").trim()val quote = g.evidence.substringAfter("“").removeSuffix("”").substringBefore("…")for ((i, l) in lines.withIndex()) {- if (Languages.clock(l.t) == at && l.src.startsWith(quote))+ if (Languages.clock(l.t) == at && l.shown.startsWith(quote))return lines.subList(maxOf(0, i - EVIDENCE_REACH), minOf(lines.size, i + EVIDENCE_REACH + 1)).any { it.speaker == "them" && it.voice == v }}diff --git a/site/changelog.json b/site/changelog.jsonindex 8623a12..06ae552 100644--- a/site/changelog.json+++ b/site/changelog.json@@ -45,6 +45,14 @@],"title": "词表里的写法和听错的形式都能就地改,删掉的词可以撤销,粘贴导入前先显示会新增几个。","text": "点写法就能改;指着一行,在后面敲一个新的听错形式就加上,指着已有的点 × 去掉。一个听错形式已经属于别的词时,会问你改给哪个,或者两个都留(之后遇到它每次都问)。没接 AI 服务时开关旁边有“去设置”。"+ },+ {+ "kind": "fixed",+ "platforms": [+ "android"+ ],+ "title": "在 Android 上打开或改动 Mac 的会议记录,Mac 改正过的听错的词会保留下来,显示、搜索和导出都用改后的文字。",+ "text": "记录里仍留着原来听到的文字,改正单独存着,和 Mac 是同一格式;还在等你确认的改法不算进去。"}]},