Skip to content

知了 Cicada · 任何会议和直播的实时字幕、同声传译、AI 会议纪要,Mac、Windows、Linux、Android 免费开源。Live subtitles, interpreting and meeting notes for any call or stream, on Mac, Windows, Linux and Android.

fix(windows): Generate Notes on a long meeting no longer drops a topic and keeps only its "(continued)" end

wquguru51c99ac26c6e
diff --git a/site/changelog.json b/site/changelog.json
index 9e83f09..1331e84 100644
--- a/site/changelog.json
+++ b/site/changelog.json
@@ -17,7 +17,8 @@
{
"kind": "fixed",
"platforms": [
- "mac"
+ "mac",
+ "windows"
],
"title": "长会议生成完整纪要时,不再丢掉某个话题、只留下它的“(续)”。",
"text": "长会议分几段写纪要,某一段写出的话题比要的多时,原来按位置挑几个留下,可能留下话题末尾单独列出的“(续)”、丢掉话题本身;现在多出的话题并进相邻的话题,同一话题的续篇并回原话题。"
diff --git a/windows/src/Cicada.Core/Notes.cs b/windows/src/Cicada.Core/Notes.cs
index 1bd577f..d18eb67 100644
--- a/windows/src/Cicada.Core/Notes.cs
+++ b/windows/src/Cicada.Core/Notes.cs
@@ -251,7 +251,7 @@ public sealed class NotesEngine
if (JsonNode.Parse(raw[a..(b + 1)]) is not JsonObject part) return null;
part.Remove("topics");
notes.Add(part.ToJsonString(Json.Compact));
- topics.AddRange(Spread(parsed.Topics, PartTopics(parts.Count)));
+ topics.AddRange(Thinned(parsed.Topics, PartTopics(parts.Count), lines[parts[i].End.Value - 1].T));
}
bool voices = SpeakerLabels.Voices && SpeakerLabels.Numbers(lines).Count > 0;
var prompt = MergePrompt(notes, lines, lang, voices);
@@ -479,15 +479,40 @@ public sealed class NotesEngine
/// Each part's share of the topics: the merge keeps them as they are, so every part has some.
public static int PartTopics(int parts) => Math.Max(2, MaxTopics / Math.Max(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.
- public static List<NoteTopic> Spread(IReadOnlyList<NoteTopic> topics, int count)
+ /// 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.
+ public static List<NoteTopic> Thinned(IReadOnlyList<NoteTopic> topics, int count, double end)
{
- if (topics.Count <= count || count <= 0) return topics.ToList();
- if (count == 1) return [topics[0]];
- return Enumerable.Range(0, count)
- .Select(k => topics[(int)Math.Round((double)k * (topics.Count - 1) / (count - 1), MidpointRounding.AwayFromZero)]).ToList();
+ var list = topics.ToList();
+ while (list.Count > Math.Max(1, count))
+ {
+ double Span(int i) => (i + 2 < list.Count ? list[i + 2].Start : end) - list[i].Start;
+ int same = Enumerable.Range(0, list.Count - 1).FirstOrDefault(i => Subject(list[i].Title) == Subject(list[i + 1].Title), -1);
+ int at = same;
+ if (at < 0)
+ {
+ // The first of equal spans, as the Mac does.
+ at = 0;
+ for (int i = 1; i < list.Count - 1; i++) if (Span(i) < Span(at)) at = i;
+ }
+ var one = Joined(list[at], list[at + 1]);
+ if (same >= 0) (one.Title, one.Summary) = (list[at].Title, 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.
+ public static string Subject(string title)
+ {
+ var t = title.Trim();
+ if (t.Length == 0 || !"))".Contains(t[^1])) return t;
+ int open = t.LastIndexOfAny(['(', '(']);
+ return open > 0 ? t[..open].Trim() : t;
}
/// The whole meeting's title, summary, conclusions, to-dos and terms from its parts' notes (the
diff --git a/windows/tests/Cicada.Tests/Program.cs b/windows/tests/Cicada.Tests/Program.cs
index cee60e9..1e41311 100644
--- a/windows/tests/Cicada.Tests/Program.cs
+++ b/windows/tests/Cicada.Tests/Program.cs
@@ -724,9 +724,23 @@ static class Tests
Check(four.Zip(four.Skip(1)).All(x => x.First.End.Value == x.Second.Start.Value), "back to back");
Equal(0, NotesEngine.Parts([]).Count, "no lines, no parts");
var ten = Enumerable.Range(0, 10).Select(i => Topic(i * 300, $"t{i}")).ToList();
- Equal("t0,t3,t6,t9", Titles(NotesEngine.Spread(ten, 4)), "a part's topics spread from first to last");
- Equal("t0", Titles(NotesEngine.Spread(ten, 1)), "one");
- Equal(3, NotesEngine.Spread(ten.Take(3).ToList(), 4).Count, "fewer than asked stay");
+ var kept = NotesEngine.Thinned(ten, 4, 3000);
+ Equal(4, kept.Count, "a part's topics thinned to four");
+ Equal(0.0, kept[0].Start, "from the first");
+ Check(ten.All(t => kept.Any(k => k.Title.Split(" / ").Contains(t.Title))), "every topic joined, none dropped");
+ Equal("0", string.Join(",", NotesEngine.Thinned(ten, 1, 3000).Select(t => t.Start)), "one");
+ Equal(3, NotesEngine.Thinned(ten.Take(3).ToList(), 4, 3000).Count, "fewer than asked 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.
+ var part = new List<NoteTopic> { Topic(6000, "营销发布安排", ["a"]), Topic(7500, "预算评审", ["b"]), Topic(8982, "预算评审(续)", ["c"]) };
+ var two = NotesEngine.Thinned(part, 2, 8990);
+ Equal("营销发布安排,预算评审", Titles(two), "the topic kept over its continuation");
+ Equal("6000,7500", string.Join(",", two.Select(t => t.Start)), "at its own start");
+ Equal("b,c", string.Join(",", two[1].Points), "with the continuation's points");
+ var other = new List<NoteTopic> { Topic(6000, "营销发布安排"), Topic(7500, "预算评审"), Topic(8982, "收尾") };
+ Equal("6000,7500", string.Join(",", NotesEngine.Thinned(other, 2, 8990).Select(t => t.Start)), "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");
}
public static void PartPromptKeepsLineNumbers()