知了 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): Generate Notes on a long meeting no longer drops a topic and keeps only its "(continued)" end
wquguru6c33dad4cf97
diff --git a/android/cli/src/main/kotlin/cicada/cli/Tests.kt b/android/cli/src/main/kotlin/cicada/cli/Tests.ktindex 573cf66..be73c8d 100644--- a/android/cli/src/main/kotlin/cicada/cli/Tests.kt+++ b/android/cli/src/main/kotlin/cicada/cli/Tests.kt@@ -627,9 +627,23 @@ object Tests {check(merge.contains("\"topics\": []"), "no topics back")val ten = (0 until 10).map { topic(it * 300.0, "t$it") }- equal("t0,t3,t6,t9", NotesEngine.spread(ten, 4).joinToString(",") { it.title }, "topics spread over the part")- equal("t0", NotesEngine.spread(ten, 1).joinToString(",") { it.title }, "one")- equal(3, NotesEngine.spread(ten.take(3), 4).size, "fewer stay")+ val kept = NotesEngine.thinned(ten, 4, 3000.0)+ equal(4, kept.size, "topics thinned to four")+ equal(0.0, kept[0].start, "from the first")+ check(ten.all { t -> kept.any { t.title in it.title.split(" / ") } }, "every topic joined, none dropped")+ equal("0.0", NotesEngine.thinned(ten, 1, 3000.0).joinToString(",") { it.start.toString() }, "one")+ equal(3, NotesEngine.thinned(ten.take(3), 4, 3000.0).size, "fewer stay")+ // A 2.5-hour meeting's last part, asked for 2 topics, came back with 3: the budget topic's+ // end as its own. Kept first and last, the budget topic at 125 min was lost.+ val part = listOf(topic(6000.0, "营销发布安排", listOf("a")), topic(7500.0, "预算评审", listOf("b")), topic(8982.0, "预算评审(续)", listOf("c")))+ val two = NotesEngine.thinned(part, 2, 8990.0)+ equal("营销发布安排,预算评审", two.joinToString(",") { it.title }, "the topic kept over its continuation")+ equal("6000.0,7500.0", two.joinToString(",") { it.start.toString() }, "at its own start")+ equal("b,c", two[1].points.joinToString(","), "with the continuation's points")+ val other = listOf(topic(6000.0, "营销发布安排"), topic(7500.0, "预算评审"), topic(8982.0, "收尾"))+ equal("6000.0,7500.0", NotesEngine.thinned(other, 2, 8990.0).joinToString(",") { it.start.toString() }, "a stub joins the topic it ends")+ equal("Budget review", NotesEngine.subject("Budget review (cont.)"), "subject without the bracket")+ equal("(续)", NotesEngine.subject("(续)"), "a bracket alone stays")}fun topicStartsWhenItsLinesWereSaid() {diff --git a/android/core/src/main/kotlin/cicada/Notes.kt b/android/core/src/main/kotlin/cicada/Notes.ktindex b3aff2c..8192481 100644--- a/android/core/src/main/kotlin/cicada/Notes.kt+++ b/android/core/src/main/kotlin/cicada/Notes.kt@@ -193,7 +193,7 @@ class NotesEngine(private val ling: LingClient, private val store: SessionStore)}// Without its topics: given them, the merge wrote them all back out and was cut off.notes.add(Json.write(part - "topics", pretty = false))- topics += spread(parsed!!.topics, partTopics(parts.size))+ topics += thinned(parsed!!.topics, partTopics(parts.size), lines[parts[i].last].t)}val prompt = mergePrompt(notes, lines, lang)for (attempt in 1..2) {@@ -393,13 +393,33 @@ class NotesEngine(private val ling: LingClient, private val store: SessionStore)/// Each part's share of the topics: the merge keeps them as they are, so every part has some.fun partTopics(parts: Int) = maxOf(2, MAX_TOPICS / maxOf(1, parts))- /// `count` of `topics`, spread evenly from the first to the last: a part's reply often has- /// more topics than asked, and keeping the first ones (or folding the rest into the last) lost- /// the end of each part.- fun spread(topics: List<NoteTopic>, count: Int): List<NoteTopic> {- if (topics.size <= count || count <= 0) return topics- if (count == 1) return listOf(topics[0])- return (0 until count).map { topics[Math.round(it.toDouble() * (topics.size - 1) / (count - 1)).toInt()] }+ /// At most `count` of a part's `topics`, neighbours joined: a part's reply often has more+ /// topics than asked. Keeping the first ones lost the end of the part, and keeping some spread+ /// from first to last kept a topic's "(续)" stub at the part's end and dropped the topic+ /// itself. The same subject twice is joined first, under the first one's title; then the pair+ /// spanning the least time (to the next topic's start, or `end` for the last), as live notes do.+ fun thinned(topics: List<NoteTopic>, count: Int, end: Double): List<NoteTopic> {+ val list = topics.toMutableList()+ while (list.size > maxOf(1, count)) {+ fun span(i: Int) = (if (i + 2 < list.size) list[i + 2].start else end) - list[i].start+ val pairs = 0 until list.size - 1+ val same = pairs.firstOrNull { subject(list[it].title) == subject(list[it + 1].title) }+ // minBy keeps the first of equal spans, as the Mac does.+ val at = same ?: pairs.minBy { span(it) }+ val one = joined(list[at], list[at + 1])+ if (same != null) { one.title = list[at].title; one.summary = list[at].summary }+ list[at] = one+ list.removeAt(at + 1)+ }+ return list+ }++ /// A topic title without a trailing bracket ("预算评审(续)", "Budget (cont.)"): what it is about.+ fun subject(title: String): String {+ val t = title.trim()+ if (t.isEmpty() || t.last() !in "))") return t+ val open = t.lastIndexOfAny(charArrayOf('(', '('))+ return if (open > 0) t.substring(0, open).trim() else t}/// The whole meeting's title, summary, conclusions, to-dos and terms from its parts' notes (thediff --git a/site/changelog.json b/site/changelog.jsonindex 320ffed..ba976a3 100644--- a/site/changelog.json+++ b/site/changelog.json@@ -19,7 +19,8 @@"platforms": ["mac","windows",- "linux"+ "linux",+ "android"],"title": "长会议生成完整纪要时,不再丢掉某个话题、只留下它的“(续)”。","text": "长会议分几段写纪要,某一段写出的话题比要的多时,原来按位置挑几个留下,可能留下话题末尾单独列出的“(续)”、丢掉话题本身;现在多出的话题并进相邻的话题,同一话题的续篇并回原话题。"