知了 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: end forgotten meetings and show which mic each meeting app uses
wquguru7dfc1f03702f
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex f048d64..9e488d8 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -5,6 +5,8 @@ the release workflow publishes it as the release notes.## Unreleased+- New: a meeting nobody ends now ends by itself. When the meeting app it was heard through (Zoom, 腾讯会议, 飞书, Teams…) hangs up, the live notes window shows "Zoom 已挂断 · 30 秒后结束" with 继续记录 / 现在结束; when nobody has said anything for 10 minutes (and no meeting app is in a call) it counts down 60 s the same way. Silence counts recognized words, so background music doesn't keep a meeting going. The record ends at the last words or the hang-up and the recording drops the silent tail, so a forgotten meeting no longer runs for hours or swallows the next video. After a meeting ends this way, the next call in a meeting app starts a new one. Settings › 通用 › 结束会议 has the switch, 提醒后结束 / 直接结束 / 一直记录 and 5–30 minutes.+- New: Settings › 同声传译 lists the meeting apps and the microphone each one is using, live. An app that isn't on BlackHole 2ch is flagged (the room can't hear the translation) with a 怎么改 sheet that turns green once it's switched; the menu bar panel shows the same warning, and the last step of the first-run guide turns green by itself when a meeting app picks the virtual mic. macOS doesn't let one app choose another's microphone, so Cicada only checks and shows the way.- Fixed: with no meeting running, the live notes window could show "正在生成纪要…" and an empty skeleton under "现在没有在记录"; it now says there is no meeting in progress.- Changed: the live notes window starts its title beside the window buttons instead of below a blank band, so more of the notes fit.- Fixed: in a quick conversation, especially Japanese, a sentence could stay unfinished for 15–20 s: the subtitle stayed a draft and the notes waited for it. A long line now ends at the next short pause (or when no new words come for a moment), so sentences finish every 5–9 s and get their real translation sooner.diff --git a/README.md b/README.mdindex bf1dbd3..0f203f7 100644--- a/README.md+++ b/README.md@@ -44,12 +44,13 @@ Cicada (知了, formerly Live Subs) is a macOS menu bar app that listens to what### Speak back in their language-- **Push-to-talk interpreting.** Hold the right `⌥` key (or a custom shortcut) and speak. The room hears your translated voice through BlackHole 2ch, a virtual microphone you can install and test from inside the app with one click.+- **Push-to-talk interpreting.** Hold the right `⌥` key (or a custom shortcut) and speak. The room hears your translated voice through BlackHole 2ch, a virtual microphone you can install and test from inside the app with one click. Settings shows which meeting apps are on it, live, and how to switch the ones that aren't.- **Ming voices and voice cloning.** With a Ling API key, the Ming audio model listens and translates in one step in about 2 seconds. The other side can hear natural Ming voices (English, Chinese, Japanese, Korean, German, French, Spanish), macOS system voices, or a clone of your own voice from an 8 to 30 second sample; without a key, Cicada uses macOS system voices.### Meeting records- **Saved on your Mac.** Every session gets its own folder with the bilingual transcript, notes and audio recording. Speakers are labeled as you and the other side; "you" covers only what you say while holding the talk key, not what you say into the meeting directly, and individual remote speakers are not separated yet (see [roadmap](#roadmap)).+- **Ends when the meeting does.** When the meeting app hangs up, or after 10 minutes with no one speaking, Cicada counts down and ends the meeting, trimming the silent tail, so a forgotten one doesn't run on for hours. You can keep it going with one click, or change this in Settings.- **Export anywhere.** Export to Markdown, Word (both start with the meeting notes) or SRT subtitles. If you recorded a meeting without live notes, click **Generate Notes** afterward to create them.<p align="center">diff --git a/README.zh-CN.md b/README.zh-CN.mdindex 1c80c48..27e6c28 100644--- a/README.zh-CN.md+++ b/README.zh-CN.md@@ -44,12 +44,13 @@### 同声传译(说话也能翻译)-- **按住快捷键说话**。按住键盘右边的 `⌥` 键开口(可改组合键),对方听到的就是翻译后的语音。声音通过虚拟音频驱动 BlackHole 2ch 传给会议软件,在知了里点一下就能从官方下载安装并自动试音。+- **按住快捷键说话**。按住键盘右边的 `⌥` 键开口(可改组合键),对方听到的就是翻译后的语音。声音通过虚拟音频驱动 BlackHole 2ch 传给会议软件,在知了里点一下就能从官方下载安装并自动试音。设置里会实时显示哪些会议软件选了它,没选的告诉你怎么改。- **Ming 人声与声音克隆**。填了 Ling 的 API key 后,由 Ming 语音模型一步听懂并翻译你说的话,大约 2 秒出声。对方听到的声音可以选 Ming 自然人声(英、中、日、韩、德、法、西语)、Mac 自带语音,或用 8 到 30 秒录音克隆自己的声音,不填 key 时使用 Mac 自带语音。### 会议记录- **完整保存在本机**。每场会议单独建一个文件夹,存下双语文字记录、纪要和原始录音。说话人目前区分“对方”和“你”,其中“你”只包括按住说话键说的话,在会上直接开口的部分还录不到,对方也还不能细分(见[路线图](#路线图))。+- **会开完就自动结束**。会议软件挂断,或 10 分钟没人说话时,知了会倒计时结束这场会议,并去掉后面空白的部分,忘了点结束也不会一直记下去。一键可以继续记录,也可以在设置里改。- **多格式导出**。支持导出成 Markdown、Word(开头就是整理好的纪要)以及 SRT 字幕文件。如果开会时没开实时纪要,会后随时可以点“生成纪要”补一份。<p align="center">diff --git a/Resources/en.lproj/Localizable.strings b/Resources/en.lproj/Localizable.stringsindex d0a0419..f849e69 100644--- a/Resources/en.lproj/Localizable.strings+++ b/Resources/en.lproj/Localizable.strings@@ -103,6 +103,10 @@"与另一个快捷键冲突" = "Conflicts with the other shortcut";"%@ 是系统快捷键,换一个吧" = "%@ is a system shortcut; choose another";"%@ 已被其他应用占用,换一个吧" = "%@ is taken by another app; choose another";+"%lld 秒后结束" = "ending in %lld s";+"%@ 已挂断" = "%@ hung up";+"已经 %lld 分钟没人说话" = "No one has spoken for %lld min";+"%lld 秒后结束会议并整理纪要" = "Ending in %lld s and writing up the notes";"欢迎使用%@" = "Welcome to %@";"设置" = "Settings";"正在记录会议" = "A meeting is being recorded";@@ -202,6 +206,37 @@"正在识别语言…" = "Detecting language…";"翻译暂不可用" = "Translation unavailable for now";+/* MicUsersView */+"这里只显示正在用麦克风的会议软件和常见会议软件,麦克风要在各软件里自己换。" = "Shows meeting apps using a mic, plus common ones. Change the mic inside each app.";+"会议软件的麦克风" = "Meeting app microphones";+"实时更新" = "Live";+"还没有会议软件在用麦克风,进会议后这里会显示" = "No meeting app is using a mic yet. Join a meeting and it shows up here";+"空闲" = "Idle";+"怎么改" = "How to fix";+"正在用虚拟麦克风" = "Using the virtual mic";+"没用虚拟麦克风,对方听不到译文" = "Not on the virtual mic; they can't hear the translation";+"正在用 %@,对方听不到译文" = "Using %@; they can't hear the translation";+"没开麦克风" = "Mic not in use";+"对方能听到" = "They hear you";+"顺便关掉自动调节麦克风音量和降噪,译文会更清楚" = "Also turn off automatic mic volume and noise suppression so the translation sounds clearer";+"进会议后,点麦克风图标旁边的 ⌃" = "In the meeting, click the ⌃ next to the microphone icon";+"在选择麦克风菜单里点 %@" = "Under Select a Microphone, choose %@";+"在会议网页的音频设置里,把麦克风选为 %@" = "In the meeting page's audio settings, set the microphone to %@";+"想让所有网页默认用它:Chrome 设置 › 隐私和安全 › 网站设置 › 麦克风" = "To make it the default for every site: Chrome Settings › Privacy and security › Site settings › Microphone";+"打开%@的音频设置" = "Open %@'s audio settings";+"把麦克风选为 %@" = "Set the microphone to %@";+"换用虚拟麦克风后,对方只能听到译文,听不到你说话的原声。" = "With the virtual mic, they hear only the translation, not your own voice.";+"在%@里使用虚拟麦克风" = "Use the virtual mic in %@";+"改好一次,下次开会不用再改" = "Change it once and it sticks for your next meetings";+"好了" = "Done";+"先不改" = "Not now";+"打开%@" = "Open %@";+"%@当前麦克风" = "%@'s microphone now";+"选对后这里会自动变绿" = "This turns green once it's right";+"没开麦克风,进会议后这里会显示" = "Mic not in use. It shows here once you join a meeting";+"%@,对方能听到译文" = "%@: they hear the translation";+"其他麦克风" = "Another mic";+/* NotesViews */"总结" = "Summary";"刚更新" = "Just updated";@@ -232,6 +267,7 @@"已听到 %lld 句" = "Heard %lld lines";"正在生成纪要" = "Writing notes";"正在更新" = "Updating";+"现在结束" = "End now";/* NotesWindow */"key 已失效(令牌被删或免费额度用尽),纪要停留在 %@。" = "The key stopped working (token deleted or free quota used up). Notes stop at %@.";@@ -336,12 +372,14 @@"正在听…" = "Listening…";"听到" = "Hearing";"自动 · %@" = "Auto · %@";-"最后一步:在会议软件中,将麦克风选为 " = "Last step: in your meeting app, set the microphone to ";"想让对方听懂你?" = "Want them to understand you?";"按住说%@,对方听到翻译后的语音。" = "Hold and speak %@; they hear it translated.";"可在设置中更改" = "Change it in Settings";"右侧 option" = "Right option";"按住说话" = "Hold to talk";+"%@已选虚拟麦克风,对方能听到译文" = "%@ is on the virtual mic; they hear the translation";+"最后一步:在会议软件中,将麦克风选为 " = "Last step: in your meeting app, set the microphone to ";+"等你选好…" = "Waiting for you…";/* OnboardingKey */"接上 Ling,用上完整的知了" = "Connect Ling to get all of Cicada";@@ -447,6 +485,14 @@"只存在这台 Mac 上" = "Stored only on this Mac";"记录文件夹" = "Records folder";"打开" = "Open";+"会议应用挂断后结束" = "End when the meeting app hangs up";+"Zoom、腾讯会议、飞书、Teams 等" = "Zoom, Tencent Meeting, Lark, Teams and others";+"没人说话时" = "When no one speaks";+"按识别出的话算,背景音乐不算" = "Counts recognized words, not background music";+"多久算没人说话" = "Silent for";+"提醒后结束" = "Ask, then end";+"直接结束" = "End";+"一直记录" = "Keep going";/* Shortcuts */"右 ⌥" = "Right ⌥";@@ -591,10 +637,13 @@/* Views */"自动识别(%@)" = "Auto-detect (%@)";"%@(需下载)" = "%@ (download needed)";+"会议已自动结束" = "Meeting ended by itself";"系统" = "System";"仅本场" = "This meeting";"按住" = "Hold";"说%@ → %@" = "%1$@ → %2$@";+"%@已选虚拟麦克风" = "%@ is on the virtual mic";+"%@没选虚拟麦克风,对方听不到译文" = "%@ isn't on the virtual mic, so they can't hear you";"虚拟麦克风尚未设置好,对方听不到你的声音" = "The virtual microphone isn't set up; they can't hear you";"纪要、文字记录和字幕都在一个窗口里" = "Notes and transcript in one window";"填入 API key 后可生成纪要;文字记录照常保存" = "Add an API key for notes; the transcript is saved either way";diff --git a/Resources/ja.lproj/Localizable.strings b/Resources/ja.lproj/Localizable.stringsindex 982fd03..98f12f3 100644--- a/Resources/ja.lproj/Localizable.strings+++ b/Resources/ja.lproj/Localizable.strings@@ -103,6 +103,10 @@"与另一个快捷键冲突" = "別のショートカットと競合しています";"%@ 是系统快捷键,换一个吧" = "%@ はシステムのショートカットです。別のものを選んでください";"%@ 已被其他应用占用,换一个吧" = "%@ は他のアプリで使用されています。別のものを選んでください";+"%lld 秒后结束" = "%lld 秒後に終了";+"%@ 已挂断" = "%@ が通話を終了しました";+"已经 %lld 分钟没人说话" = "%lld 分間だれも話していません";+"%lld 秒后结束会议并整理纪要" = "%lld 秒後に会議を終了して議事録をまとめます";"欢迎使用%@" = "%@へようこそ";"设置" = "設定";"正在记录会议" = "会議を記録中です";@@ -202,6 +206,37 @@"正在识别语言…" = "言語を検出中…";"翻译暂不可用" = "現在翻訳を利用できません";+/* MicUsersView */+"这里只显示正在用麦克风的会议软件和常见会议软件,麦克风要在各软件里自己换。" = "マイクを使用中の会議アプリと主な会議アプリを表示します。マイクは各アプリで切り替えてください。";+"会议软件的麦克风" = "会議アプリのマイク";+"实时更新" = "リアルタイム";+"还没有会议软件在用麦克风,进会议后这里会显示" = "マイクを使っている会議アプリはまだありません。会議に参加するとここに表示されます";+"空闲" = "待機中";+"怎么改" = "直し方";+"正在用虚拟麦克风" = "仮想マイクを使用中";+"没用虚拟麦克风,对方听不到译文" = "仮想マイクではないため、相手に訳文が届きません";+"正在用 %@,对方听不到译文" = "%@ を使用中のため、相手に訳文が届きません";+"没开麦克风" = "マイク未使用";+"对方能听到" = "相手に届いています";+"顺便关掉自动调节麦克风音量和降噪,译文会更清楚" = "マイク音量の自動調整とノイズ抑制もオフにすると、訳文がよりクリアに届きます";+"进会议后,点麦克风图标旁边的 ⌃" = "会議中にマイクアイコンの横の ⌃ をクリック";+"在选择麦克风菜单里点 %@" = "マイクの選択メニューで %@ を選ぶ";+"在会议网页的音频设置里,把麦克风选为 %@" = "会議ページのオーディオ設定で、マイクを %@ にする";+"想让所有网页默认用它:Chrome 设置 › 隐私和安全 › 网站设置 › 麦克风" = "すべてのサイトで使うには:Chrome の設定 › プライバシーとセキュリティ › サイトの設定 › マイク";+"打开%@的音频设置" = "%@ のオーディオ設定を開く";+"把麦克风选为 %@" = "マイクを %@ にする";+"换用虚拟麦克风后,对方只能听到译文,听不到你说话的原声。" = "仮想マイクにすると、相手には訳文だけが届き、あなたの声そのものは聞こえません。";+"在%@里使用虚拟麦克风" = "%@ で仮想マイクを使う";+"改好一次,下次开会不用再改" = "一度変えれば、次の会議からはそのままです";+"好了" = "完了";+"先不改" = "あとで";+"打开%@" = "%@ を開く";+"%@当前麦克风" = "%@ の現在のマイク";+"选对后这里会自动变绿" = "正しく選ぶと自動で緑になります";+"没开麦克风,进会议后这里会显示" = "マイク未使用です。会議に参加するとここに表示されます";+"%@,对方能听到译文" = "%@ で相手に訳文が届いています";+"其他麦克风" = "別のマイク";+/* NotesViews */"总结" = "まとめ";"刚更新" = "更新直後";@@ -232,6 +267,7 @@"已听到 %lld 句" = "%lld文を聞き取りました";"正在生成纪要" = "議事メモを作成中";"正在更新" = "更新中";+"现在结束" = "今すぐ終了";/* NotesWindow */"key 已失效(令牌被删或免费额度用尽),纪要停留在 %@。" = "キーが無効になりました(トークンの削除、または無料枠の上限)。議事メモは%@で止まっています。";@@ -336,12 +372,14 @@"正在听…" = "聞き取り中…";"听到" = "検出";"自动 · %@" = "自動 · %@";-"最后一步:在会议软件中,将麦克风选为 " = "最後に、会議アプリのマイクを次に設定します: ";"想让对方听懂你?" = "相手に伝えたいですか?";"按住说%@,对方听到翻译后的语音。" = "押したまま%@で話すと、相手には翻訳された音声が聞こえます。";"可在设置中更改" = "設定で変更できます";"右侧 option" = "右の option";"按住说话" = "押して話す";+"%@已选虚拟麦克风,对方能听到译文" = "%@ は仮想マイクを選択済み。相手に訳文が届きます";+"最后一步:在会议软件中,将麦克风选为 " = "最後に、会議アプリのマイクを次に設定します: ";+"等你选好…" = "選択を待っています…";/* OnboardingKey */"接上 Ling,用上完整的知了" = "Ling をつないで、Cicada をフルに使う";@@ -447,6 +485,14 @@"只存在这台 Mac 上" = "このMacにのみ保存";"记录文件夹" = "記録フォルダ";"打开" = "開く";+"会议应用挂断后结束" = "会議アプリの通話終了で終了";+"Zoom、腾讯会议、飞书、Teams 等" = "Zoom、Tencent Meeting、Lark、Teams など";+"没人说话时" = "だれも話さないとき";+"按识别出的话算,背景音乐不算" = "認識された発言で判断し、BGM は数えません";+"多久算没人说话" = "無音とみなすまで";+"提醒后结束" = "確認してから終了";+"直接结束" = "すぐ終了";+"一直记录" = "記録を続ける";/* Shortcuts */"右 ⌥" = "右⌥";@@ -591,10 +637,13 @@/* Views */"自动识别(%@)" = "自動検出(%@)";"%@(需下载)" = "%@(要ダウンロード)";+"会议已自动结束" = "会議は自動で終了しました";"系统" = "システム";"仅本场" = "この会議のみ";"按住" = "押す";"说%@ → %@" = "%1$@ → %2$@";+"%@已选虚拟麦克风" = "%@ は仮想マイクを選択済み";+"%@没选虚拟麦克风,对方听不到译文" = "%@ が仮想マイクを選んでいないため、相手に訳文が届きません";"虚拟麦克风尚未设置好,对方听不到你的声音" = "仮想マイクが未設定のため、相手にあなたの声は届きません";"纪要、文字记录和字幕都在一个窗口里" = "議事メモ、文字起こし、字幕を1つのウインドウに表示";"填入 API key 后可生成纪要;文字记录照常保存" = "API key を入力すると議事メモを作成できます。文字起こしは常に保存されます";diff --git a/Resources/ko.lproj/Localizable.strings b/Resources/ko.lproj/Localizable.stringsindex 3c64412..89c9ffe 100644--- a/Resources/ko.lproj/Localizable.strings+++ b/Resources/ko.lproj/Localizable.strings@@ -103,6 +103,10 @@"与另一个快捷键冲突" = "다른 단축키와 충돌합니다";"%@ 是系统快捷键,换一个吧" = "%@은(는) 시스템 단축키입니다. 다른 키를 선택하세요";"%@ 已被其他应用占用,换一个吧" = "%@은(는) 다른 앱에서 사용 중입니다. 다른 키를 선택하세요";+"%lld 秒后结束" = "%lld초 후 종료";+"%@ 已挂断" = "%@ 통화가 종료됨";+"已经 %lld 分钟没人说话" = "%lld분 동안 아무도 말하지 않았습니다";+"%lld 秒后结束会议并整理纪要" = "%lld초 후 회의를 끝내고 회의록을 정리합니다";"欢迎使用%@" = "%@에 오신 것을 환영합니다";"设置" = "설정";"正在记录会议" = "회의를 기록하는 중";@@ -202,6 +206,37 @@"正在识别语言…" = "언어 감지 중…";"翻译暂不可用" = "번역을 일시적으로 사용할 수 없음";+/* MicUsersView */+"这里只显示正在用麦克风的会议软件和常见会议软件,麦克风要在各软件里自己换。" = "마이크를 쓰는 회의 앱과 주요 회의 앱만 표시해요. 마이크는 각 앱에서 바꿔 주세요.";+"会议软件的麦克风" = "회의 앱 마이크";+"实时更新" = "실시간";+"还没有会议软件在用麦克风,进会议后这里会显示" = "아직 마이크를 쓰는 회의 앱이 없어요. 회의에 들어가면 여기에 표시돼요";+"空闲" = "대기 중";+"怎么改" = "바꾸는 법";+"正在用虚拟麦克风" = "가상 마이크 사용 중";+"没用虚拟麦克风,对方听不到译文" = "가상 마이크가 아니라 상대가 번역을 못 들어요";+"正在用 %@,对方听不到译文" = "%@ 사용 중이라 상대가 번역을 못 들어요";+"没开麦克风" = "마이크 안 씀";+"对方能听到" = "상대가 들어요";+"顺便关掉自动调节麦克风音量和降噪,译文会更清楚" = "마이크 음량 자동 조절과 소음 억제도 끄면 번역이 더 또렷하게 들려요";+"进会议后,点麦克风图标旁边的 ⌃" = "회의 중 마이크 아이콘 옆의 ⌃ 를 클릭";+"在选择麦克风菜单里点 %@" = "마이크 선택 메뉴에서 %@ 선택";+"在会议网页的音频设置里,把麦克风选为 %@" = "회의 페이지의 오디오 설정에서 마이크를 %@(으)로 선택";+"想让所有网页默认用它:Chrome 设置 › 隐私和安全 › 网站设置 › 麦克风" = "모든 사이트의 기본값으로 하려면: Chrome 설정 › 개인 정보 보호 및 보안 › 사이트 설정 › 마이크";+"打开%@的音频设置" = "%@의 오디오 설정 열기";+"把麦克风选为 %@" = "마이크를 %@(으)로 선택";+"换用虚拟麦克风后,对方只能听到译文,听不到你说话的原声。" = "가상 마이크로 바꾸면 상대는 번역만 듣고 원래 목소리는 듣지 못해요.";+"在%@里使用虚拟麦克风" = "%@에서 가상 마이크 사용";+"改好一次,下次开会不用再改" = "한 번 바꾸면 다음 회의부터는 그대로예요";+"好了" = "완료";+"先不改" = "나중에";+"打开%@" = "%@ 열기";+"%@当前麦克风" = "%@ 현재 마이크";+"选对后这里会自动变绿" = "제대로 고르면 자동으로 초록색이 돼요";+"没开麦克风,进会议后这里会显示" = "마이크를 안 쓰는 중이에요. 회의에 들어가면 여기에 표시돼요";+"%@,对方能听到译文" = "%@, 상대가 번역을 들어요";+"其他麦克风" = "다른 마이크";+/* NotesViews */"总结" = "요약";"刚更新" = "방금 업데이트";@@ -232,6 +267,7 @@"已听到 %lld 句" = "%lld문장 들음";"正在生成纪要" = "회의록 작성 중";"正在更新" = "업데이트 중";+"现在结束" = "지금 끝내기";/* NotesWindow */"key 已失效(令牌被删或免费额度用尽),纪要停留在 %@。" = "key가 만료되었습니다(토큰 삭제 또는 무료 한도 소진). 회의록은 %@까지만 작성되었습니다.";@@ -336,12 +372,14 @@"正在听…" = "듣는 중…";"听到" = "들린 내용";"自动 · %@" = "자동 · %@";-"最后一步:在会议软件中,将麦克风选为 " = "마지막 단계: 회의 앱에서 마이크를 다음으로 선택하세요: ";"想让对方听懂你?" = "상대가 내 말을 알아듣게 할까요?";"按住说%@,对方听到翻译后的语音。" = "누르고 %@로 말하면 상대가 번역된 음성을 듣습니다.";"可在设置中更改" = "설정에서 변경할 수 있습니다";"右侧 option" = "오른쪽 option";"按住说话" = "누르고 말하기";+"%@已选虚拟麦克风,对方能听到译文" = "%@에서 가상 마이크를 골랐어요. 상대가 번역을 들어요";+"最后一步:在会议软件中,将麦克风选为 " = "마지막 단계: 회의 앱에서 마이크를 다음으로 선택하세요: ";+"等你选好…" = "선택을 기다리는 중…";/* OnboardingKey */"接上 Ling,用上完整的知了" = "Ling을 연결하고 Cicada를 온전히 쓰세요";@@ -447,6 +485,14 @@"只存在这台 Mac 上" = "이 Mac에만 저장됨";"记录文件夹" = "기록 폴더";"打开" = "열기";+"会议应用挂断后结束" = "회의 앱 통화가 끝나면 종료";+"Zoom、腾讯会议、飞书、Teams 等" = "Zoom, Tencent Meeting, Lark, Teams 등";+"没人说话时" = "아무도 말하지 않을 때";+"按识别出的话算,背景音乐不算" = "인식된 말 기준이며 배경음악은 제외";+"多久算没人说话" = "말이 없다고 볼 시간";+"提醒后结束" = "알린 뒤 종료";+"直接结束" = "바로 종료";+"一直记录" = "계속 기록";/* Shortcuts */"右 ⌥" = "오른쪽 ⌥";@@ -591,10 +637,13 @@/* Views */"自动识别(%@)" = "자동 감지(%@)";"%@(需下载)" = "%@(다운로드 필요)";+"会议已自动结束" = "회의가 자동으로 종료됨";"系统" = "시스템";"仅本场" = "이번 회의만";"按住" = "누르기";"说%@ → %@" = "%1$@ → %2$@";+"%@已选虚拟麦克风" = "%@ 가상 마이크 선택됨";+"%@没选虚拟麦克风,对方听不到译文" = "%@에서 가상 마이크를 안 골라 상대가 번역을 못 들어요";"虚拟麦克风尚未设置好,对方听不到你的声音" = "가상 마이크가 설정되지 않아 상대가 내 목소리를 들을 수 없습니다";"纪要、文字记录和字幕都在一个窗口里" = "회의록, 대화 기록, 자막을 한 창에서 확인합니다";"填入 API key 后可生成纪要;文字记录照常保存" = "API key를 입력하면 회의록을 작성할 수 있으며, 대화 기록은 그대로 저장됩니다";diff --git a/Resources/zh-Hans.lproj/Localizable.strings b/Resources/zh-Hans.lproj/Localizable.stringsindex 7dbc329..d46c9e4 100644--- a/Resources/zh-Hans.lproj/Localizable.strings+++ b/Resources/zh-Hans.lproj/Localizable.strings@@ -103,6 +103,10 @@"与另一个快捷键冲突" = "与另一个快捷键冲突";"%@ 是系统快捷键,换一个吧" = "%@ 是系统快捷键,换一个吧";"%@ 已被其他应用占用,换一个吧" = "%@ 已被其他应用占用,换一个吧";+"%lld 秒后结束" = "%lld 秒后结束";+"%@ 已挂断" = "%@ 已挂断";+"已经 %lld 分钟没人说话" = "已经 %lld 分钟没人说话";+"%lld 秒后结束会议并整理纪要" = "%lld 秒后结束会议并整理纪要";"欢迎使用%@" = "欢迎使用%@";"设置" = "设置";"正在记录会议" = "正在记录会议";@@ -202,6 +206,37 @@"正在识别语言…" = "正在识别语言…";"翻译暂不可用" = "翻译暂不可用";+/* MicUsersView */+"这里只显示正在用麦克风的会议软件和常见会议软件,麦克风要在各软件里自己换。" = "这里只显示正在用麦克风的会议软件和常见会议软件,麦克风要在各软件里自己换。";+"会议软件的麦克风" = "会议软件的麦克风";+"实时更新" = "实时更新";+"还没有会议软件在用麦克风,进会议后这里会显示" = "还没有会议软件在用麦克风,进会议后这里会显示";+"空闲" = "空闲";+"怎么改" = "怎么改";+"正在用虚拟麦克风" = "正在用虚拟麦克风";+"没用虚拟麦克风,对方听不到译文" = "没用虚拟麦克风,对方听不到译文";+"正在用 %@,对方听不到译文" = "正在用 %@,对方听不到译文";+"没开麦克风" = "没开麦克风";+"对方能听到" = "对方能听到";+"顺便关掉自动调节麦克风音量和降噪,译文会更清楚" = "顺便关掉自动调节麦克风音量和降噪,译文会更清楚";+"进会议后,点麦克风图标旁边的 ⌃" = "进会议后,点麦克风图标旁边的 ⌃";+"在选择麦克风菜单里点 %@" = "在选择麦克风菜单里点 %@";+"在会议网页的音频设置里,把麦克风选为 %@" = "在会议网页的音频设置里,把麦克风选为 %@";+"想让所有网页默认用它:Chrome 设置 › 隐私和安全 › 网站设置 › 麦克风" = "想让所有网页默认用它:Chrome 设置 › 隐私和安全 › 网站设置 › 麦克风";+"打开%@的音频设置" = "打开%@的音频设置";+"把麦克风选为 %@" = "把麦克风选为 %@";+"换用虚拟麦克风后,对方只能听到译文,听不到你说话的原声。" = "换用虚拟麦克风后,对方只能听到译文,听不到你说话的原声。";+"在%@里使用虚拟麦克风" = "在%@里使用虚拟麦克风";+"改好一次,下次开会不用再改" = "改好一次,下次开会不用再改";+"好了" = "好了";+"先不改" = "先不改";+"打开%@" = "打开%@";+"%@当前麦克风" = "%@当前麦克风";+"选对后这里会自动变绿" = "选对后这里会自动变绿";+"没开麦克风,进会议后这里会显示" = "没开麦克风,进会议后这里会显示";+"%@,对方能听到译文" = "%@,对方能听到译文";+"其他麦克风" = "其他麦克风";+/* NotesViews */"总结" = "总结";"刚更新" = "刚更新";@@ -232,6 +267,7 @@"已听到 %lld 句" = "已听到 %lld 句";"正在生成纪要" = "正在生成纪要";"正在更新" = "正在更新";+"现在结束" = "现在结束";/* NotesWindow */"key 已失效(令牌被删或免费额度用尽),纪要停留在 %@。" = "key 已失效(令牌被删或免费额度用尽),纪要停留在 %@。";@@ -336,12 +372,14 @@"正在听…" = "正在听…";"听到" = "听到";"自动 · %@" = "自动 · %@";-"最后一步:在会议软件中,将麦克风选为 " = "最后一步:在会议软件中,将麦克风选为 ";"想让对方听懂你?" = "想让对方听懂你?";"按住说%@,对方听到翻译后的语音。" = "按住说%@,对方听到翻译后的语音。";"可在设置中更改" = "可在设置中更改";"右侧 option" = "右侧 option";"按住说话" = "按住说话";+"%@已选虚拟麦克风,对方能听到译文" = "%@已选虚拟麦克风,对方能听到译文";+"最后一步:在会议软件中,将麦克风选为 " = "最后一步:在会议软件中,将麦克风选为 ";+"等你选好…" = "等你选好…";/* OnboardingKey */"接上 Ling,用上完整的知了" = "接上 Ling,用上完整的知了";@@ -447,6 +485,14 @@"只存在这台 Mac 上" = "只存在这台 Mac 上";"记录文件夹" = "记录文件夹";"打开" = "打开";+"会议应用挂断后结束" = "会议应用挂断后结束";+"Zoom、腾讯会议、飞书、Teams 等" = "Zoom、腾讯会议、飞书、Teams 等";+"没人说话时" = "没人说话时";+"按识别出的话算,背景音乐不算" = "按识别出的话算,背景音乐不算";+"多久算没人说话" = "多久算没人说话";+"提醒后结束" = "提醒后结束";+"直接结束" = "直接结束";+"一直记录" = "一直记录";/* Shortcuts */"右 ⌥" = "右 ⌥";@@ -591,10 +637,13 @@/* Views */"自动识别(%@)" = "自动识别(%@)";"%@(需下载)" = "%@(需下载)";+"会议已自动结束" = "会议已自动结束";"系统" = "系统";"仅本场" = "仅本场";"按住" = "按住";"说%@ → %@" = "说%@ → %@";+"%@已选虚拟麦克风" = "%@已选虚拟麦克风";+"%@没选虚拟麦克风,对方听不到译文" = "%@没选虚拟麦克风,对方听不到译文";"虚拟麦克风尚未设置好,对方听不到你的声音" = "虚拟麦克风尚未设置好,对方听不到你的声音";"纪要、文字记录和字幕都在一个窗口里" = "纪要、文字记录和字幕都在一个窗口里";"填入 API key 后可生成纪要;文字记录照常保存" = "填入 API key 后可生成纪要;文字记录照常保存";diff --git a/Sources/LiveSubs/AppModel.swift b/Sources/LiveSubs/AppModel.swiftindex 38dabdb..ba444f5 100644--- a/Sources/LiveSubs/AppModel.swift+++ b/Sources/LiveSubs/AppModel.swift@@ -22,10 +22,23 @@ final class AppModel: ObservableObject {}/// The 试一句 sheet in settings.@Published var speakTestShown = false+ /// Meeting apps and the microphone each reads; refreshed every second once the virtual mic exists.+ @Published var micUsers: [MicUser] = []+ /// The app whose "怎么改" sheet is open in Settings.+ @Published var micGuide: MicUser?/// Settings › 同声传译: the voice list under "对方听到" is open.@Published var voicePickerOpen = false@Published var running = false+ /// The meeting is about to end by itself (a hang-up or a long silence) unless someone keeps it going.+ @Published private(set) var ending: MeetingEndWatch.Pending?+ /// The last meeting ended by itself: the menu says so, and the next call in a meeting app starts a new one.+ @Published private(set) var autoEnded = false+ private var endWatch: MeetingEndWatch?+ private var endTimer: Timer?+ /// Debug: meeting apps in a call instead of what Core Audio says, and shorter waits.+ private var fakeCalls: [String: String]?+ private var endTimesOverride: (silence: Double, countdown: Double, grace: Double)?@Published var status = L("准备就绪")@Published var summary = ""@Published var installed: Set<String> = []@@ -74,7 +87,7 @@ final class AppModel: ObservableObject {listen.onSubtitle = { [weak self] src, dst inself?.liveSource = srcself?.liveTranslation = dst- if !src.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty { self?.heardSpeech() }+ if !src.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty { self?.heardSpeech(); self?.heardWords() }guard let self, self.settings.displayMode == "bar" else { return }self.overlay.clearStatus()let shown = self.displayed(src, dst)@@ -133,7 +146,7 @@ final class AppModel: ObservableObject {self.speakPhase = phase// A 试一句 rehearsal shows in its own sheet: no notes window, caption or subtitle bar.if self.speakTester.busy { return }- if phase == .listening && !src.isEmpty { self.heardSpeech() }+ if phase == .listening && !src.isEmpty { self.heardSpeech(); self.heardWords() }guard self.settings.displayMode == "bar" else {// The notes window's caption line shows what you are saying.if phase != .idle || !src.isEmpty {@@ -178,6 +191,11 @@ final class AppModel: ObservableObject {}applyToggleKey()refreshOutputs()+ let watch = Timer(timeInterval: 2, repeats: true) { [weak self] _ in+ MainActor.assumeIsolated { self?.watchEnd() }+ }+ endTimer = watch+ RunLoop.main.add(watch, forMode: .common)}func setOverlayAuto(_ on: Bool) {@@ -217,6 +235,26 @@ final class AppModel: ObservableObject {let devices = AudioDevices.outputs()if devices.map(\.uid) != outputs.map(\.uid) { outputs = devices }if listen.isRunning && !systemAudioOK { systemAudioOK = true }+ refreshMicUsers()+ }++ func refreshMicUsers() {+ // Compare against where our voice actually goes: 高级 › 声音输出到 can point elsewhere.+ let target = outputs.first { !settings.speakOutput.isEmpty && $0.uid == settings.speakOutput } ?? virtualMic+ let users = virtualMic != nil ? target.map { MicUsers.current(virtualMic: $0.id) } ?? [] : []+ if users != micUsers { micUsers = users }+ }++ /// Opens the "怎么改" sheet for an app, from the panel or Settings.+ func showMicGuide(_ user: MicUser) {+ micGuide = user+ openSettings(.speak)+ }++ /// Brings a meeting app forward so the user can change its microphone.+ func openApp(_ bundleID: String) {+ guard let url = NSWorkspace.shared.urlForApplication(withBundleIdentifier: bundleID) else { return }+ NSWorkspace.shared.openApplication(at: url, configuration: NSWorkspace.OpenConfiguration())}/// Starting the tap triggers the system prompt; if it still fails, open the pane.@@ -271,6 +309,9 @@ final class AppModel: ObservableObject {lineForSegment = [:]speechHeard = falsemeetingSubtitles = nil+ autoEnded = false+ endWatch = MeetingEndWatch(config: endConfig, start: Date())+ setEnding(nil)if settings.recordAudio {listen.router.setRecording(store.systemAudioURL(session.id))speak.setRecording(store.micAudioURL(session.id))@@ -285,12 +326,16 @@ final class AppModel: ObservableObject {refresh()}- func stop() {+ /// `endedAt`: when a meeting that ends by itself really ended (see `autoEnd`).+ func stop(endedAt: Date? = nil) {+ autoEnded = false+ endWatch = nil+ setEnding(nil)diagnostics.end()listen.stop()listen.router.setRecording(nil)speak.setRecording(nil)- store.end()+ store.end(at: endedAt)notes.finish()overlay.hide()refresh()@@ -617,6 +662,85 @@ final class AppModel: ObservableObject {if settings.speakEnabled { Task { await speak.prepare() } }}+ // MARK: Meeting end++ private var endConfig: MeetingEndWatch.Config {+ var c = MeetingEndWatch.Config()+ c.followApps = settings.endWithApp+ c.silence = MeetingEndWatch.Silence(rawValue: settings.silenceEnd) ?? .prompt+ c.silenceAfter = settings.silenceMinutes * 60+ if let o = endTimesOverride { (c.silenceAfter, c.countdown, c.appGrace) = (o.silence, o.countdown, o.grace) }+ return c+ }++ private func heardWords() {+ endWatch?.heard(at: Date())+ setEnding(endWatch?.pending)+ }++ /// Every 2 s: while listening, whether the meeting is over; after one ended by itself, whether+ /// a meeting app started the next call.+ private func watchEnd() {+ if listen.isRunning, var w = endWatch {+ w.config = endConfig+ let said = store.liveID.flatMap { store.session($0) }.map { !$0.lines.isEmpty } ?? false+ let calls = w.config.followApps ? (fakeCalls ?? MicUsers.currentCalls()) : [:]+ let reason = w.tick(at: Date(), calls: calls, said: said)+ endWatch = w+ setEnding(w.pending)+ if let reason { autoEnd(reason, watch: w) }+ } else if !listen.isRunning, autoEnded, settings.endWithApp, !(fakeCalls ?? MicUsers.currentCalls()).isEmpty {+ debugLog("meeting end: a meeting app started a call, starting a new meeting")+ start()+ }+ }++ private func setEnding(_ p: MeetingEndWatch.Pending?) {+ guard p != ending else {+ if p != nil { showEndingOnBar() }+ return+ }+ if let p { debugLog("meeting end: pending \(p.reason), ends in \(Int(p.deadline.timeIntervalSinceNow)) s") }+ else if ending != nil { debugLog("meeting end: pending cleared"); overlay.clearStatus() }+ ending = p+ showEndingOnBar()+ }++ /// The subtitle bar has no buttons: it says what will happen, and speaking keeps a silent meeting going.+ private func showEndingOnBar() {+ guard settings.displayMode == "bar", let p = ending else { return }+ let left = max(0, Int(p.deadline.timeIntervalSinceNow.rounded()))+ overlay.notice(endingTitle(p) + " · " + L("\(left) 秒后结束"))+ }++ func endingTitle(_ p: MeetingEndWatch.Pending) -> String {+ switch p.reason {+ case .appLeft(let name): L("\(name) 已挂断")+ case .silence: L("已经 \(max(1, Int((endConfig.silenceAfter / 60).rounded()))) 分钟没人说话")+ }+ }++ func endingDetail(_ p: MeetingEndWatch.Pending, now: Date = Date()) -> String {+ L("\(max(0, Int(p.deadline.timeIntervalSince(now).rounded()))) 秒后结束会议并整理纪要")+ }++ /// "继续记录" on the ending prompt.+ func keepRecording() {+ endWatch?.keepGoing(at: Date())+ setEnding(nil)+ debugLog("meeting end: kept going")+ }++ /// Ends where the meeting really ended: a little after the last words, or at the hang-up if+ /// that was later. Never before a line that was kept, or its audio would be cut.+ private func autoEnd(_ reason: MeetingEndWatch.Reason, watch w: MeetingEndWatch) {+ var at = w.lastSpeech.addingTimeInterval(5)+ if case .appLeft = reason { at = max(at, Date().addingTimeInterval(-w.config.appGrace)) }+ debugLog("meeting end: ended by itself (\(reason)), end time \(Int(Date().timeIntervalSince(at))) s ago")+ stop(endedAt: at)+ autoEnded = true+ }+// MARK: Meeting recordprivate func recordHeard(_ seg: Segment, duration: Double) {@@ -627,6 +751,7 @@ final class AppModel: ObservableObject {let t = max(0, Date().timeIntervalSince(start) - duration)store.append(TranscriptLine(id: id, t: t, speaker: "them", src: seg.text, dst: seg.translation,srcLang: seg.sourceCode, dstLang: listen.resolvedTarget))+ heardWords()}private func recordSaid(_ src: String, _ dst: String, from: String, to: String, secondsAgo: Double) {@@ -635,6 +760,7 @@ final class AppModel: ObservableObject {let t = max(0, Date().timeIntervalSince(start) - secondsAgo)store.append(TranscriptLine(id: "m\(lineCounter)", t: t, speaker: "me", src: src, dst: dst,srcLang: from, dstLang: to))+ heardWords()}// MARK: Export@@ -713,6 +839,12 @@ final class AppModel: ObservableObject {debugLog("diag report:\n" + diagnostics.report(version: "", model: settings.aiModel))case "micTest": installer.runTest()case "micNext": installer.next()+ case "micUsers":+ refreshMicUsers()+ debugLog("mic users virtual=\(virtualMic?.id ?? 0) readers=\(MicUsers.readers().map { "\($0.bundleID)\($0.inputs)" }) users=\(micUsers.map { "\($0.name)=\($0.state)" })")+ case "micGuide":+ refreshMicUsers()+ if let user = micUsers.first(where: { $0.bundleID == arg || $0.name == arg }) { showMicGuide(user) } else { micGuide = nil }case "talkKey", "toggleKey":let s = arg == "right" ? Shortcut.rightOption : Shortcut(stored: arg)let refusal = s.map { setShortcut($0, for: parts[0] == "talkKey" ? .talk : .toggle) } ?? "bad shortcut"@@ -744,6 +876,17 @@ final class AppModel: ObservableObject {let kv = arg.split(separator: "=", maxSplits: 1).map(String.init)if kv.count == 2 { previewVoice(kv[1], language: kv[0]) }case "notesNow": notes.updateNow()+ case "endSim":+ // endSim:<app name>[,<app name>] pretends those meeting apps are in a call; endSim: none; endSim:off real.+ fakeCalls = arg == "off" ? nil : Dictionary(arg.split(separator: ",").map { ("sim.\($0)", String($0)) }) { a, _ in a }+ debugLog("meeting end: simulated calls \(fakeCalls.map { $0.values.sorted().description } ?? "off")")+ case "endTimes":+ // endTimes:<silence>,<countdown>,<grace> in seconds; endTimes: back to the settings.+ let v = arg.split(separator: ",").compactMap { Double($0) }+ endTimesOverride = v.count == 3 ? (v[0], v[1], v[2]) : nil+ case "endKeep": keepRecording()+ case "endState":+ debugLog("meeting end: running=\(listen.isRunning) autoEnded=\(autoEnded) pending=\(ending.map { "\($0.reason) in \(Int($0.deadline.timeIntervalSinceNow)) s" } ?? "none") inCall=\(endWatch?.inCall.values.sorted() ?? []) silent=\(endWatch.map { Int(Date().timeIntervalSince($0.lastSpeech)) } ?? -1) s config=\(endConfig)")case "updateFeed":// updateFeed:<release json url>: check a fake release (file:// works), even in a dev build.if let url = URL(string: arg) { updates.checker.feed = url }@@ -860,6 +1003,15 @@ final class AppModel: ObservableObject {case "speakTestClose": speakTester.cancel(); speakTestShown = falsecase "speakTestState":debugLog("speak test phase=\(speakTester.phase) reached=\(String(describing: speakTester.reached)) result=\(speakTester.result?.report.replacingOccurrences(of: "\n", with: " | ") ?? "-")")+ case "micGuideRender":+ // micGuideRender:<bundle id>=<png>: the 怎么改 sheet for an app in the list.+ let p = arg.split(separator: "=", maxSplits: 1).map(String.init)+ guard p.count == 2, let user = micUsers.first(where: { $0.bundleID == p[0] }) else { break }+ let r = ImageRenderer(content: MicGuideView(model: self, bundleID: user.bundleID, name: user.name, close: {}).background(Color.white))+ r.scale = 2+ if let img = r.nsImage, let tiff = img.tiffRepresentation, let rep = NSBitmapImageRep(data: tiff) {+ try? rep.representation(using: .png, properties: [:])?.write(to: URL(fileURLWithPath: p[1]))+ }case "speakTestRender":let r = ImageRenderer(content: SpeakTestView(model: self, tester: speakTester, close: {}).background(Color.white))r.scale = 2diff --git a/Sources/LiveSubs/AudioRouter.swift b/Sources/LiveSubs/AudioRouter.swiftindex b6fa81f..adb6f76 100644--- a/Sources/LiveSubs/AudioRouter.swift+++ b/Sources/LiveSubs/AudioRouter.swift@@ -221,12 +221,14 @@ enum AudioFileWriter {/// Rewraps `partial(url)` into `url` without re-encoding, then removes the partial file./// A partial file next to an .m4a means the last rewrap was cut short: it is done again.- nonisolated static func finish(_ url: URL) async {+ /// `until`: seconds to keep from the start (the silent tail of a meeting that ended by itself).+ nonisolated static func finish(_ url: URL, until: Double? = nil) async {let src = partial(url)guard FileManager.default.fileExists(atPath: src.path) else { return }try? FileManager.default.removeItem(at: url)let asset = AVURLAsset(url: src)guard let export = AVAssetExportSession(asset: asset, presetName: AVAssetExportPresetPassthrough) else { return }+ if let until { export.timeRange = CMTimeRange(start: .zero, duration: CMTime(seconds: until, preferredTimescale: 600)) }do {try await export.export(to: url, as: .m4a)try? FileManager.default.removeItem(at: src)diff --git a/Sources/LiveSubs/MeetingEnd.swift b/Sources/LiveSubs/MeetingEnd.swiftnew file mode 100644index 0000000..39feb90--- /dev/null+++ b/Sources/LiveSubs/MeetingEnd.swift@@ -0,0 +1,94 @@+import Foundation++/// Decides when a meeting is over, so one nobody ended doesn't run on for hours and pull the next+/// video or meeting into its notes.+///+/// Two signals. The main one: a meeting app (Zoom, 腾讯会议…) that was reading a microphone during+/// this meeting lets go of it, which is what hanging up looks like from outside; a short grace+/// covers switching devices. The fallback, for meetings in a browser or in the room: nothing was+/// recognised for a while. "Nothing recognised" counts words, not sound, so background music+/// doesn't keep a meeting alive. While a meeting app is still in a call, silence doesn't count:+/// muted webinars and quiet screen shares are still meetings. Pure; `AppModel` ticks it.+struct MeetingEndWatch: Equatable {+ enum Silence: String { case prompt, end, off }++ struct Config: Equatable {+ var followApps = true+ var silence: Silence = .prompt+ var silenceAfter: TimeInterval = 600+ /// How long the "没人说话" prompt waits before ending.+ var countdown: TimeInterval = 60+ /// How long after a hang-up before ending: a device switch drops the mic for a moment.+ var appGrace: TimeInterval = 30+ }++ enum Reason: Equatable {+ /// The meeting app (by name) hung up.+ case appLeft(String)+ case silence+ }++ struct Pending: Equatable {+ var reason: Reason+ var deadline: Date+ }++ var config: Config+ /// The meeting ends at `deadline` unless someone keeps it going.+ private(set) var pending: Pending?+ private(set) var lastSpeech: Date+ /// Meeting apps seen in a call during this meeting (bundle id → name).+ private(set) var inCall: [String: String] = [:]++ init(config: Config, start: Date) {+ self.config = config+ lastSpeech = start+ }++ /// Words were recognised (theirs or mine): a silence countdown stops. A hang-up doesn't: the+ /// next video would talk over it.+ mutating func heard(at now: Date) {+ lastSpeech = now+ if pending?.reason == .silence { pending = nil }+ }++ /// "继续记录": forget the hang-up and start counting silence again.+ mutating func keepGoing(at now: Date) {+ pending = nil+ lastSpeech = now+ inCall = [:]+ }++ /// `calls`: meeting apps reading a microphone now. `said`: the meeting has lines. One without+ /// keeps listening (nothing is kept until someone speaks, and the subtitles stay ready); a call+ /// that ended before anyone spoke doesn't count. Returns why the meeting ends now, if it does.+ mutating func tick(at now: Date, calls: [String: String], said: Bool) -> Reason? {+ guard said else {+ inCall = config.followApps ? calls : [:]+ pending = nil+ return nil+ }+ if config.followApps {+ for (id, name) in calls { inCall[id] = name }+ let hungUp = !inCall.isEmpty && inCall.keys.allSatisfy { calls[$0] == nil }+ if case .appLeft = pending?.reason, !hungUp { pending = nil } // rejoined+ if hungUp, pending == nil || pending?.reason == .silence {+ let name = inCall.sorted { $0.key < $1.key }.first?.value ?? ""+ pending = Pending(reason: .appLeft(name), deadline: now.addingTimeInterval(config.appGrace))+ }+ } else if case .appLeft = pending?.reason {+ pending = nil+ }+ let inACall = config.followApps && !calls.isEmpty+ if pending == nil, config.silence != .off, !inACall, now.timeIntervalSince(lastSpeech) >= config.silenceAfter {+ if config.silence == .end { return .silence }+ pending = Pending(reason: .silence, deadline: now.addingTimeInterval(config.countdown))+ }+ if config.silence == .off || inACall, pending?.reason == .silence { pending = nil }+ if let p = pending, now >= p.deadline {+ pending = nil+ return p.reason+ }+ return nil+ }+}diff --git a/Sources/LiveSubs/MicUsers.swift b/Sources/LiveSubs/MicUsers.swiftnew file mode 100644index 0000000..796cc6b--- /dev/null+++ b/Sources/LiveSubs/MicUsers.swift@@ -0,0 +1,137 @@+import AppKit+import CoreAudio+import Foundation++/// Which microphone each meeting app is reading, so we can say who hears the translation.+///+/// macOS doesn't let one app pick another app's microphone, so all we can do is look: Core Audio+/// lists every process using audio (macOS 14.2+) with the input devices it has open. An app that+/// has no input open shows as idle; we can't know what it would pick when it starts.+///+/// BlackHole is one device with both sides, so a process that only plays into it (a recorder or+/// router holding an IO proc) also lists it as an input: it would read as hearing the translation.+/// Meeting apps that picked it as their mic are the case this is for.+struct MicUser: Identifiable, Equatable {+ enum State: Equatable {+ case virtualMic+ case otherMic(String)+ case idle+ }++ let bundleID: String+ let name: String+ let state: State+ var id: String { bundleID }+}++enum MicUsers {+ /// Dedicated meeting apps: listed while running, even when idle. Browsers and chat apps are+ /// listed only while they read a microphone, or the list would always show them.+ static let meetingApps: Set<String> = [+ "us.zoom.xos", "com.tencent.meeting", "com.microsoft.teams2", "com.microsoft.teams",+ "com.electron.lark", "com.bytedance.lark", "com.alibaba.DingTalkMac", "Cisco-Systems.Spark",+ ]++ /// One audio-reading process: its bundle id and the input devices it has open.+ struct Reader: Equatable {+ var bundleID: String+ var inputs: [AudioObjectID]+ }++ /// The app a process belongs to. Browsers and Electron apps capture audio in helper processes+ /// (`com.google.Chrome.helper`), so walk up the bundle id until it names a running app.+ /// Safari and other WebKit apps capture in the shared GPU process; it's Safari in practice.+ static func owner(of bundleID: String, running: Set<String>) -> String? {+ if bundleID.hasPrefix("com.apple.WebKit") { return running.contains("com.apple.Safari") ? "com.apple.Safari" : nil }+ var parts = bundleID.split(separator: ".").map(String.init)+ while !parts.isEmpty {+ let id = parts.joined(separator: ".")+ if running.contains(id) { return id }+ parts.removeLast()+ }+ return nil+ }++ /// Pure merge of what Core Audio reports with the running apps: readers first (the ones that+ /// can't hear the translation before the ones that can), then idle meeting apps, each by name.+ static func merge(readers: [Reader], running: [String: String], virtualMic: AudioObjectID,+ deviceName: (AudioObjectID) -> String?, ownBundleID: String) -> [MicUser] {+ let ids = Set(running.keys)+ var inputs: [String: Set<AudioObjectID>] = [:]+ for r in readers where !r.inputs.isEmpty {+ guard let app = owner(of: r.bundleID, running: ids), app != ownBundleID else { continue }+ inputs[app, default: []].formUnion(r.inputs)+ }+ var users = inputs.map { app, devices -> MicUser in+ // An app may hold several inputs open; any one being the virtual mic means it hears us.+ let state: MicUser.State = devices.contains(virtualMic)+ ? .virtualMic+ : .otherMic(devices.sorted().compactMap(deviceName).first ?? "")+ return MicUser(bundleID: app, name: running[app] ?? app, state: state)+ }+ for app in ids.intersection(meetingApps) where inputs[app] == nil {+ users.append(MicUser(bundleID: app, name: running[app] ?? app, state: .idle))+ }+ func rank(_ s: MicUser.State) -> Int {+ switch s { case .otherMic: 0; case .virtualMic: 1; case .idle: 2 }+ }+ return users.sorted { (rank($0.state), $0.name) < (rank($1.state), $1.name) }+ }++ /// The apps using a microphone now, plus idle meeting apps.+ @MainActor+ static func current(virtualMic: AudioObjectID) -> [MicUser] {+ var running: [String: String] = [:]+ for app in NSWorkspace.shared.runningApplications {+ guard let id = app.bundleIdentifier else { continue }+ running[id] = app.localizedName ?? id+ }+ return merge(readers: readers(), running: running, virtualMic: virtualMic,+ deviceName: AudioDevices.name, ownBundleID: Bundle.main.bundleIdentifier ?? "")+ }++ /// Meeting apps in a call: reading a microphone, any microphone (bundle id → name). Browsers+ /// aren't counted: their mic use doesn't say a meeting started or ended.+ static func calls(readers: [Reader], running: [String: String]) -> [String: String] {+ let ids = Set(running.keys)+ var out: [String: String] = [:]+ for r in readers where !r.inputs.isEmpty {+ if let app = owner(of: r.bundleID, running: ids), meetingApps.contains(app) { out[app] = running[app] ?? app }+ }+ return out+ }++ @MainActor+ static func currentCalls() -> [String: String] {+ var running: [String: String] = [:]+ for app in NSWorkspace.shared.runningApplications {+ guard let id = app.bundleIdentifier, meetingApps.contains(id) else { continue }+ running[id] = app.localizedName ?? id+ }+ return running.isEmpty ? [:] : calls(readers: readers(), running: running)+ }++ /// Core Audio's process objects that have input running.+ static func readers() -> [Reader] {+ let system = AudioObjectID(kAudioObjectSystemObject)+ return objects(system, kAudioHardwarePropertyProcessObjectList).compactMap { process in+ var running: UInt32 = 0+ var size = UInt32(MemoryLayout<UInt32>.size)+ var addr = AudioObjectPropertyAddress(mSelector: kAudioProcessPropertyIsRunningInput,+ mScope: kAudioObjectPropertyScopeGlobal, mElement: kAudioObjectPropertyElementMain)+ guard AudioObjectGetPropertyData(process, &addr, 0, nil, &size, &running) == noErr, running != 0,+ let bundleID = AudioDevices.string(process, kAudioProcessPropertyBundleID), !bundleID.isEmpty else { return nil }+ return Reader(bundleID: bundleID, inputs: objects(process, kAudioProcessPropertyDevices, scope: kAudioObjectPropertyScopeInput))+ }+ }++ private static func objects(_ object: AudioObjectID, _ selector: AudioObjectPropertySelector,+ scope: AudioObjectPropertyScope = kAudioObjectPropertyScopeGlobal) -> [AudioObjectID] {+ var addr = AudioObjectPropertyAddress(mSelector: selector, mScope: scope, mElement: kAudioObjectPropertyElementMain)+ var size: UInt32 = 0+ guard AudioObjectGetPropertyDataSize(object, &addr, 0, nil, &size) == noErr, size > 0 else { return [] }+ var ids = [AudioObjectID](repeating: 0, count: Int(size) / MemoryLayout<AudioObjectID>.size)+ guard AudioObjectGetPropertyData(object, &addr, 0, nil, &size, &ids) == noErr else { return [] }+ return ids+ }+}diff --git a/Sources/LiveSubs/MicUsersView.swift b/Sources/LiveSubs/MicUsersView.swiftnew file mode 100644index 0000000..0461134--- /dev/null+++ b/Sources/LiveSubs/MicUsersView.swift@@ -0,0 +1,196 @@+import AppKit+import SwiftUI++/// Settings › 同声传译: each meeting app and the microphone it reads.+struct MicUsersSection: View {+ @ObservedObject var model: AppModel++ var body: some View {+ VStack(alignment: .leading, spacing: 8) {+ HStack(alignment: .firstTextBaseline) {+ Text("会议软件的麦克风").font(.system(size: 13, weight: .semibold)).foregroundStyle(Palette.ink)+ Spacer()+ Text("实时更新").font(.system(size: 11)).foregroundStyle(Palette.tertiary)+ }+ .padding(.horizontal, 4)+ SettingsCard {+ if model.micUsers.isEmpty {+ Text("还没有会议软件在用麦克风,进会议后这里会显示")+ .font(.system(size: 12)).foregroundStyle(Palette.tertiary)+ .frame(maxWidth: .infinity, alignment: .leading)+ .padding(.horizontal, 16).padding(.vertical, 14)+ }+ ForEach(Array(model.micUsers.enumerated()), id: \.element.id) { i, user in+ if i > 0 { Divider().padding(.leading, 56) }+ row(user)+ }+ }+ // The tinted problem row would otherwise square off the card's corners.+ .clipShape(RoundedRectangle(cornerRadius: 12))+ Text("这里只显示正在用麦克风的会议软件和常见会议软件,麦克风要在各软件里自己换。")+ .font(.system(size: 11)).foregroundStyle(Palette.tertiary)+ .fixedSize(horizontal: false, vertical: true)+ .padding(.horizontal, 4)+ }+ .sheet(item: $model.micGuide) { user in+ MicGuideView(model: model, bundleID: user.bundleID, name: user.name) { model.micGuide = nil }+ }+ }++ private func row(_ user: MicUser) -> some View {+ HStack(spacing: 12) {+ AppIcon(bundleID: user.bundleID, size: 28)+ VStack(alignment: .leading, spacing: 2) {+ Text(user.name).font(.system(size: 13, weight: .semibold)).foregroundStyle(Palette.ink).lineLimit(1)+ Text(MicUserCopy.detail(user.state)).font(.system(size: 11))+ .foregroundStyle(user.state.isOther ? Palette.accentInk : Palette.tertiary)+ .lineLimit(2).fixedSize(horizontal: false, vertical: true)+ }+ Spacer(minLength: 8)+ switch user.state {+ case .virtualMic:+ HStack(spacing: 6) {+ Circle().fill(Palette.ok).frame(width: 7, height: 7)+ Text("对方能听到").font(.system(size: 12, weight: .medium)).foregroundStyle(Palette.ok)+ }+ .padding(.horizontal, 10).frame(height: 24)+ .background(Capsule().fill(Palette.okPale))+ case .otherMic:+ SoftButton(L("怎么改"), dark: true) { model.micGuide = user }+ case .idle:+ Text("空闲").font(.system(size: 12)).foregroundStyle(Palette.tertiary)+ }+ }+ .padding(.horizontal, 16).padding(.vertical, 10)+ .background(user.state.isOther ? Palette.accentPale : Color.clear)+ }+}++enum MicUserCopy {+ static func detail(_ state: MicUser.State) -> String {+ switch state {+ case .virtualMic: L("正在用虚拟麦克风")+ case .otherMic(let mic): mic.isEmpty ? L("没用虚拟麦克风,对方听不到译文") : L("正在用 \(mic),对方听不到译文")+ case .idle: L("没开麦克风")+ }+ }+}++extension MicUser.State {+ var isOther: Bool { if case .otherMic = self { true } else { false } }+}++/// The app's own icon, so the row reads at a glance.+struct AppIcon: View {+ let bundleID: String+ var size: CGFloat = 28++ var body: some View {+ Image(nsImage: Self.icon(bundleID)).resizable().frame(width: size, height: size)+ }++ private static func icon(_ bundleID: String) -> NSImage {+ if let url = NSWorkspace.shared.urlForApplication(withBundleIdentifier: bundleID) {+ return NSWorkspace.shared.icon(forFile: url.path)+ }+ return NSWorkspace.shared.icon(for: .application)+ }+}++/// "怎么改": the steps for one app, with its microphone checked live so the user sees it turn green.+struct MicGuideView: View {+ @ObservedObject var model: AppModel+ let bundleID: String+ let name: String+ let close: () -> Void++ /// The app's state now; idle once it closes its microphone.+ private var state: MicUser.State {+ model.micUsers.first { $0.bundleID == bundleID }?.state ?? .idle+ }++ private var micName: String { model.virtualMic?.name ?? "BlackHole 2ch" }++ /// Only apps whose menus we've checked get exact steps; the rest get the plain instruction.+ private var steps: [String] {+ let tune = L("顺便关掉自动调节麦克风音量和降噪,译文会更清楚")+ switch bundleID {+ case "com.tencent.meeting", "us.zoom.xos":+ return [L("进会议后,点麦克风图标旁边的 ⌃"), L("在选择麦克风菜单里点 \(micName)"), tune]+ // Browsers: the meeting page picks its own mic; Chrome can also set a default for every site.+ case "com.google.Chrome":+ return [L("在会议网页的音频设置里,把麦克风选为 \(micName)"),+ L("想让所有网页默认用它:Chrome 设置 › 隐私和安全 › 网站设置 › 麦克风"), tune]+ case "com.apple.Safari", "com.microsoft.edgemac", "company.thebrowser.Browser":+ return [L("在会议网页的音频设置里,把麦克风选为 \(micName)"), tune]+ default:+ return [L("打开\(name)的音频设置"), L("把麦克风选为 \(micName)"), tune]+ }+ }++ var body: some View {+ VStack(alignment: .leading, spacing: 18) {+ HStack(spacing: 12) {+ AppIcon(bundleID: bundleID, size: 36)+ VStack(alignment: .leading, spacing: 2) {+ Text("在\(name)里使用虚拟麦克风").font(.system(size: 15, weight: .semibold)).foregroundStyle(Palette.ink)+ Text("改好一次,下次开会不用再改").font(.system(size: 12)).foregroundStyle(Palette.secondary)+ }+ }+ VStack(alignment: .leading, spacing: 12) {+ ForEach(Array(steps.enumerated()), id: \.offset) { i, step in+ HStack(alignment: .firstTextBaseline, spacing: 12) {+ Text("\(i + 1)").font(.system(size: 12, weight: .semibold)).foregroundStyle(Palette.ink)+ .frame(width: 22, height: 22).background(Circle().fill(Palette.fill))+ Text(step).font(.system(size: 13)).foregroundStyle(Palette.ink)+ .fixedSize(horizontal: false, vertical: true)+ }+ }+ }+ status+ Text("换用虚拟麦克风后,对方只能听到译文,听不到你说话的原声。")+ .font(.system(size: 12)).foregroundStyle(Palette.secondary)+ .fixedSize(horizontal: false, vertical: true)+ .padding(.horizontal, 14).padding(.vertical, 12)+ .frame(maxWidth: .infinity, alignment: .leading)+ .background(RoundedRectangle(cornerRadius: 10).fill(Palette.accentPale))+ HStack(spacing: 10) {+ Spacer()+ if state == .virtualMic {+ SoftButton(L("好了"), dark: true, action: close)+ } else {+ SoftButton(L("先不改"), action: close)+ SoftButton(L("打开\(name)"), dark: true) { model.openApp(bundleID) }+ }+ }+ }+ .padding(24)+ .frame(width: 440, alignment: .leading)+ }++ @ViewBuilder+ private var status: some View {+ VStack(alignment: .leading, spacing: 8) {+ Text("\(name)当前麦克风").font(.system(size: 12)).foregroundStyle(Palette.secondary)+ switch state {+ case .virtualMic:+ HStack(spacing: 8) {+ Image(systemName: "checkmark.circle.fill").foregroundStyle(Palette.ok)+ Text("\(micName),对方能听到译文").font(.system(size: 13, weight: .semibold)).foregroundStyle(Palette.ok)+ }+ case .otherMic(let mic):+ HStack(spacing: 10) {+ Text(mic.isEmpty ? L("其他麦克风") : mic).font(.system(size: 13)).foregroundStyle(Palette.accentInk)+ Image(systemName: "arrow.right").font(.system(size: 11)).foregroundStyle(Palette.tertiary)+ Text(micName).font(.system(size: 13, weight: .semibold)).foregroundStyle(Palette.ink)+ }+ Text("选对后这里会自动变绿").font(.system(size: 11)).foregroundStyle(Palette.tertiary)+ case .idle:+ Text("没开麦克风,进会议后这里会显示").font(.system(size: 13)).foregroundStyle(Palette.secondary)+ }+ }+ .padding(.horizontal, 16).padding(.vertical, 14)+ .frame(maxWidth: .infinity, alignment: .leading)+ .background(RoundedRectangle(cornerRadius: 10).fill(state == .virtualMic ? Palette.okPale : Palette.fill))+ }+}diff --git a/Sources/LiveSubs/NotesViews.swift b/Sources/LiveSubs/NotesViews.swiftindex 4488f68..2e9b19a 100644--- a/Sources/LiveSubs/NotesViews.swift+++ b/Sources/LiveSubs/NotesViews.swift@@ -784,3 +784,31 @@ struct FadeIn: ViewModifier {.onAppear { if active { withAnimation(.easeOut(duration: 0.6)) { shown = true } } }}}++/// "已经 10 分钟没人说话 · 60 秒后结束": the meeting is about to end by itself. In the notes window+/// and the menu panel; neither takes focus, so a click lands on the buttons at once.+struct MeetingEndingStrip: View {+ @ObservedObject var model: AppModel+ let pending: MeetingEndWatch.Pending+ var compact = false+ @State private var now = Date()+ private let tick = Timer.publish(every: 1, on: .main, in: .common).autoconnect()++ var body: some View {+ VStack(alignment: .leading, spacing: compact ? 8 : 10) {+ VStack(alignment: .leading, spacing: 3) {+ Text(model.endingTitle(pending)).font(.system(size: compact ? 13 : 14, weight: .bold)).lineLimit(2)+ Text(model.endingDetail(pending, now: now)).font(.system(size: 12).monospacedDigit())+ .foregroundStyle(Palette.secondary).lineLimit(2)+ }+ HStack(spacing: 8) {+ SoftButton(L("继续记录"), dark: true) { model.keepRecording() }+ SoftButton(L("现在结束")) { model.stop() }+ }+ }+ .frame(maxWidth: .infinity, alignment: .leading)+ .padding(compact ? 12 : 14)+ .background(RoundedRectangle(cornerRadius: 12).fill(Palette.accentPale))+ .onReceive(tick) { now = $0 }+ }+}diff --git a/Sources/LiveSubs/NotesWindow.swift b/Sources/LiveSubs/NotesWindow.swiftindex 5de6d42..03c4cbf 100644--- a/Sources/LiveSubs/NotesWindow.swift+++ b/Sources/LiveSubs/NotesWindow.swift@@ -444,6 +444,7 @@ struct NotesWindowView: View {@ViewBuilderprivate var meetingBar: some View {if live {+ if let p = model.ending { MeetingEndingStrip(model: model, pending: p).padding(.bottom, confirmEnd ? 8 : 0) }if languageOpen && !confirmEnd { languageCard(session?.id ?? "") }if confirmEnd {VStack(alignment: .leading, spacing: 10) {@@ -682,7 +683,10 @@ struct NotesWindowView: View {Spacer()iconButton("arrow.up.left.and.arrow.down.right", help: L("展开纪要")) { setWidth(460, 760) }}- if catchUp {+ if live, let p = model.ending {+ MeetingEndingStrip(model: model, pending: p, compact: true)+ Spacer(minLength: 0)+ } else if catchUp {Text("这 \(span) 讲了").font(.system(size: 17, weight: .bold))ScrollView {VStack(alignment: .leading, spacing: 12) {diff --git a/Sources/LiveSubs/Onboarding.swift b/Sources/LiveSubs/Onboarding.swiftindex 4d146b3..1100c66 100644--- a/Sources/LiveSubs/Onboarding.swift+++ b/Sources/LiveSubs/Onboarding.swift@@ -513,12 +513,27 @@ struct OnboardingView: View {.background(RoundedRectangle(cornerRadius: 18).fill(Color.white)).overlay(RoundedRectangle(cornerRadius: 18).stroke(Palette.line, lineWidth: 1))+ // Turns green by itself once a meeting app reads the virtual mic.if model.virtualMic != nil && installer.passed {- (Text("最后一步:在会议软件中,将麦克风选为 ") + Text(model.virtualMic?.name ?? "BlackHole 2ch").bold())- .font(.system(size: 13)).foregroundStyle(Palette.ink)+ if let user = model.micUsers.first(where: { $0.state == .virtualMic }) {+ HStack(spacing: 10) {+ Image(systemName: "checkmark.circle.fill").foregroundStyle(Palette.ok)+ Text("\(user.name)已选虚拟麦克风,对方能听到译文").font(.system(size: 13)).foregroundStyle(Palette.ok)+ }+ .padding(.horizontal, 16).padding(.vertical, 12)+ .frame(maxWidth: .infinity, alignment: .leading)+ .background(RoundedRectangle(cornerRadius: 12).fill(Palette.okPale))+ } else {+ HStack(spacing: 10) {+ (Text("最后一步:在会议软件中,将麦克风选为 ") + Text(model.virtualMic?.name ?? "BlackHole 2ch").bold())+ .font(.system(size: 13)).foregroundStyle(Palette.ink)+ Spacer(minLength: 8)+ Text("等你选好…").font(.system(size: 12)).foregroundStyle(Palette.tertiary)+ }.padding(.horizontal, 16).padding(.vertical, 12).frame(maxWidth: .infinity, alignment: .leading).background(RoundedRectangle(cornerRadius: 12).fill(Palette.accentPale))+ }}}}diff --git a/Sources/LiveSubs/Overlay.swift b/Sources/LiveSubs/Overlay.swiftindex 692f5c2..ff1eb35 100644--- a/Sources/LiveSubs/Overlay.swift+++ b/Sources/LiveSubs/Overlay.swift@@ -91,9 +91,19 @@ final class OverlayController {if view.isStatus {view.translation = ""view.isStatus = false+ view.needsDisplay = true}}+ /// A status that has to be seen (the meeting is about to end): brings a tucked-away bar back+ /// and keeps it up while it is repeated.+ func notice(_ text: String) {+ setStatus(text)+ guard view.isStatus else { return }+ lastContentAt = Date()+ expand()+ }+func setSpeaking(_ s: Speaking?) {speakClearWork?.cancel()if s != nil {diff --git a/Sources/LiveSubs/SessionStore.swift b/Sources/LiveSubs/SessionStore.swiftindex 61e7f32..8c0c8df 100644--- a/Sources/LiveSubs/SessionStore.swift+++ b/Sources/LiveSubs/SessionStore.swift@@ -101,9 +101,12 @@ final class SessionStore: ObservableObject {return s}- func end() {+ /// `at`: when the meeting really ended, for one that ended by itself after a hang-up or a+ /// long silence; the recordings are cut there too.+ func end(at: Date? = nil) {guard let id = liveID, let i = index(id) else { liveID = nil; return }- sessions[i].endedAt = Date()+ let now = Date()+ sessions[i].endedAt = at.map { min(now, max(sessions[i].startedAt, $0)) } ?? nowliveID = nilif sessions[i].lines.isEmpty {// Nothing was said: don't keep an empty meeting around.@@ -115,7 +118,7 @@ final class SessionStore: ObservableObject {FileManager.default.fileExists(atPath: $0.path) || FileManager.default.fileExists(atPath: AudioFileWriter.partial($0).path)}saveNow(id)- finishAudio(id)+ finishAudio(id, until: at == nil ? nil : sessions[i].duration)}private func hasPartialAudio(_ id: String) -> Bool {@@ -123,9 +126,9 @@ final class SessionStore: ObservableObject {}/// Turns the meeting's recordings into .m4a files (call after the recorders are closed).- func finishAudio(_ id: String) {+ func finishAudio(_ id: String, until: Double? = nil) {let urls = [systemAudioURL(id), micAudioURL(id)]- Task.detached(priority: .utility) { for u in urls { await AudioFileWriter.finish(u) } }+ Task.detached(priority: .utility) { for u in urls { await AudioFileWriter.finish(u, until: until) } }}var liveStart: Date? { liveID.flatMap { index($0) }.map { sessions[$0].startedAt } }diff --git a/Sources/LiveSubs/Settings.swift b/Sources/LiveSubs/Settings.swiftindex 23c6200..ba2b585 100644--- a/Sources/LiveSubs/Settings.swift+++ b/Sources/LiveSubs/Settings.swift@@ -77,6 +77,19 @@ final class AppSettings: ObservableObject {didSet { save() }}+ /// End the meeting when the meeting app it was heard through hangs up.+ @Published var endWithApp: Bool {+ didSet { save() }+ }+ /// When nobody has said anything for `silenceMinutes`: "prompt" (count down, then end),+ /// "end" or "off". See `MeetingEndWatch`.+ @Published var silenceEnd: String {+ didSet { save() }+ }+ @Published var silenceMinutes: Double {+ didSet { save() }+ }+/// Record per-sentence timings (never text) and show the 诊断 tab. On by default in dev builds.@Published var diagnostics: Bool {didSet { save() }@@ -107,6 +120,9 @@ final class AppSettings: ObservableObject {aiModel = defaults.string(forKey: "aiModel") ?? "Ling-3.1-flash"displayMode = defaults.string(forKey: "displayMode") ?? "notes"speakVoices = defaults.dictionary(forKey: "speakVoices") as? [String: String] ?? [:]+ endWithApp = defaults.object(forKey: "endWithApp") as? Bool ?? true+ silenceEnd = defaults.string(forKey: "silenceEnd") ?? "prompt"+ silenceMinutes = defaults.object(forKey: "silenceMinutes") as? Double ?? 10diagnostics = defaults.object(forKey: "diagnostics") as? Bool ?? DevBuild.isDev}@@ -130,6 +146,9 @@ final class AppSettings: ObservableObject {defaults.set(aiModel, forKey: "aiModel")defaults.set(displayMode, forKey: "displayMode")defaults.set(speakVoices, forKey: "speakVoices")+ defaults.set(endWithApp, forKey: "endWithApp")+ defaults.set(silenceEnd, forKey: "silenceEnd")+ defaults.set(silenceMinutes, forKey: "silenceMinutes")defaults.set(diagnostics, forKey: "diagnostics")}diff --git a/Sources/LiveSubs/SettingsWindow.swift b/Sources/LiveSubs/SettingsWindow.swiftindex 2410b72..666959d 100644--- a/Sources/LiveSubs/SettingsWindow.swift+++ b/Sources/LiveSubs/SettingsWindow.swift@@ -488,6 +488,7 @@ struct SettingsView: View {Divider().padding(.leading, 50)VoiceSection(model: model, settings: settings, ling: model.ling)}+ if model.virtualMic != nil { MicUsersSection(model: model) }DisclosureGroup {SettingsCard {SettingsRow(title: L("声音输出到"), detail: L("对方只能听到虚拟麦克风里的声音"), divider: false) {@@ -604,6 +605,23 @@ struct SettingsView: View {SoftButton(L("打开")) { NSWorkspace.shared.open(model.store.root) }}}+ Text("结束会议").font(.system(size: 13, weight: .semibold)).foregroundStyle(Palette.secondary).padding(.top, 4)+ SettingsCard {+ SettingsRow(title: L("会议应用挂断后结束"), detail: L("Zoom、腾讯会议、飞书、Teams 等")) {+ Toggle("会议应用挂断后结束", isOn: $settings.endWithApp)+ .toggleStyle(.switch).labelsHidden().controlSize(.small).tint(Palette.ink)+ }+ SettingsRow(title: L("没人说话时"), detail: L("按识别出的话算,背景音乐不算"), divider: settings.silenceEnd != "off") {+ Segments(options: [("prompt", L("提醒后结束")), ("end", L("直接结束")), ("off", L("一直记录"))],+ value: settings.silenceEnd) { settings.silenceEnd = $0 }+ }+ if settings.silenceEnd != "off" {+ SettingsRow(title: L("多久算没人说话"), divider: false) {+ Segments(options: [5.0, 10, 15, 30].map { (String(Int($0)), L("\(Int($0)) 分钟")) },+ value: String(Int(settings.silenceMinutes))) { settings.silenceMinutes = Double($0) ?? 10 }+ }+ }+ }AppRows(updates: model.updates, loginItem: model.loginItem, model: model)}}diff --git a/Sources/LiveSubs/SpeakEngine.swift b/Sources/LiveSubs/SpeakEngine.swiftindex 038d309..bca618d 100644--- a/Sources/LiveSubs/SpeakEngine.swift+++ b/Sources/LiveSubs/SpeakEngine.swift@@ -17,7 +17,7 @@ struct OutputDevice: Identifiable, Hashable {}enum AudioDevices {- private static func string(_ device: AudioObjectID, _ selector: AudioObjectPropertySelector) -> String? {+ static func string(_ device: AudioObjectID, _ selector: AudioObjectPropertySelector) -> String? {var value: CFString = "" as CFStringvar size = UInt32(MemoryLayout<CFString>.size)var addr = AudioObjectPropertyAddress(mSelector: selector, mScope: kAudioObjectPropertyScopeGlobal,@@ -49,6 +49,8 @@ enum AudioDevices {static var virtualMic: OutputDevice? { outputs().first(where: \.isVirtualMic) }+ static func name(_ device: AudioObjectID) -> String? { string(device, kAudioObjectPropertyName) }+/// The system output (speakers or headphones): voice previews play here, not into the room.static var defaultOutput: OutputDevice? {var id = AudioObjectID(0)diff --git a/Sources/LiveSubs/Views.swift b/Sources/LiveSubs/Views.swiftindex 9893af9..799586b 100644--- a/Sources/LiveSubs/Views.swift+++ b/Sources/LiveSubs/Views.swift@@ -124,7 +124,7 @@ struct MenuPanelView: View {}HStack(spacing: 6) {Circle().fill(model.running ? Palette.accent : Color.gray.opacity(0.5)).frame(width: 7, height: 7)- Text(model.running ? model.summary : L("已暂停"))+ Text(model.running ? model.summary : model.autoEnded ? L("会议已自动结束") : L("已暂停")).font(.system(size: 12)).foregroundStyle(Palette.secondary).lineLimit(1)}}@@ -133,6 +133,8 @@ struct MenuPanelView: View {.toggleStyle(.switch).labelsHidden().tint(Palette.ink)}+ if let p = model.ending { MeetingEndingStrip(model: model, pending: p, compact: true) }+VStack(spacing: 8) {ChoiceRow(label: L("听到"), value: heardValue.0, badge: heardValue.1, options: sourceOptions) {model.sourceSelection = $0@@ -162,11 +164,28 @@ struct MenuPanelView: View {.foregroundStyle(Palette.secondary).lineLimit(1)}.font(.system(size: 12))+ // Green only when nothing needs fixing; the warning row below covers the rest.+ if settings.speakEnabled, !model.micUsers.contains(where: { $0.state.isOther }),+ let user = model.micUsers.first(where: { $0.state == .virtualMic }) {+ HStack(spacing: 6) {+ Circle().fill(Palette.ok).frame(width: 7, height: 7)+ Text("\(user.name)已选虚拟麦克风").font(.system(size: 12)).foregroundStyle(Palette.secondary)+ }+ }}Spacer()Toggle("同声传译", isOn: Binding(get: { settings.speakEnabled }, set: { model.enableSpeaking($0) })).toggleStyle(.switch).labelsHidden().tint(Palette.ink)}+ if settings.speakEnabled, model.virtualMic != nil, let user = model.micUsers.first(where: { $0.state.isOther }) {+ HStack {+ Text("\(user.name)没选虚拟麦克风,对方听不到译文").font(.system(size: 12)).foregroundStyle(Palette.accentInk)+ Spacer()+ SoftButton(L("怎么改")) { model.showMicGuide(user) }+ }+ .padding(10).frame(maxWidth: .infinity, alignment: .leading)+ .background(RoundedRectangle(cornerRadius: 9).fill(Palette.accentPale))+ }if settings.speakEnabled && model.virtualMic == nil {HStack {Text("虚拟麦克风尚未设置好,对方听不到你的声音").font(.system(size: 12)).foregroundStyle(Palette.accentInk)diff --git a/Tests/LiveSubsTests/MeetingEndTests.swift b/Tests/LiveSubsTests/MeetingEndTests.swiftnew file mode 100644index 0000000..4a1a6bb--- /dev/null+++ b/Tests/LiveSubsTests/MeetingEndTests.swift@@ -0,0 +1,108 @@+import Foundation+import Testing+@testable import LiveSubs++@Suite struct MeetingEndTests {+ let t0 = Date(timeIntervalSince1970: 1_000_000)+ let zoom = ["us.zoom.xos": "Zoom"]++ func watch(_ silence: MeetingEndWatch.Silence = .prompt, followApps: Bool = true) -> MeetingEndWatch {+ var c = MeetingEndWatch.Config()+ c.followApps = followApps+ c.silence = silence+ return MeetingEndWatch(config: c, start: t0)+ }++ func at(_ s: Double) -> Date { t0.addingTimeInterval(s) }++ @Test func hangUpEndsAfterTheGrace() {+ var w = watch()+ #expect(w.tick(at: at(10), calls: zoom, said: true) == nil)+ #expect(w.tick(at: at(20), calls: [:], said: true) == nil)+ #expect(w.pending == .init(reason: .appLeft("Zoom"), deadline: at(50)))+ #expect(w.tick(at: at(49), calls: [:], said: true) == nil)+ #expect(w.tick(at: at(50), calls: [:], said: true) == .appLeft("Zoom"))+ }++ @Test func rejoiningWithinTheGraceKeepsGoing() {+ var w = watch()+ _ = w.tick(at: at(10), calls: zoom, said: true)+ _ = w.tick(at: at(20), calls: [:], said: true)+ #expect(w.tick(at: at(30), calls: zoom, said: true) == nil)+ #expect(w.pending == nil)+ }++ @Test func speechDoesNotCancelAHangUp() {+ var w = watch()+ _ = w.tick(at: at(10), calls: zoom, said: true)+ _ = w.tick(at: at(20), calls: [:], said: true)+ w.heard(at: at(25))+ #expect(w.tick(at: at(50), calls: [:], said: true) == .appLeft("Zoom"))+ }++ @Test func keepGoingForgetsTheHangUp() {+ var w = watch()+ _ = w.tick(at: at(10), calls: zoom, said: true)+ _ = w.tick(at: at(20), calls: [:], said: true)+ w.keepGoing(at: at(30))+ #expect(w.tick(at: at(100), calls: [:], said: true) == nil)+ #expect(w.pending == nil)+ }++ @Test func silencePromptsThenEnds() {+ var w = watch()+ w.heard(at: at(5))+ #expect(w.tick(at: at(604), calls: [:], said: true) == nil)+ #expect(w.pending == nil)+ #expect(w.tick(at: at(605), calls: [:], said: true) == nil)+ #expect(w.pending == .init(reason: .silence, deadline: at(665)))+ #expect(w.tick(at: at(665), calls: [:], said: true) == .silence)+ }++ @Test func wordsCancelTheSilencePrompt() {+ var w = watch()+ _ = w.tick(at: at(600), calls: [:], said: true)+ #expect(w.pending?.reason == .silence)+ w.heard(at: at(620))+ #expect(w.pending == nil)+ #expect(w.tick(at: at(700), calls: [:], said: true) == nil)+ }++ @Test func silenceEndModeEndsAtOnceAndOffNever() {+ var end = watch(.end)+ #expect(end.tick(at: at(600), calls: [:], said: true) == .silence)+ var off = watch(.off)+ #expect(off.tick(at: at(99_999), calls: [:], said: true) == nil)+ #expect(off.pending == nil)+ }++ @Test func silenceDoesNotCountDuringACall() {+ var w = watch()+ #expect(w.tick(at: at(5_000), calls: zoom, said: true) == nil)+ #expect(w.pending == nil)+ // Without following apps, a call says nothing.+ var plain = watch(followApps: false)+ #expect(plain.tick(at: at(600), calls: zoom, said: true) == nil)+ #expect(plain.pending?.reason == .silence)+ }++ @Test func nothingSaidKeepsListening() {+ var w = watch()+ _ = w.tick(at: at(10), calls: zoom, said: false)+ #expect(w.tick(at: at(5_000), calls: [:], said: false) == nil)+ #expect(w.pending == nil)+ // A call that ended before anyone spoke is forgotten once someone does.+ w.heard(at: at(5_001))+ #expect(w.tick(at: at(5_002), calls: [:], said: true) == nil)+ #expect(w.pending == nil)+ }++ @Test func callsCountOnlyMeetingAppsReadingAMic() {+ let calls = MicUsers.calls(+ readers: [.init(bundleID: "us.zoom.xos", inputs: [82]),+ .init(bundleID: "com.tencent.meeting", inputs: []),+ .init(bundleID: "com.google.Chrome.helper", inputs: [82])],+ running: ["us.zoom.xos": "Zoom", "com.tencent.meeting": "腾讯会议", "com.google.Chrome": "Google Chrome"])+ #expect(calls == ["us.zoom.xos": "Zoom"])+ }+}diff --git a/Tests/LiveSubsTests/MicUsersTests.swift b/Tests/LiveSubsTests/MicUsersTests.swiftnew file mode 100644index 0000000..7dbe1cc--- /dev/null+++ b/Tests/LiveSubsTests/MicUsersTests.swift@@ -0,0 +1,41 @@+import Foundation+import Testing+@testable import LiveSubs++@Suite struct MicUsersTests {+ let virtual: UInt32 = 87+ let builtIn: UInt32 = 82+ let names: [UInt32: String] = [87: "BlackHole 2ch", 82: "MacBook Pro 麦克风"]++ @Test func helperProcessesBelongToTheirApp() {+ let running: Set<String> = ["com.google.Chrome", "com.apple.Safari", "us.zoom.xos"]+ #expect(MicUsers.owner(of: "com.google.Chrome.helper", running: running) == "com.google.Chrome")+ #expect(MicUsers.owner(of: "com.google.Chrome.helper.renderer", running: running) == "com.google.Chrome")+ #expect(MicUsers.owner(of: "us.zoom.xos", running: running) == "us.zoom.xos")+ #expect(MicUsers.owner(of: "com.apple.WebKit.GPU", running: running) == "com.apple.Safari")+ #expect(MicUsers.owner(of: "com.apple.WebKit.GPU", running: ["us.zoom.xos"]) == nil)+ #expect(MicUsers.owner(of: "org.example.tool", running: running) == nil)+ }++ @Test func mergeSortsProblemsFirstAndListsIdleMeetingApps() {+ let users = MicUsers.merge(+ readers: [.init(bundleID: "us.zoom.xos", inputs: [virtual]),+ .init(bundleID: "com.tencent.meeting", inputs: [builtIn]),+ .init(bundleID: "com.google.Chrome.helper", inputs: [])],+ running: ["us.zoom.xos": "Zoom", "com.tencent.meeting": "腾讯会议", "com.microsoft.teams2": "Microsoft Teams",+ "com.google.Chrome": "Google Chrome"],+ virtualMic: virtual, deviceName: { names[$0] }, ownBundleID: "com.wquguru.cicada")+ #expect(users.map(\.name) == ["腾讯会议", "Zoom", "Microsoft Teams"])+ #expect(users.map(\.state) == [.otherMic("MacBook Pro 麦克风"), .virtualMic, .idle])+ }++ @Test func anyVirtualInputCountsAndOwnAppIsHidden() {+ let users = MicUsers.merge(+ readers: [.init(bundleID: "com.google.Chrome.helper", inputs: [builtIn]),+ .init(bundleID: "com.google.Chrome.helper", inputs: [virtual]),+ .init(bundleID: "com.wquguru.cicada", inputs: [virtual])],+ running: ["com.google.Chrome": "Google Chrome", "com.wquguru.cicada": "知了"],+ virtualMic: virtual, deviceName: { names[$0] }, ownBundleID: "com.wquguru.cicada")+ #expect(users == [MicUser(bundleID: "com.google.Chrome", name: "Google Chrome", state: .virtualMic)])+ }+}diff --git a/site/changelog.json b/site/changelog.jsonindex 68e571d..5700f2d 100644--- a/site/changelog.json+++ b/site/changelog.json@@ -6,6 +6,16 @@"summary": "对话很快时字幕更早出正式译文,实时纪要的议题不再一开始就切得很碎,并自动跟到正在讲的议题;字幕和纪要的语言也保持一致。","image": null,"items": [+ {+ "kind": "new",+ "title": "忘了点结束,会议也会自己结束。",+ "text": "会议软件(Zoom、腾讯会议、飞书、Teams 等)挂断后,实时纪要窗口提示「已挂断 · 30 秒后结束」,可以点继续记录或现在结束;没在通话、又 10 分钟没人说话时,同样倒计时 60 秒后结束。是否有人说话按识别出的话算,背景音乐不算。记录在最后一句或挂断时结束,录音去掉后面的空白,不会再记几个小时、把之后的视频也并进来。自动结束后,会议软件再开始通话就自动开始新的一场。在设置的通用里可以关掉,或改成直接结束、一直记录,时长可选 5 到 30 分钟。"+ },+ {+ "kind": "new",+ "title": "看得到每个会议软件用的是哪个麦克风。",+ "text": "设置的同声传译里会实时列出会议软件和它正在用的麦克风。没选 BlackHole 2ch 的会标出来,告诉你对方听不到译文,点「怎么改」按步骤切换,选对后自动变绿。菜单栏面板也会提醒,新手引导的最后一步选好后会自己变绿。macOS 不允许一个应用替另一个应用换麦克风,所以知了只负责检查和带路。"+ },{"kind": "fixed","title": "对话很快时,句子更早结束。",diff --git a/tools/README.md b/tools/README.mdindex af0b47a..08a45f6 100644--- a/tools/README.md+++ b/tools/README.md@@ -9,6 +9,7 @@- 开关字幕:`start` / `stop`- 打开界面:`open`(主窗口)、`panel`(菜单栏面板)、`settings[:speak]`(设置,可指定栏目)- 虚拟麦克风:`micTest` 试音(往虚拟麦克风播一句再听回来,结果写进日志),`micNext` 做清单里的下一步+ - 会议软件的麦克风:`micUsers` 把每个读麦克风的进程和列表写进日志,`micGuide:<bundle id 或名字>` 打开怎么改,`micGuideRender:<bundle id>=<png>`- 快捷键:`talkKey:right` 或 `talkKey:<keyCode>:<Carbon 修饰键>` 换说话键(被拒的原因写进日志),`toggleKey:…` 同理,`shortcuts` 把当前状态写进日志- 字幕条:`frame` 把位置写进日志,`place:x,y,宽,字号` 摆到指定位置- 说话同传:`speakOn` / `speakOff` 开关,`speakFile:<音频>` 把文件按实时速度当作麦克风输入,`speakOut:<路径>` 把译文语音另存一份,`speakOutput:<设备名片段>` 改输出设备(留空 = 虚拟麦克风)@@ -18,6 +19,7 @@- 新手引导与窗口:`onboarding:<步骤>`、`samplePlay`、`closeWindow:<main|settings|onboarding>`、`settings:<overlay|language|speak|records|ai|diagnostics>`、`about`- 显示与字幕:`display:<notes|bar|none>`、`subtitles:<both|translation|original>`、`meetingSubtitles:<…>`、`overlayState`、`overlayToggle`、`overlayAuto[:off]`、`hideAfter:<秒>`- 纪要:`notesLang:<mine|source>`、`meetingNotesLang:<…>`、`notesRegenerate:<id>=<mine|source>`、`notesWindow[:x,y,w,h]`、`notesClose`、`notesFrame`、`notesNow`、`notesState`、`notesShow:<id>`、`notesReplay:<id>`、`notesCapturable[:off]`+ - 结束会议:`endSim:<应用名>[,…]` 假装这些会议应用在通话(`endSim:` 全部挂断,`endSim:off` 回到真实情况),`endTimes:<静默秒>,<倒计时秒>,<挂断宽限秒>` 缩短等待(`endTimes:` 回到设置),`endKeep` 等于点“继续记录”,`endState` 写进日志- 渲染(不需要录屏权限):`windowsRender:<目录>`、`settingsRender:<栏目>=<png>`、`notesRender:<png>`、`mainShow:<id>[,transcript]`、`mainRender:<png>`、`speakTestRender:<png>`- AI:`aiKeyFile:<路径>`(从 0600 文件读 key,不经过日志;测完就删掉文件)、`aiCheck`、`aiRemove`、`aiHide:<on|off>`(只在内存里当作没有 key,文件不动;用于截图)、`aiState`、`lingSimulate:<429|hijack|timeout|off>`- 声音:`voice:<语言>[=<id>]`、`voicePreview:<语言>=<id>`、`voiceCloneFile:<wav>`、`voicePicker:<on|off>`