知了 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
chore(windows): anchor topic times to the lines they cite, and expose what the new UI shows
wquguru030439c6c60e
diff --git a/windows/src/Cicada.Core/ListenEngine.cs b/windows/src/Cicada.Core/ListenEngine.csindex 8eaf96e..5a2257f 100644--- a/windows/src/Cicada.Core/ListenEngine.cs+++ b/windows/src/Cicada.Core/ListenEngine.cs@@ -37,7 +37,14 @@ public sealed class ListenEngine/// Segments sent and not yet back: the UI shows "…" while this is above zero.public int Pending { get { lock (gate) return segments.Count; } }/// The last error worth showing ("key 无效", "网络不通"), cleared by the next good reply.- public string? Problem { get; private set; }+ /// What last went wrong talking to Ling (null once a segment gets through); the windows word it.+ public LingException.Kind? Problem { get; private set; }++ /// The user pressed 重试: hide the bar until the next failure says otherwise.+ public void ClearProblem() { Problem = null; Changed?.Invoke(); }++ /// Debug pipe only: show a failure's bar without breaking the network ("network", "ratelimited"…).+ public void SimulateProblem(string kind) { Problem = Enum.TryParse<LingException.Kind>(kind, true, out var k) ? k : null; Changed?.Invoke(); }public double Level { get; private set; }public event Action? Changed;@@ -130,14 +137,7 @@ public sealed class ListenEngine}catch (LingException e){- Problem = e.Failure switch- {- LingException.Kind.NoKey => Strings.L("需要 Ling key 才能听"),- LingException.Kind.InvalidKey => Strings.L("Ling key 无效"),- LingException.Kind.RateLimited => Strings.L("Ling 太忙,稍后再试"),- LingException.Kind.Network or LingException.Kind.Timeout => Strings.L("连不上 Ling,检查网络"),- _ => null,- };+ Problem = e.Failure is LingException.Kind.Hijacked or LingException.Kind.Parse ? null : e.Failure;Log.Debug($"listen: segment {seg.Index} failed {e.Message}");}Log.Debug($"listen: segment {seg.Index} {seg.Seconds:F1}s -> {(heard is null ? "nothing" : heard.Lang)} in {(DateTime.UtcNow - started).TotalMilliseconds:F0} ms");diff --git a/windows/src/Cicada.Core/Notes.cs b/windows/src/Cicada.Core/Notes.csindex 2397c3a..268278d 100644--- a/windows/src/Cicada.Core/Notes.cs+++ b/windows/src/Cicada.Core/Notes.cs@@ -23,6 +23,8 @@ public sealed class NotesEnginepublic MeetingNotes Notes { get; private set; } = new();public State Status { get; private set; } = State.Idle;+ /// While a meeting runs and has notes: when the next live update is due.+ public DateTime? NextUpdate { get { lock (gate) return sessionId is null || Notes.IsEmpty || inFlight ? null : lastAttempt.AddSeconds(Interval); } }/// The session the notes belong to (stays set after the meeting ends).public string? ShownId { get; private set; }/// The language notes are written in (English name), from 纪要语言.@@ -308,9 +310,14 @@ public sealed class NotesEnginepointTimes.Add(p is JsonObject po2 ? Time(po2["evidence"]) : null);}}+ // The model's "start" is sometimes misread (04:49 for 00:49); the lines it cites are not.+ // So the earliest cited line wins, and a time past the last line is pulled back to it.+ var cited = new[] { Time(t["evidence"]) }.Concat(pointTimes).Where(x => x is not null).Select(x => x!.Value).ToList();+ var start = cited.Count > 0 ? cited.Min() : Num(t["start"]) ?? startedAt;+ if (times.Count > 0 && start > times[^1]) start = times[^1];n.Topics.Add(new NoteTopic{- Start = Num(t["start"]) ?? startedAt, Title = topicTitle, Summary = Str(t["summary"]),+ Start = start, Title = topicTitle, Summary = Str(t["summary"]),Points = points, Fishbone = fish, PointTimes = pointTimes.Any(x => x is not null) ? pointTimes : null,});}diff --git a/windows/src/Cicada.Core/SessionStore.cs b/windows/src/Cicada.Core/SessionStore.csindex eccb907..6149192 100644--- a/windows/src/Cicada.Core/SessionStore.cs+++ b/windows/src/Cicada.Core/SessionStore.cs@@ -84,6 +84,9 @@ public sealed class SessionStorepublic void Rename(string id, string title) => Mutate(id, s => { s.Title = title.Trim(); s.Renamed = true; });+ /// Back to the default title, so the name the notes give the meeting shows again.+ public void ResetTitle(string id) => Mutate(id, s => { s.Title = DefaultTitle(s.StartedAt); s.Renamed = false; });+/// The meeting ended: kept if anything was said, removed otherwise.public void End(string id){@@ -156,29 +159,7 @@ public sealed class SessionStorevar b = new StringBuilder();b.AppendLine($"# {DisplayTitle(s)}").AppendLine();b.AppendLine(s.StartedAt.ToLocalTime().ToString("yyyy-MM-dd HH:mm", CultureInfo.InvariantCulture)).AppendLine();- if (s.Notes is { IsEmpty: false } n)- {- b.AppendLine($"## {Strings.L("纪要")}").AppendLine().AppendLine(n.Summary).AppendLine();- foreach (var t in n.Topics)- {- b.AppendLine($"### {Languages.Clock(t.Start)} {t.Title}").AppendLine();- if (t.Summary.Length > 0) b.AppendLine(t.Summary).AppendLine();- foreach (var p in t.Points) b.AppendLine($"- {p}");- b.AppendLine();- }- if (n.Conclusions.Count > 0)- {- b.AppendLine($"### {Strings.L("结论")}").AppendLine();- foreach (var c in n.Conclusions) b.AppendLine($"- {c.Text}");- b.AppendLine();- }- if (n.Todos.Count > 0)- {- b.AppendLine($"### {Strings.L("待办")}").AppendLine();- foreach (var t in n.Todos) b.AppendLine($"- [ ] {t.Text}{(t.Owner is null ? "" : $"({t.Owner})")}");- b.AppendLine();- }- }+ if (s.Notes is { IsEmpty: false } n) b.AppendLine($"## {Strings.L("纪要")}").AppendLine().Append(NotesBody(n));b.AppendLine($"## {Strings.L("文字记录")}").AppendLine();foreach (var l in s.Lines){@@ -188,4 +169,34 @@ public sealed class SessionStore}return b.ToString();}++ /// The notes alone (复制纪要): title, summary, topics, conclusions, to-dos.+ public static string NotesMarkdown(Session s) =>+ s.Notes is { IsEmpty: false } n ? $"# {DisplayTitle(s)}\n\n" + NotesBody(n) : "";++ static string NotesBody(MeetingNotes n)+ {+ var b = new StringBuilder();+ b.AppendLine(n.Summary).AppendLine();+ foreach (var t in n.Topics)+ {+ b.AppendLine($"### {Languages.Clock(t.Start)} {t.Title}").AppendLine();+ if (t.Summary.Length > 0) b.AppendLine(t.Summary).AppendLine();+ foreach (var p in t.Points) b.AppendLine($"- {p}");+ b.AppendLine();+ }+ if (n.Conclusions.Count > 0)+ {+ b.AppendLine($"### {Strings.L("结论")}").AppendLine();+ foreach (var c in n.Conclusions) b.AppendLine($"- {c.Text}");+ b.AppendLine();+ }+ if (n.Todos.Count > 0)+ {+ b.AppendLine($"### {Strings.L("待办")}").AppendLine();+ foreach (var t in n.Todos) b.AppendLine($"- [ ] {t.Text}{(t.Owner is null ? "" : $"({t.Owner})")}");+ b.AppendLine();+ }+ return b.ToString();+ }}diff --git a/windows/src/Cicada.Core/Settings.cs b/windows/src/Cicada.Core/Settings.csindex 9d3a0f5..c0cca8e 100644--- a/windows/src/Cicada.Core/Settings.cs+++ b/windows/src/Cicada.Core/Settings.cs@@ -18,6 +18,10 @@ public sealed class AppSettings[JsonPropertyName("onboarded")] public bool Onboarded { get; set; }/// The UI language: "system", "zh-Hans", "en", "ja" or "ko".[JsonPropertyName("uiLanguage")] public string UiLanguage { get; set; } = "system";+ /// 字幕文字大小, in px.+ [JsonPropertyName("subtitleSize")] public int SubtitleSize { get; set; } = 24;+ /// The one-time "知了还在听" notice after the panel is first collapsed while listening.+ [JsonPropertyName("toldStillListening")] public bool ToldStillListening { get; set; }[JsonIgnore] public string TargetCode => Target == "system" ? Languages.FromSystem(CultureInfo.CurrentUICulture.Name) : Target;[JsonIgnore] public string NotesCode => NotesLanguage == "system" ? TargetCode : NotesLanguage;diff --git a/windows/tests/Cicada.Tests/Program.cs b/windows/tests/Cicada.Tests/Program.csindex d56cd85..fd874a5 100644--- a/windows/tests/Cicada.Tests/Program.cs+++ b/windows/tests/Cicada.Tests/Program.cs@@ -253,6 +253,15 @@ static class TestsEqual(null, NotesEngine.Parse("{}", [], 0), "empty notes");}+ public static void TopicStartsAtItsFirstCitedLine()+ {+ double[] times = [5, 11, 49, 180];+ var raw = "{\"summary\":\"s\",\"topics\":[{\"start\":289,\"title\":\"发布说明\",\"points\":[{\"text\":\"发给设计组\",\"evidence\":[\"L3\"]}]},{\"start\":999,\"title\":\"别的\",\"points\":[\"x\"]}]}";+ var n = NotesEngine.Parse(raw, times, 0)!;+ Equal(49.0, n.Topics[0].Start, "the cited line's time, not the model's 289");+ Equal(180.0, n.Topics[1].Start, "never after the last line");+ }+public static void KeepsEarliestTimes(){var old = new MeetingNotes { Topics = [new NoteTopic { Title = "t", Points = ["a"], PointTimes = [3] }], Todos = [new NoteItem { Text = "x", T = 2 }] };