知了 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
feat(windows): open to a main window that says what's left to set up, with a listening switch in the title bar
wquguru1446b24179e6
diff --git a/site/changelog.json b/site/changelog.jsonindex 4735bb9..71d520d 100644--- a/site/changelog.json+++ b/site/changelog.json@@ -226,6 +226,11 @@"title": "Windows 上会议应用挂断、或很久没人说话时,自动结束会议、整理纪要。","text": "Zoom、腾讯会议、飞书、Teams 等挂断后结束;没人说话时先提醒,也可以在设置 › 结束会议里改成直接结束或一直记录。"},+ {+ "kind": "improved",+ "title": "Windows 上打开知了就有主窗口:没设置好时列出还差几步,顶部一颗开关显示在不在听。",+ "text": "第一次打开时引导叠在主窗口上;“听声音”这一步分清对方的声音和你的麦克风,可以直接放一段测试声音。开机自启时只在任务栏右下角待命。"+ },{"kind": "new","title": "Windows 版改成一个安装包 Cicada-Setup.exe:双击就装好,不用管理员权限。",diff --git a/windows/src/Cicada.Core/Settings.cs b/windows/src/Cicada.Core/Settings.csindex c04a016..b0b2786 100644--- a/windows/src/Cicada.Core/Settings.cs+++ b/windows/src/Cicada.Core/Settings.cs@@ -18,6 +18,9 @@ public sealed class AppSettings/// 共享屏幕时让对方看到: let the notes window and subtitles show up in screen sharing.[JsonPropertyName("showInCapture")] public bool ShowInCapture { get; set; }[JsonPropertyName("onboarded")] public bool Onboarded { get; set; }+ /// The setup checklist (主窗口 › 还差几步): the onboarding heard the PC's sound / played the sample.+ [JsonPropertyName("heardSystemAudio")] public bool HeardSystemAudio { get; set; }+ [JsonPropertyName("sampleSeen")] public bool SampleSeen { get; set; }/// The UI language: "system", "zh-Hans", "en", "ja" or "ko".[JsonPropertyName("uiLanguage")] public string UiLanguage { get; set; } = "system";/// 字幕文字大小, in px.diff --git a/windows/src/Cicada/App.cs b/windows/src/Cicada/App.csindex 84d6ed7..3e5d3d7 100644--- a/windows/src/Cicada/App.cs+++ b/windows/src/Cicada/App.cs@@ -37,7 +37,7 @@ static class Programapp.ThemeMode = ThemeMode.Light;#pragma warning restore WPF0001app.DispatcherUnhandledException += (_, e) => { Log.Debug($"ui: unhandled {e.Exception.GetType().Name}: {e.Exception.Message}"); e.Handled = true; };- var controller = new Controller(app);+ var controller = new Controller(app) { Background = args.Contains("--background") };app.Startup += (_, _) => controller.Launch();return app.Run();}@@ -58,6 +58,9 @@ sealed class Controllerpublic readonly SpeakEngine Speak;public readonly WindowsVoice WindowsVoice = new();public readonly UpdateChecker Updates;+ /// Started with Windows (--background): stay in the tray. Opened by hand, the main window shows.+ public bool Background { get; init; }+ Onboarding? onboarding;/// 检查更新 in settings: null, or the result of the last manual check for a few seconds.public string? UpdateCheck { get; private set; }bool checksUpdates;@@ -137,7 +140,16 @@ sealed class Controllervar watch = new DispatcherTimer { Interval = TimeSpan.FromSeconds(2) };watch.Tick += (_, _) => _ = WatchEnd();watch.Start();- if (!Settings.Onboarded) new Onboarding(this, installed: Arrived == "--installed").Show();+ if (AutoStart.Enabled) AutoStart.Refresh();+ // The Mac shows its main window when opened by hand; a Windows user who double-clicks the+ // exe expects a window too, not just a tray icon. Not set up yet: the onboarding on top.+ if (!Background || !Settings.Onboarded) ShowRecords();+ if (!Settings.Onboarded)+ {+ var later = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(500) };+ later.Tick += (_, _) => { later.Stop(); ShowOnboarding(); };+ later.Start();+ }else{if (Ling.HasKey) _ = Ling.Check();@@ -146,11 +158,11 @@ sealed class Controller}}- /// The installer ran again with this version (or an older one) already here: open the panel.+ /// The installer ran again with this version (or an older one) already here: bring the main window.public void FromInstaller(){- ShowFlyout();- Toast(L("知了已经装好了"), L("下载的安装包可以删掉。"), ShowFlyout);+ ShowRecords();+ Toast(L("知了已经装好了"), L("下载的安装包可以删掉。"), ShowRecords);}void Changed() => Dispatch.BeginInvoke(() =>@@ -294,7 +306,7 @@ sealed class Controllerpublic void StartListening(IAudioSource source){if (Listen.Listening) return;- if (!Ling.HasKey) { new Onboarding(this).Show(); return; }+ if (!Ling.HasKey) { ShowOnboarding(0); return; }source.Ended += reason =>{if (reason is null) return;@@ -516,6 +528,41 @@ sealed class ControllernotesWindow.Refresh();}+ // MARK: Setup (the main window's 还差几步 and the title bar's pill)++ /// The setup steps, as the onboarding numbers them: what is done, by what really happened+ /// rather than by "the onboarding was finished".+ public (bool Key, bool Audio, bool Sample) SetupDone => (Ling.HasKey, Settings.HeardSystemAudio || Settings.Onboarded, Settings.SampleSeen || Settings.Onboarded);++ /// Steps left before listening works; 0 once set up. 同声传译 is optional and never counted.+ public int SetupLeft+ {+ get+ {+ var (k, a, sm) = SetupDone;+ if (Settings.Onboarded && k) return 0;+ return (k ? 0 : 1) + (a ? 0 : 1) + (sm ? 0 : 1);+ }+ }++ /// The onboarding, at `step` or at the first step not done; one window at a time.+ public void ShowOnboarding(int? step = null)+ {+ var (k, a, _) = SetupDone;+ var at = step ?? (!k ? 0 : !a ? 1 : 2);+ if (onboarding is null)+ {+ onboarding = new Onboarding(this, installed: Arrived == "--installed");+ onboarding.Closed += (_, _) => { onboarding = null; Changed(); };+ if (mainWindow?.IsVisible == true) { onboarding.Owner = mainWindow; onboarding.WindowStartupLocation = WindowStartupLocation.CenterOwner; }+ }+ onboarding.At(at);+ onboarding.Show();+ onboarding.Activate();+ }++ public void SetupChanged() => Changed();+public void ShowRecords() => ShowRecords(null);public void ShowRecords(string? id)@@ -716,7 +763,7 @@ static class DebugServerelse if (arg.StartsWith("settings")) { app.ShowSettings(); if (arg.Length > 9) app.SettingsPage(arg[9..]); }else if (arg == "flyout") app.ShowFlyout();else if (arg == "menu") app.ShowMenu();- else if (arg.StartsWith("onboarding")) { var o = new Onboarding(app); if (int.TryParse(arg[10..].Trim(), out var n)) o.At(n); o.Show(); }+ else if (arg.StartsWith("onboarding")) app.ShowOnboarding(int.TryParse(arg[10..].Trim(), out var n) ? n : null);else app.ShowNotes();break;case "toast": app.Toast(L("纪要整理好了"), LF("%@ · 点这里打开", "Test"), () => app.ShowRecords()); break;diff --git a/windows/src/Cicada/MainWindow.cs b/windows/src/Cicada/MainWindow.csindex 558e4d3..1a47e46 100644--- a/windows/src/Cicada/MainWindow.cs+++ b/windows/src/Cicada/MainWindow.cs@@ -44,6 +44,16 @@ sealed class MainWindow : Windowdouble? jumpTo;string? shownKey;bool refreshQueued;+ readonly ContentControl pill = new() { VerticalAlignment = VerticalAlignment.Top, HorizontalAlignment = HorizontalAlignment.Center, Margin = new Thickness(0, 8, 0, 0) };+ readonly ColumnDefinition listColumn = new() { Width = new GridLength(260) };+ readonly DispatcherTimer tick = new() { Interval = TimeSpan.FromMilliseconds(120) };+ readonly double[] levels = new double[8];+ FrameworkElement? left;+ // The pill is rebuilt only when what it says changes (a rebuild between press and release+ // would lose the click); the bars and the clock move in place.+ string? pillKey;+ readonly List<System.Windows.Shapes.Rectangle> bars = [];+ TextBlock? clock;public MainWindow(Controller app, string? select = null){@@ -56,7 +66,7 @@ sealed class MainWindow : WindowWindowStartupLocation = WindowStartupLocation.CenterScreen;var grid = new Grid();- grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(260) });+ grid.ColumnDefinitions.Add(listColumn);grid.ColumnDefinitions.Add(new ColumnDefinition());// The search box, with its icon and placeholder drawn over it@@ -89,6 +99,7 @@ sealed class MainWindow : Windowvar logo = AppIcon.Small(20);logo.HorizontalAlignment = HorizontalAlignment.Left; logo.Margin = new Thickness(18, 14, 0, 6);var left = new DockPanel { Background = Palette.Mica };+ this.left = left;DockPanel.SetDock(logo, Dock.Top);DockPanel.SetDock(searchBox, Dock.Top);left.Children.Add(logo);@@ -98,7 +109,14 @@ sealed class MainWindow : Windowvar right = new Border { Background = Palette.Surface, Child = detail };Grid.SetColumn(right, 1);grid.Children.Add(left); grid.Children.Add(right);+ // The Mac's toolbar pill, centred in the title bar: the brand is the listening switch.+ System.Windows.Shell.WindowChrome.SetIsHitTestVisibleInChrome(pill, true);+ Grid.SetColumnSpan(pill, 2);+ grid.Children.Add(pill);Content = Ui.Frameless(this, grid);+ // The pill's clock and level move while listening; nothing else needs a timer.+ tick.Tick += (_, _) => { if (app.Listen.Listening) Pill(); else { tick.Stop(); Pill(); } };+ Closed += (_, _) => tick.Stop();Refresh();}@@ -119,7 +137,11 @@ sealed class MainWindow : Windowvoid Fill(){+ Pill();var all = app.Store.All();+ // No meetings yet: only the welcome. An empty list and search box are noise.+ listColumn.Width = new GridLength(all.Count == 0 ? 0 : 260);+ if (left is not null) left.Visibility = all.Count == 0 ? Visibility.Collapsed : Visibility.Visible;var q = search.Text.Trim();var shown = all.Where(s => Matches(s, q)).ToList();list.Children.Clear();@@ -137,7 +159,7 @@ sealed class MainWindow : Windowlist.Children.Add(Item(s));}// An empty page replaces the meeting, so the next real one must draw again.- if (all.Count == 0) { selected = null; shownKey = null; detail.Content = Empty(L("还没有会议记录"), L("点任务栏里的知了图标,开始听第一场会。")); return; }+ if (all.Count == 0) { selected = null; shownKey = null; detail.Content = Welcome(); return; }if (shown.Count == 0) { shownKey = null; detail.Content = Empty(L("没有找到"), ""); return; }if (selected is null || shown.All(s => s.Id != selected)) selected = shown[0].Id;foreach (var child in list.Children.OfType<Button>()) Paint(child);@@ -189,6 +211,161 @@ sealed class MainWindow : Windowreturn t;}+ // MARK: Welcome and the pill++ /// No meetings yet (Views.swift › welcome): the logo, one line and the one thing to do; or,+ /// not set up yet, what is left, each step opening the onboarding where it is.+ FrameworkElement Welcome()+ {+ var s = new StackPanel { HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, MaxWidth = 480, Margin = new Thickness(24, 40, 24, 60) };+ var mark = AppIcon.Small(72);+ mark.Effect = new System.Windows.Media.Effects.DropShadowEffect { Color = Color.FromRgb(0xE8, 0x55, 0x2B), Opacity = 0.25, BlurRadius = 26, ShadowDepth = 8, Direction = 270 };+ s.Children.Add(mark);+ var left = app.SetupLeft;+ var title = Ui.Text(left > 0 ? LF("还差 %@ 步就能用", left) : L("还没有会议"), 26, Palette.Ink, FontWeights.Bold, wrap: false);+ title.HorizontalAlignment = HorizontalAlignment.Center; title.Margin = new Thickness(0, 26, 0, 8);+ s.Children.Add(title);+ var line = Ui.Text(left > 0 ? L("知了把电脑里放出来的会议声音变成字幕和纪要。") : L("打开会议或视频,开始听后,每一场都会存在这里。"), 15, Palette.Secondary);+ line.TextAlignment = TextAlignment.Center;+ s.Children.Add(line);+ if (left > 0) { s.Children.Add(Checklist()); return s; }++ var label = Ui.Row(10, Ui.Dot(Palette.Live, 9), Ui.Text(L("开始听"), 15, Brushes.White, Palette.Strong, wrap: false),+ new Border { BorderBrush = new SolidColorBrush(Color.FromArgb(0x55, 0xFF, 0xFF, 0xFF)), BorderThickness = new Thickness(1), CornerRadius = new CornerRadius(5), Padding = new Thickness(6, 0, 6, 1), Child = Ui.Text(Hotkey.Label.Replace('+', ' '), 12, Palette.NightText, wrap: false) });+ var start = Capsule(label, Palette.Ink, null, 44, new Thickness(22, 0, 22, 0), () => _ = app.ToggleListening(), L("开始听"));+ start.HorizontalAlignment = HorizontalAlignment.Center; start.Margin = new Thickness(0, 30, 0, 0);+ s.Children.Add(start);+ var sample = Ui.LinkText(L("先听一段示例"), () => _ = app.PlaySample(), 13);+ sample.Foreground = Palette.Secondary; sample.HorizontalAlignment = HorizontalAlignment.Center; sample.Margin = new Thickness(0, 16, 0, 0);+ s.Children.Add(sample);+ return s;+ }++ FrameworkElement Checklist()+ {+ var (key, audio, sample) = app.SetupDone;+ var first = !key ? 0 : !audio ? 1 : !sample ? 2 : 3;+ (string title, string detail, bool done)[] steps =+ [+ (L("接上 Ling"), key ? L("key 已加密存在这台电脑上") : L("识别、翻译和纪要都靠它,约 1 分钟"), key),+ (L("听一下电脑里的声音"), L("放一段测试声音,看音量条动起来"), audio),+ (L("看看效果"), L("一段 9 秒的英文会议,字幕和纪要一句句出来"), sample),+ (L("同声传译"), LF("按住%@说话,对方听到翻译后的声音", PushToTalk.Label), false),+ ];+ var list = new StackPanel();+ for (int i = 0; i < steps.Length; i++)+ {+ var (title, detail, done) = steps[i];+ var now = i == first;+ var n = i;+ var disc = new Border+ {+ Width = 26, Height = 26, CornerRadius = new CornerRadius(13), VerticalAlignment = VerticalAlignment.Center, Margin = new Thickness(0, 0, 14, 0),+ Background = done ? Palette.Ink : now ? Palette.Live : Palette.Surface, BorderBrush = done ? Palette.Ink : now ? Palette.Live : Palette.Line, BorderThickness = new Thickness(1),+ Child = done ? Ui.Icon(Icons.Check, 13, Brushes.White, stroke: 2) : Center(Ui.Text((i + 1).ToString(), 12, now ? Brushes.White : Palette.Body, FontWeights.Bold, wrap: false)),+ };+ var head = Ui.Row(8, Ui.Text(title, 14, done ? Palette.Secondary : Palette.Ink, done ? FontWeights.Normal : Palette.Strong, wrap: false));+ if (i == 3) ((StackPanel)head).Children.Add(Ui.Badge(L("可选"), Palette.Surface, Palette.Secondary));+ var text = Ui.Stack(1, head, Ui.Helper(detail));+ FrameworkElement? action = now ? Ui.Button(L("继续设置"), () => app.ShowOnboarding(n), Ui.Kind.Primary, height: 32)+ : i == 3 && first == 3 ? Ui.Button(L("去设置"), () => app.ShowOnboarding(3), height: 32) : null;+ var row = new DockPanel { Margin = new Thickness(0, 14, 0, 14) };+ DockPanel.SetDock(disc, Dock.Left);+ row.Children.Add(disc);+ if (action is not null) { action.Margin = new Thickness(12, 0, 0, 0); DockPanel.SetDock(action, Dock.Right); row.Children.Add(action); }+ row.Children.Add(text);+ list.Children.Add(new Border { BorderBrush = Palette.Line, BorderThickness = new Thickness(0, i == 0 ? 0 : 1, 0, 0), Child = row });+ }+ return new Border { Background = Palette.Page, CornerRadius = new CornerRadius(16), Padding = new Thickness(18, 2, 18, 2), Margin = new Thickness(0, 28, 0, 0), Child = list, MinWidth = 440 };+ static FrameworkElement Center(FrameworkElement e) { e.HorizontalAlignment = HorizontalAlignment.Center; e.VerticalAlignment = VerticalAlignment.Center; return e; }+ }++ /// The title bar's switch (ListenPill.swift), led by the logo: a white pill while idle or not+ /// set up, an ink one with the level, the time and 结束 while listening.+ void Pill()+ {+ var listen = app.Listen;+ var live = listen.Listening && listen.SessionId is { } id ? app.Store.Get(id) : null;+ var left = app.SetupLeft;+ var key = live is not null ? (app.Ending is { } e ? $"ending|{app.EndingTitle(e)}|{Controller.EndingLeft(e)}" : "live")+ : left > 0 ? $"setup|{left}" : $"idle|{app.AutoEnded}";+ if (live is not null)+ {+ if (!tick.IsEnabled) tick.Start();+ Array.Copy(levels, 1, levels, 0, levels.Length - 1);+ levels[^1] = Math.Max(listen.Level <= 0 ? 0 : Math.Clamp((20 * Math.Log10(listen.Level) + 50) / 50, 0, 1), levels[^2] * 0.7);+ }+ if (key != pillKey)+ {+ pillKey = key;+ pill.Content = live is not null ? LivePill() : IdlePill(left);+ }+ for (int i = 0; i < bars.Count && i < levels.Length; i++) bars[i].Height = 3 + levels[i] * 12;+ if (clock is not null && live is not null) clock.Text = Languages.Clock((DateTimeOffset.Now - live.StartedAt).TotalSeconds);+ }++ FrameworkElement IdlePill(int left)+ {+ bars.Clear(); clock = null;+ var sep = new Border { Width = 1, Height = 14, Background = Palette.Line, VerticalAlignment = VerticalAlignment.Center };+ var content = left > 0+ ? Ui.Row(9, AppIcon.Small(22), Ui.Text(L("知了"), 13, Palette.Ink, FontWeights.Heavy, wrap: false), sep, Ui.Text(LF("还差 %@ 步", left), 13, Palette.AccentText, Palette.Strong, wrap: false), Ui.Text(L("继续设置"), 11, Palette.Secondary, wrap: false))+ : Ui.Row(9, AppIcon.Small(22), Ui.Text(L("知了"), 13, Palette.Ink, FontWeights.Heavy, wrap: false), sep, Ui.Text(app.AutoEnded ? L("会议已自动结束") : L("开始听"), 13, Palette.Ink, Palette.Strong, wrap: false), Ui.Text(Hotkey.Label.Replace('+', ' '), 11, Palette.Secondary, wrap: false));+ return Capsule(content, Palette.Surface, Palette.Line, 32, new Thickness(5, 0, 12, 0),+ left > 0 ? () => app.ShowOnboarding() : () => _ = app.ToggleListening(), left > 0 ? L("继续设置") : L("开始听"));+ }++ FrameworkElement LivePill()+ {+ bars.Clear();+ var mark = AppIcon.Small(22);+ UIElement state;+ if (app.Ending is { } p)+ {+ clock = null;+ state = Ui.Row(10, mark, Ui.Text(app.EndingTitle(p), 13, Brushes.White, Palette.Strong, wrap: false), Ui.Text(LF("%lld 秒后结束", Controller.EndingLeft(p)), 13, new SolidColorBrush(Color.FromRgb(0xF4, 0xA5, 0x8C)), wrap: false));+ }+ else+ {+ var meter = new StackPanel { Orientation = Orientation.Horizontal, Height = 15, VerticalAlignment = VerticalAlignment.Center };+ for (int i = 0; i < levels.Length; i++)+ {+ var r = new System.Windows.Shapes.Rectangle { Width = 3, Height = 3, RadiusX = 1, RadiusY = 1, Margin = new Thickness(0, 0, 2, 0), VerticalAlignment = VerticalAlignment.Bottom, Fill = Palette.Live };+ bars.Add(r); meter.Children.Add(r);+ }+ clock = Ui.Text("00:00", 13, Brushes.White, wrap: false);+ state = Ui.Row(10, mark, Ui.Text(L("正在听"), 13, Brushes.White, Palette.Strong, wrap: false), meter, clock);+ }+ var show = Capsule(state, Brushes.Transparent, null, 32, new Thickness(0), app.ShowNotes, L("显示纪要"));+ var end = app.Ending is not null+ ? Capsule(Ui.Text(L("继续记录"), 12, Palette.Ink, Palette.Strong, wrap: false), Brushes.White, null, 24, new Thickness(12, 0, 12, 0), app.KeepRecording, L("继续记录"))+ : Capsule(Ui.Text(L("结束"), 12, Brushes.White, Palette.Strong, wrap: false), new SolidColorBrush(Color.FromRgb(0x2F, 0x32, 0x3A)), null, 24, new Thickness(12, 0, 12, 0), app.RequestStop, L("结束会议"));+ end.Margin = new Thickness(10, 0, 0, 0);+ return new Border { Background = Palette.Ink, CornerRadius = new CornerRadius(16), Height = 32, Padding = new Thickness(5, 0, 4, 0), Child = Ui.Row(0, show, end) };+ }++ /// A rounded button with no theme chrome: the pill and its parts.+ static Button Capsule(UIElement content, Brush background, Brush? border, double height, Thickness padding, Action click, string name)+ {+ var b = new Button { Content = content, Height = height, Padding = padding, Background = background, BorderBrush = border ?? Brushes.Transparent, BorderThickness = new Thickness(border is null ? 0 : 1), Cursor = System.Windows.Input.Cursors.Hand, Focusable = false };+ var t = new ControlTemplate(typeof(Button));+ var bg = new FrameworkElementFactory(typeof(Border), "bg");+ bg.SetValue(Border.CornerRadiusProperty, new CornerRadius(height / 2));+ foreach (var (dp, path) in new[] { (Border.BackgroundProperty, "Background"), (Border.BorderBrushProperty, "BorderBrush"), (Border.BorderThicknessProperty, "BorderThickness"), (Border.PaddingProperty, "Padding") })+ bg.SetBinding(dp, new System.Windows.Data.Binding(path) { RelativeSource = System.Windows.Data.RelativeSource.TemplatedParent });+ var cp = new FrameworkElementFactory(typeof(ContentPresenter));+ cp.SetValue(ContentPresenter.VerticalAlignmentProperty, VerticalAlignment.Center);+ bg.AppendChild(cp);+ t.VisualTree = bg;+ var hover = new Trigger { Property = UIElement.IsMouseOverProperty, Value = true };+ hover.Setters.Add(new Setter(UIElement.OpacityProperty, 0.9));+ t.Triggers.Add(hover);+ b.Template = t;+ b.Click += (_, _) => click();+ System.Windows.Automation.AutomationProperties.SetName(b, name);+ return b;+ }+static FrameworkElement Empty(string title, string hint){var s = new StackPanel { HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center };diff --git a/windows/src/Cicada/Onboarding.cs b/windows/src/Cicada/Onboarding.csindex 05e0e0f..43b53c2 100644--- a/windows/src/Cicada/Onboarding.cs+++ b/windows/src/Cicada/Onboarding.cs@@ -207,12 +207,6 @@ sealed class Onboarding : Windownext.MinWidth = 108; next.HorizontalAlignment = HorizontalAlignment.Right;next.IsEnabled = !checking;var right = new StackPanel { Orientation = Orientation.Horizontal };- if (step == 1)- {- var hint = Ui.Text(L("音量条没动?放段视频或音乐试试"), 13, Palette.Secondary, wrap: false);- hint.VerticalAlignment = VerticalAlignment.Center; hint.Margin = new Thickness(0, 0, 16, 0);- right.Children.Add(hint);- }if (step == 3){var later = Ui.Button(L("以后再说"), () => { LeaveSpeak(keep: false); speakBefore = null; step = 4; Render(); }, height: 44);@@ -328,36 +322,96 @@ sealed class Onboarding : Windowif (tap is null){tap = new SystemAudioTap();- tap.Samples += buf =>- {- double sum = 0;- foreach (var s in buf) sum += (double)s * s;- var rms = buf.Length == 0 ? 0 : Math.Sqrt(sum / buf.Length) / 32768;- // The loudest buffer since the last bar, not the last one (often a silent fill).- level = Math.Max(level, rms);- peak = Math.Max(peak, rms);- };+ tap.Samples += Heard;tap.Start();meter.Start();}Detach(meterHost); Detach(heardHost);heardHost.Tag = null;Meter();- var tile = new Border { Width = 44, Height = 44, CornerRadius = new CornerRadius(12), Background = Palette.Mica, Margin = new Thickness(0, 0, 16, 0), Child = Ui.Icon(Icons.Speaker, 20, Palette.Ink) };+ var tile = new Border { Width = 44, Height = 44, CornerRadius = new CornerRadius(12), Background = Palette.AccentPale, Margin = new Thickness(0, 0, 16, 0), Child = Ui.Icon(Icons.Speaker, 20, Palette.AccentText) };var status = Ui.Row(18, meterHost, heardHost);- var device = AudioDevice.DefaultName();- var from = new Border { Background = Palette.Mica, CornerRadius = new CornerRadius(8), Padding = new Thickness(12, 6, 12, 6), Child = Ui.Text(device ?? L("默认扬声器"), 13, Palette.Ink, wrap: false), MaxWidth = 340 };+ var device = AudioDevice.DefaultName() ?? L("默认扬声器");+ var test = Ui.Button(testing ? L("正在播放…") : L("放一段测试声音"), () => _ = PlayTest(), Ui.Kind.Accent, Icons.Play, 36, iconFill: true);+ test.IsEnabled = !testing;var card = StepCard(new StackPanel{Children ={- Numbered(tile, L("听电脑里的声音"), L("只听声音,不录屏幕画面,也不占麦克风"), status),+ Numbered(tile, L("电脑播放的声音"), LF("%@ · 只听声音,不录屏幕", device), status),Divider(16),- Ui.Spread(Ui.Text(L("从哪里听"), 14, Palette.Body, wrap: false), from),+ Ui.Spread(Ui.Stack(2, Ui.Text(L("没有声音在放?"), 14, Palette.Ink, wrap: false), Ui.Helper(L("放 3 秒测试声音,从默认扬声器出来"))), test),},});- var note = Ui.Row(8, Ui.Icon(Icons.EyeOff, 15, Palette.Secondary), Ui.Text(L("纪要窗不会出现在截图和屏幕共享里"), 13, Palette.Secondary, wrap: false));- return Page(L("让知了听到电脑里的声音"), L("字幕和纪要都从这里来。Windows 上不用授权,放点声音就行。"), card, note);+ // The two sounds side by side: people try speaking first, but this step hears the PC.+ var sources = new Grid { Margin = new Thickness(0, 12, 0, 0) };+ sources.ColumnDefinitions.Add(new ColumnDefinition());+ sources.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(12) });+ sources.ColumnDefinitions.Add(new ColumnDefinition());+ var theirs = Source(L("对方的声音"), Ui.Badge(L("这一步")), [L("会议软件"), L("扬声器"), L("知了:字幕和纪要")], on: true);+ var yours = Source(L("你的声音 · 麦克风"), Ui.Badge(L("第 4 步再用"), Palette.Mica, Palette.Secondary), [L("麦克风"), L("同声传译"), L("对方听到译文")], on: false);+ Grid.SetColumn(yours, 2);+ sources.Children.Add(theirs); sources.Children.Add(yours);+ return Page(L("让知了听到电脑里的声音"), L("会议里对方说的话从电脑扬声器放出来,字幕和纪要都从这里来。Windows 上不用授权。"), card, sources);+ }++ /// One of the two sounds: where it goes, outlined in ink when it is this step's.+ static FrameworkElement Source(string title, FrameworkElement badge, string[] flow, bool on)+ {+ var path = new WrapPanel { Margin = new Thickness(0, 8, 0, 0) };+ for (int i = 0; i < flow.Length; i++)+ {+ var last = on && i == flow.Length - 1;+ path.Children.Add(new Border { Background = last ? Palette.Ink : Palette.Mica, CornerRadius = new CornerRadius(6), Padding = new Thickness(7, 1, 7, 2), Margin = new Thickness(0, 0, 0, 4), Child = Ui.Text(flow[i], 12, last ? Brushes.White : Palette.Ink, wrap: false) });+ if (i < flow.Length - 1) path.Children.Add(new TextBlock { Text = "→", FontSize = 12, Foreground = Palette.Secondary, Margin = new Thickness(6, 1, 6, 0) });+ }+ var head = Ui.Row(8, Ui.Text(title, 14, Palette.Ink, Palette.Strong, wrap: false), badge);+ return new Border+ {+ Background = Palette.Surface, CornerRadius = new CornerRadius(14), Padding = new Thickness(16, 12, 16, 10),+ BorderBrush = on ? Palette.Ink : Palette.Line, BorderThickness = new Thickness(on ? 2 : 1),+ Child = new StackPanel { Children = { head, path } },+ };+ }++ void Heard(short[] buf)+ {+ double sum = 0;+ foreach (var s in buf) sum += (double)s * s;+ var rms = buf.Length == 0 ? 0 : Math.Sqrt(sum / buf.Length) / 32768;+ // The loudest buffer since the last bar, not the last one (often a silent fill).+ level = Math.Max(level, rms);+ peak = Math.Max(peak, rms);+ }++ bool testing;++ /// 放一段测试声音: the sample's first seconds through the default speakers. The listening tap+ /// leaves Cicada's own sound out, so a second tap that hears only Cicada feeds the same bars:+ /// they still move only if Windows really hands the PC's sound over.+ async Task PlayTest()+ {+ if (testing || Bundled.Sample() is not { } wav) return;+ testing = true; Render();+ var self = new SystemAudioTap { OnlySelf = true };+ self.Samples += Heard;+ self.Start();+ var player = new System.Media.SoundPlayer(wav);+ try+ {+ player.Play();+ Log.Debug("onboarding: test sound");+ await Task.Delay(3200);+ }+ catch (Exception e) { Log.Debug($"onboarding: test sound failed {e.GetType().Name}"); }+ finally+ {+ player.Stop();+ await Task.Delay(300);+ self.Stop();+ testing = false;+ if (IsLoaded && step == 1) Render();+ }}/// A few bars of the last moment's loudness, newest on the right, in the accent once there's sound.@@ -373,6 +427,7 @@ sealed class Onboarding : WindowSystem.Windows.Automation.AutomationProperties.SetName(bars, L("系统声音"));meterHost.Content = bars;var heard = peak >= 0.01;+ if (heard && !app.Settings.HeardSystemAudio) { app.Settings.HeardSystemAudio = true; app.Settings.Save(); app.SetupChanged(); }if (heardHost.Tag as bool? != heard){heardHost.Tag = heard;@@ -411,7 +466,12 @@ sealed class Onboarding : WindowLeft = Math.Max(area.Left + 8, Math.Min(Left, room - Width));playing = true; Render();try { await app.PlaySample(); }- finally { playing = false; if (IsLoaded) Render(); }+ finally+ {+ playing = false;+ if (!app.Settings.SampleSeen) { app.Settings.SampleSeen = true; app.Settings.Save(); app.SetupChanged(); }+ if (IsLoaded) Render();+ }}// MARK: 4 · Speak into the meetingdiff --git a/windows/src/Cicada/Platform.cs b/windows/src/Cicada/Platform.csindex 9299586..cb70bea 100644--- a/windows/src/Cicada/Platform.cs+++ b/windows/src/Cicada/Platform.cs@@ -45,7 +45,20 @@ static class AutoStart{const string RunKey = @"Software\Microsoft\Windows\CurrentVersion\Run";static string Name => Paths.Dev ? "Cicada Dev" : "Cicada";- static string Command(string exe) => $"\"{exe}\"" + (Paths.Dev ? " --dev" : "");+ // --background: started with Windows, so stay in the tray; opened by hand, the main window shows.+ static string Command(string exe) => $"\"{exe}\" --background" + (Paths.Dev ? " --dev" : "");++ /// Rewrites an entry made before --background existed, which would open the main window at sign-in.+ public static void Refresh()+ {+ try+ {+ using var k = Registry.CurrentUser.OpenSubKey(RunKey, writable: true);+ var exe = Environment.ProcessPath ?? "";+ if (k?.GetValue(Name) is string v && v.StartsWith($"\"{exe}\"", StringComparison.OrdinalIgnoreCase) && v != Command(exe)) { k.SetValue(Name, Command(exe)); Log.Debug("autostart: command updated"); }+ }+ catch (Exception e) { Log.Debug($"autostart: refresh failed {e.GetType().Name}"); }+ }public static bool Enabled{diff --git a/windows/src/Cicada/Strings/en.lproj/Windows.strings b/windows/src/Cicada/Strings/en.lproj/Windows.stringsindex c65cbfd..62ff727 100644--- a/windows/src/Cicada/Strings/en.lproj/Windows.strings+++ b/windows/src/Cicada/Strings/en.lproj/Windows.strings@@ -221,3 +221,28 @@"在开始菜单里放入口" = "Add it to the Start menu";"登记到“设置 › 应用”,以后从那里卸载" = "Add it to Settings › Apps, to uninstall from there";"下载后打开,知了会自己更新" = "Open it and Cicada updates itself";+"还差 %@ 步就能用" = "Almost ready: %@ to go";+"知了把电脑里放出来的会议声音变成字幕和纪要。" = "Cicada turns the meeting audio your PC plays into subtitles and notes.";+"key 已加密存在这台电脑上" = "Your key is encrypted on this PC";+"识别、翻译和纪要都靠它,约 1 分钟" = "Transcription, translation and notes need it. About a minute.";+"听一下电脑里的声音" = "Check your PC's sound";+"放一段测试声音,看音量条动起来" = "Play a test sound and watch the meter move";+"一段 9 秒的英文会议,字幕和纪要一句句出来" = "A 9-second English meeting, with subtitles and notes as they come";+"按住%@说话,对方听到翻译后的声音" = "Hold %@ to speak; they hear the translation";+"可选" = "Optional";+"继续设置" = "Continue setup";+"还差 %@ 步" = "%@ to go";+"放一段测试声音" = "Play a test sound";+"电脑播放的声音" = "What your PC plays";+"%@ · 只听声音,不录屏幕" = "%@ · Sound only, never the screen";+"没有声音在放?" = "Nothing playing?";+"放 3 秒测试声音,从默认扬声器出来" = "Play 3 seconds of sound through your default speakers";+"对方的声音" = "Their voices";+"这一步" = "This step";+"会议软件" = "Meeting app";+"扬声器" = "Speakers";+"知了:字幕和纪要" = "Cicada: subtitles and notes";+"你的声音 · 麦克风" = "Your voice · microphone";+"第 4 步再用" = "Used in step 4";+"对方听到译文" = "They hear the translation";+"会议里对方说的话从电脑扬声器放出来,字幕和纪要都从这里来。Windows 上不用授权。" = "What others say in a meeting comes out of your PC's speakers. Subtitles and notes come from there. No permission needed on Windows.";diff --git a/windows/src/Cicada/Strings/ja.lproj/Windows.strings b/windows/src/Cicada/Strings/ja.lproj/Windows.stringsindex 20777f3..5180127 100644--- a/windows/src/Cicada/Strings/ja.lproj/Windows.strings+++ b/windows/src/Cicada/Strings/ja.lproj/Windows.strings@@ -221,3 +221,28 @@"在开始菜单里放入口" = "スタートメニューに追加";"登记到“设置 › 应用”,以后从那里卸载" = "「設定 › アプリ」に登録(ここからアンインストールできます)";"下载后打开,知了会自己更新" = "開くと Cicada が自動で更新します";+"还差 %@ 步就能用" = "あと %@ ステップで使えます";+"知了把电脑里放出来的会议声音变成字幕和纪要。" = "Cicada は PC から流れる会議の音声を字幕とメモにします。";+"key 已加密存在这台电脑上" = "キーはこの PC に暗号化して保存されています";+"识别、翻译和纪要都靠它,约 1 分钟" = "文字起こし・翻訳・メモに使います。約 1 分";+"听一下电脑里的声音" = "PC の音を確認";+"放一段测试声音,看音量条动起来" = "テスト音を流してメーターが動くか確認";+"一段 9 秒的英文会议,字幕和纪要一句句出来" = "9 秒の英語の会議で、字幕とメモが出てくる様子を確認";+"按住%@说话,对方听到翻译后的声音" = "%@ を押しながら話すと、相手には翻訳された音声が届きます";+"可选" = "任意";+"继续设置" = "設定を続ける";+"还差 %@ 步" = "あと %@ ステップ";+"放一段测试声音" = "テスト音を流す";+"电脑播放的声音" = "PC から流れる音";+"%@ · 只听声音,不录屏幕" = "%@ · 音だけで、画面は録りません";+"没有声音在放?" = "何も再生していませんか?";+"放 3 秒测试声音,从默认扬声器出来" = "既定のスピーカーから 3 秒のテスト音を流します";+"对方的声音" = "相手の声";+"这一步" = "このステップ";+"会议软件" = "会議アプリ";+"扬声器" = "スピーカー";+"知了:字幕和纪要" = "Cicada:字幕とメモ";+"你的声音 · 麦克风" = "あなたの声 · マイク";+"第 4 步再用" = "ステップ 4 で使います";+"对方听到译文" = "相手に翻訳が届く";+"会议里对方说的话从电脑扬声器放出来,字幕和纪要都从这里来。Windows 上不用授权。" = "会議で相手が話す声は PC のスピーカーから流れます。字幕とメモはそこから作られます。Windows では許可は不要です。";diff --git a/windows/src/Cicada/Strings/ko.lproj/Windows.strings b/windows/src/Cicada/Strings/ko.lproj/Windows.stringsindex 73c1f91..76ad79a 100644--- a/windows/src/Cicada/Strings/ko.lproj/Windows.strings+++ b/windows/src/Cicada/Strings/ko.lproj/Windows.strings@@ -221,3 +221,28 @@"在开始菜单里放入口" = "시작 메뉴에 추가";"登记到“设置 › 应用”,以后从那里卸载" = "설정 › 앱에 등록 (여기서 제거할 수 있어요)";"下载后打开,知了会自己更新" = "열면 Cicada가 스스로 업데이트해요";+"还差 %@ 步就能用" = "%@단계만 더 하면 돼요";+"知了把电脑里放出来的会议声音变成字幕和纪要。" = "Cicada는 PC에서 나오는 회의 소리를 자막과 회의록으로 바꿔요.";+"key 已加密存在这台电脑上" = "키는 이 PC에 암호화되어 저장돼요";+"识别、翻译和纪要都靠它,约 1 分钟" = "인식, 번역, 회의록에 필요해요. 약 1분";+"听一下电脑里的声音" = "PC 소리 확인하기";+"放一段测试声音,看音量条动起来" = "테스트 소리를 틀고 미터가 움직이는지 확인";+"一段 9 秒的英文会议,字幕和纪要一句句出来" = "9초짜리 영어 회의로 자막과 회의록이 나오는 모습을 확인";+"按住%@说话,对方听到翻译后的声音" = "%@ 키를 누르고 말하면 상대는 번역된 음성을 들어요";+"可选" = "선택";+"继续设置" = "설정 계속하기";+"还差 %@ 步" = "%@단계 남음";+"放一段测试声音" = "테스트 소리 틀기";+"电脑播放的声音" = "PC에서 나오는 소리";+"%@ · 只听声音,不录屏幕" = "%@ · 소리만 듣고 화면은 녹화하지 않아요";+"没有声音在放?" = "재생 중인 소리가 없나요?";+"放 3 秒测试声音,从默认扬声器出来" = "기본 스피커로 3초 동안 테스트 소리를 틀어요";+"对方的声音" = "상대방 목소리";+"这一步" = "이 단계";+"会议软件" = "회의 앱";+"扬声器" = "스피커";+"知了:字幕和纪要" = "Cicada: 자막과 회의록";+"你的声音 · 麦克风" = "내 목소리 · 마이크";+"第 4 步再用" = "4단계에서 사용";+"对方听到译文" = "상대가 번역을 들어요";+"会议里对方说的话从电脑扬声器放出来,字幕和纪要都从这里来。Windows 上不用授权。" = "회의에서 상대가 하는 말은 PC 스피커로 나와요. 자막과 회의록은 여기서 만들어져요. Windows에서는 권한이 필요 없어요.";diff --git a/windows/src/Cicada/SystemAudioTap.cs b/windows/src/Cicada/SystemAudioTap.csindex a126f19..910e09f 100644--- a/windows/src/Cicada/SystemAudioTap.cs+++ b/windows/src/Cicada/SystemAudioTap.cs@@ -14,6 +14,9 @@ sealed class SystemAudioTap : IAudioSourceThread? thread;volatile bool running;+ /// Only Cicada's own sound instead of everything else: the onboarding's test sound, which the+ /// normal tap leaves out by design. Proves process loopback works on this PC all the same.+ public bool OnlySelf { get; init; }public event Action<short[]>? Samples;public event Action<string?>? Ended;@@ -123,9 +126,9 @@ sealed class SystemAudioTap : IAudioSourcereturn Wav.Resample(mono, rate);}- static IAudioClient Activate()+ IAudioClient Activate(){- var p = new ActivationParams { ActivationType = 1, TargetProcessId = (uint)Environment.ProcessId, ProcessLoopbackMode = 1 /* exclude tree */ };+ var p = new ActivationParams { ActivationType = 1, TargetProcessId = (uint)Environment.ProcessId, ProcessLoopbackMode = OnlySelf ? 0 /* include tree */ : 1 /* exclude tree */ };int size = Marshal.SizeOf<ActivationParams>();var blob = Marshal.AllocHGlobal(size);Marshal.StructureToPtr(p, blob, false);