知了 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: switch the system mic to the virtual mic while interpreting
wquguru1674cf71b392
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 9ccce0f..9973ba2 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -3,6 +3,10 @@One section per release, newest first. `scripts/release.sh` needs the section, dated today;the release workflow publishes it as the release notes.+## Unreleased++- New: turning on 同声传译 switches the Mac's system microphone to BlackHole 2ch and switches it back when 同声传译 is turned off or Cicada quits, so a meeting page in Chrome (or any app left on the default microphone) hears the translation with no setup. Cicada itself keeps recording from your real microphone (Settings › 同声传译 › 系统麦克风 lets you pin one). If Cicada didn't get to switch back (it crashed), or AirPods or something else took over the system mic while you were speaking, the menu bar panel says so with a 还原 / 换回 button; the panel's ⋯ menu also has 同声传译设置…, 试一句 and 还原系统麦克风. The switch can be turned off in Settings.+## 2.2.0 — 2026-11-02- 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.diff --git a/README.md b/README.mdindex 0f203f7..622423c 100644--- a/README.md+++ b/README.md@@ -44,7 +44,7 @@ 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. Settings shows which meeting apps are on it, live, and how to switch the ones that aren't.+- **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. While interpreting is on, Cicada makes it the system microphone (and switches back afterwards), so a meeting in Chrome or any app on the default mic needs no setup; 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@@ -114,7 +114,7 @@ The UI is available in English, Chinese, Japanese and Korean, following your mac1. Play any video, livestream or call. The live notes window opens by default, and pressing `⌃⌥S` switches between the notes window, the subtitle bar and hidden.2. Click the Cicada icon in the menu bar to change the spoken language (auto by default), the target translation language, or the display mode.3. To use live notes, paste your [Ling API key](https://chat.ant-ling.com/platform/api) in **Settings › AI Service** or in the notes window prompt.-4. To speak back in another language, turn on **Interpreting** in the menu bar panel, set your meeting app's microphone to **BlackHole 2ch**, and hold the right `⌥` key while speaking.+4. To speak back in another language, turn on **Interpreting** in the menu bar panel and hold the right `⌥` key while speaking. Cicada switches the system microphone to **BlackHole 2ch** while it's on; a meeting app set to a specific microphone needs **BlackHole 2ch** (or the default) picked in its audio settings.5. Open **会议记录** from the menu bar panel to search past transcripts (`⌘F`), generate notes for older sessions, or export to Markdown, Word or SRT.## Roadmapdiff --git a/README.zh-CN.md b/README.zh-CN.mdindex 27e6c28..365d83a 100644--- a/README.zh-CN.md+++ b/README.zh-CN.md@@ -44,7 +44,7 @@### 同声传译(说话也能翻译)-- **按住快捷键说话**。按住键盘右边的 `⌥` 键开口(可改组合键),对方听到的就是翻译后的语音。声音通过虚拟音频驱动 BlackHole 2ch 传给会议软件,在知了里点一下就能从官方下载安装并自动试音。设置里会实时显示哪些会议软件选了它,没选的告诉你怎么改。+- **按住快捷键说话**。按住键盘右边的 `⌥` 键开口(可改组合键),对方听到的就是翻译后的语音。声音通过虚拟音频驱动 BlackHole 2ch 传给会议软件,在知了里点一下就能从官方下载安装并自动试音。打开同声传译时知了会把系统麦克风换成它(关掉时换回),Chrome 里的会议网页和用默认麦克风的软件不用再设置;设置里会实时显示哪些会议软件选了它,没选的告诉你怎么改。- **Ming 人声与声音克隆**。填了 Ling 的 API key 后,由 Ming 语音模型一步听懂并翻译你说的话,大约 2 秒出声。对方听到的声音可以选 Ming 自然人声(英、中、日、韩、德、法、西语)、Mac 自带语音,或用 8 到 30 秒录音克隆自己的声音,不填 key 时使用 Mac 自带语音。### 会议记录@@ -113,7 +113,7 @@1. 放任何有声音的视频、直播或会议,默认会弹出实时纪要窗口。随时按 `⌃⌥S` 可以在实时纪要窗口、字幕条和不显示之间切换。2. 点菜单栏上的知了图标,调整听到的语言(默认自动识别)、翻译成的语言以及显示方式。3. 想用实时纪要,去 [Ling 开放平台](https://chat.ant-ling.com/platform/api) 申请一个 API key,填进“设置 › AI 服务”或纪要窗口的提示框里。-4. 想用同声传译跟对方说话,在菜单栏面板里打开同声传译,把会议软件的麦克风选成 BlackHole 2ch,然后按住右边的 `⌥` 键开口。+4. 想用同声传译跟对方说话,在菜单栏面板里打开同声传译,按住右边的 `⌥` 键开口。打开期间知了会把系统麦克风换成 BlackHole 2ch;在会议软件里自己选过麦克风的,要在它的音频设置里改成 BlackHole 2ch(或“默认”)。5. 点面板里的“会议记录”翻看以前的纪要和双语文字记录,支持 `⌘F` 搜索、补生成纪要,或者导出成 Markdown、Word 和 SRT 字幕。## 路线图diff --git a/Resources/en.lproj/Localizable.strings b/Resources/en.lproj/Localizable.stringsindex f849e69..febb523 100644--- a/Resources/en.lproj/Localizable.strings+++ b/Resources/en.lproj/Localizable.strings@@ -207,6 +207,7 @@"翻译暂不可用" = "Translation unavailable for now";/* MicUsersView */+"跟随系统的软件会自动换好;在软件里自己选过麦克风的,要在软件里改。" = "Apps on the system default switch on their own; apps set to a specific mic need changing there.";"这里只显示正在用麦克风的会议软件和常见会议软件,麦克风要在各软件里自己换。" = "Shows meeting apps using a mic, plus common ones. Change the mic inside each app.";"会议软件的麦克风" = "Meeting app microphones";"实时更新" = "Live";@@ -221,6 +222,7 @@"顺便关掉自动调节麦克风音量和降噪,译文会更清楚" = "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, choose %@ or \"Default\" as the microphone";"在会议网页的音频设置里,把麦克风选为 %@" = "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";@@ -378,6 +380,7 @@"右侧 option" = "Right option";"按住说话" = "Hold to talk";"%@已选虚拟麦克风,对方能听到译文" = "%@ is on the virtual mic; they hear the translation";+"系统麦克风已换成 %@,用默认麦克风的会议软件不用再选" = "System mic is now %@; meeting apps on the default mic need no change";"最后一步:在会议软件中,将麦克风选为 " = "Last step: in your meeting app, set the microphone to ";"等你选好…" = "Waiting for you…";@@ -462,9 +465,23 @@"对方只能听到虚拟麦克风里的声音" = "They only hear what goes into the virtual microphone";"虚拟麦克风(自动)" = "Virtual microphone (auto)";"高级:声音输出到 · %@" = "Advanced: voice goes to · %@";-"在会议软件里把麦克风选成「%@」" = "In your meeting app, choose “%@” as the microphone";+"%@ 已装好" = "%@ is installed";"试音通过" = "Sound test passed";"已装好" = "Installed";+"系统麦克风" = "System microphone";+"自动切换系统麦克风" = "Switch the system microphone";+"同声传译打开时换成 %@,Chrome 等跟随系统的软件不用再设置" = "Uses %@ while Interpreting is on, so Chrome and other apps on the default need no setup";+"%@听你说话用" = "%@ listens through";+"固定用这个,不跟着系统切换" = "Always this one, whatever the system uses";+"现在:%@" = "Now: %@";+"关掉同声传译或退出%@时,换回 %@" = "Switches back to %2$@ when Interpreting is off or %1$@ quits";+"立即还原" = "Restore now";+"同声传译已关,别的软件听不到你说话" = "Interpreting is off; other apps can't hear you";+"还原" = "Restore";+"跟随系统的网页听不到译文" = "Pages on the default mic won't hear the translation";+"换回" = "Switch back";+"切换" = "Switch";+"自动(%@)" = "Auto (%@)";"听的时候显示" = "While listening, show";"选择任意模式都会正常保存记录、生成纪要" = "Every mode still saves the meeting and writes notes";"切换显示方式" = "Switch display";@@ -643,12 +660,20 @@"按住" = "Hold";"说%@ → %@" = "%1$@ → %2$@";"%@已选虚拟麦克风" = "%@ is on the virtual mic";+"系统麦克风已换成 %@" = "System mic is now %@";+"同声传译选项" = "Interpreting options";+"系统麦克风还是 %@" = "System mic is still %@";+"别的软件现在听不到你说话" = "Other apps can't hear you now";+"系统麦克风被换成了 %@" = "System mic changed to %@";"%@没选虚拟麦克风,对方听不到译文" = "%@ 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";"有人说话时显示" = "Show while someone talks";"收起前等待" = "Wait before tucking away";+"同声传译设置…" = "Interpreting Settings…";+"系统麦克风换成 %@" = "Switch System Mic to %@";+"还原系统麦克风" = "Restore System Mic";"搜索标题和原话" = "Search titles and transcripts";"开启字幕后,每场会议都会自动保存在这里。" = "Once subtitles are on, every meeting is saved here.";"没有找到“%@”" = "Nothing found for “%@”";diff --git a/Resources/ja.lproj/Localizable.strings b/Resources/ja.lproj/Localizable.stringsindex 98f12f3..cc4071d 100644--- a/Resources/ja.lproj/Localizable.strings+++ b/Resources/ja.lproj/Localizable.strings@@ -207,6 +207,7 @@"翻译暂不可用" = "現在翻訳を利用できません";/* MicUsersView */+"跟随系统的软件会自动换好;在软件里自己选过麦克风的,要在软件里改。" = "システム設定に合わせるアプリは自動で切り替わります。アプリ内でマイクを選んだ場合は、そのアプリで変更してください。";"这里只显示正在用麦克风的会议软件和常见会议软件,麦克风要在各软件里自己换。" = "マイクを使用中の会議アプリと主な会議アプリを表示します。マイクは各アプリで切り替えてください。";"会议软件的麦克风" = "会議アプリのマイク";"实时更新" = "リアルタイム";@@ -221,6 +222,7 @@"顺便关掉自动调节麦克风音量和降噪,译文会更清楚" = "マイク音量の自動調整とノイズ抑制もオフにすると、訳文がよりクリアに届きます";"进会议后,点麦克风图标旁边的 ⌃" = "会議中にマイクアイコンの横の ⌃ をクリック";"在选择麦克风菜单里点 %@" = "マイクの選択メニューで %@ を選ぶ";+"在会议网页的音频设置里,把麦克风选为 %@ 或“默认”" = "会議ページの音声設定で、マイクを %@ または「デフォルト」にします";"在会议网页的音频设置里,把麦克风选为 %@" = "会議ページのオーディオ設定で、マイクを %@ にする";"想让所有网页默认用它:Chrome 设置 › 隐私和安全 › 网站设置 › 麦克风" = "すべてのサイトで使うには:Chrome の設定 › プライバシーとセキュリティ › サイトの設定 › マイク";"打开%@的音频设置" = "%@ のオーディオ設定を開く";@@ -378,6 +380,7 @@"右侧 option" = "右の option";"按住说话" = "押して話す";"%@已选虚拟麦克风,对方能听到译文" = "%@ は仮想マイクを選択済み。相手に訳文が届きます";+"系统麦克风已换成 %@,用默认麦克风的会议软件不用再选" = "システムのマイクを %@ にしました。デフォルトのマイクを使う会議アプリは設定不要です";"最后一步:在会议软件中,将麦克风选为 " = "最後に、会議アプリのマイクを次に設定します: ";"等你选好…" = "選択を待っています…";@@ -462,9 +465,23 @@"对方只能听到虚拟麦克风里的声音" = "相手に聞こえるのは仮想マイクの音だけです";"虚拟麦克风(自动)" = "仮想マイク(自動)";"高级:声音输出到 · %@" = "詳細:音声の出力先 · %@";-"在会议软件里把麦克风选成「%@」" = "会議アプリでマイクを「%@」に設定";+"%@ 已装好" = "%@ をインストール済み";"试音通过" = "サウンドテスト合格";"已装好" = "インストール済み";+"系统麦克风" = "システムのマイク";+"自动切换系统麦克风" = "システムのマイクを自動で切り替える";+"同声传译打开时换成 %@,Chrome 等跟随系统的软件不用再设置" = "同時通訳中は %@ に切り替えます。Chrome などシステムに合わせるアプリは設定不要です";+"%@听你说话用" = "%@ が聞き取るマイク";+"固定用这个,不跟着系统切换" = "システムの切り替えに関係なくこれを使います";+"现在:%@" = "現在:%@";+"关掉同声传译或退出%@时,换回 %@" = "同時通訳をオフにするか %1$@ を終了すると %2$@ に戻します";+"立即还原" = "今すぐ戻す";+"同声传译已关,别的软件听不到你说话" = "同時通訳はオフです。ほかのアプリにあなたの声が届きません";+"还原" = "戻す";+"跟随系统的网页听不到译文" = "システムに合わせるページに訳が届きません";+"换回" = "元に戻す";+"切换" = "切り替える";+"自动(%@)" = "自動(%@)";"听的时候显示" = "聞き取り中の表示";"选择任意模式都会正常保存记录、生成纪要" = "どのモードでも、会議の記録と議事メモの作成は行われます";"切换显示方式" = "表示方法を切り替え";@@ -643,12 +660,20 @@"按住" = "押す";"说%@ → %@" = "%1$@ → %2$@";"%@已选虚拟麦克风" = "%@ は仮想マイクを選択済み";+"系统麦克风已换成 %@" = "システムのマイクは %@ です";+"同声传译选项" = "同時通訳のオプション";+"系统麦克风还是 %@" = "システムのマイクがまだ %@ です";+"别的软件现在听不到你说话" = "ほかのアプリにあなたの声が届きません";+"系统麦克风被换成了 %@" = "システムのマイクが %@ に変わりました";"%@没选虚拟麦克风,对方听不到译文" = "%@ が仮想マイクを選んでいないため、相手に訳文が届きません";"虚拟麦克风尚未设置好,对方听不到你的声音" = "仮想マイクが未設定のため、相手にあなたの声は届きません";"纪要、文字记录和字幕都在一个窗口里" = "議事メモ、文字起こし、字幕を1つのウインドウに表示";"填入 API key 后可生成纪要;文字记录照常保存" = "API key を入力すると議事メモを作成できます。文字起こしは常に保存されます";"有人说话时显示" = "誰かが話しているときに表示";"收起前等待" = "たたむまでの待ち時間";+"同声传译设置…" = "同時通訳の設定…";+"系统麦克风换成 %@" = "システムのマイクを %@ にする";+"还原系统麦克风" = "システムのマイクを戻す";"搜索标题和原话" = "タイトルと発言を検索";"开启字幕后,每场会议都会自动保存在这里。" = "字幕をオンにすると、すべての会議がここに自動保存されます。";"没有找到“%@”" = "「%@」は見つかりません";diff --git a/Resources/ko.lproj/Localizable.strings b/Resources/ko.lproj/Localizable.stringsindex 89c9ffe..25df007 100644--- a/Resources/ko.lproj/Localizable.strings+++ b/Resources/ko.lproj/Localizable.strings@@ -207,6 +207,7 @@"翻译暂不可用" = "번역을 일시적으로 사용할 수 없음";/* MicUsersView */+"跟随系统的软件会自动换好;在软件里自己选过麦克风的,要在软件里改。" = "시스템 기본값을 쓰는 앱은 자동으로 바뀌어요. 앱에서 마이크를 직접 고른 경우엔 그 앱에서 바꿔 주세요.";"这里只显示正在用麦克风的会议软件和常见会议软件,麦克风要在各软件里自己换。" = "마이크를 쓰는 회의 앱과 주요 회의 앱만 표시해요. 마이크는 각 앱에서 바꿔 주세요.";"会议软件的麦克风" = "회의 앱 마이크";"实时更新" = "실시간";@@ -221,6 +222,7 @@"顺便关掉自动调节麦克风音量和降噪,译文会更清楚" = "마이크 음량 자동 조절과 소음 억제도 끄면 번역이 더 또렷하게 들려요";"进会议后,点麦克风图标旁边的 ⌃" = "회의 중 마이크 아이콘 옆의 ⌃ 를 클릭";"在选择麦克风菜单里点 %@" = "마이크 선택 메뉴에서 %@ 선택";+"在会议网页的音频设置里,把麦克风选为 %@ 或“默认”" = "회의 페이지의 오디오 설정에서 마이크를 %@ 또는 '기본값'으로 고르세요";"在会议网页的音频设置里,把麦克风选为 %@" = "회의 페이지의 오디오 설정에서 마이크를 %@(으)로 선택";"想让所有网页默认用它:Chrome 设置 › 隐私和安全 › 网站设置 › 麦克风" = "모든 사이트의 기본값으로 하려면: Chrome 설정 › 개인 정보 보호 및 보안 › 사이트 설정 › 마이크";"打开%@的音频设置" = "%@의 오디오 설정 열기";@@ -378,6 +380,7 @@"右侧 option" = "오른쪽 option";"按住说话" = "누르고 말하기";"%@已选虚拟麦克风,对方能听到译文" = "%@에서 가상 마이크를 골랐어요. 상대가 번역을 들어요";+"系统麦克风已换成 %@,用默认麦克风的会议软件不用再选" = "시스템 마이크를 %@(으)로 바꿨어요. 기본 마이크를 쓰는 회의 앱은 따로 고를 필요가 없어요";"最后一步:在会议软件中,将麦克风选为 " = "마지막 단계: 회의 앱에서 마이크를 다음으로 선택하세요: ";"等你选好…" = "선택을 기다리는 중…";@@ -462,9 +465,23 @@"对方只能听到虚拟麦克风里的声音" = "상대는 가상 마이크로 들어간 소리만 듣습니다";"虚拟麦克风(自动)" = "가상 마이크(자동)";"高级:声音输出到 · %@" = "고급: 음성 출력 · %@";-"在会议软件里把麦克风选成「%@」" = "회의 앱에서 마이크를 “%@”(으)로 선택";+"%@ 已装好" = "%@ 설치됨";"试音通过" = "사운드 테스트 통과";"已装好" = "설치됨";+"系统麦克风" = "시스템 마이크";+"自动切换系统麦克风" = "시스템 마이크 자동 전환";+"同声传译打开时换成 %@,Chrome 等跟随系统的软件不用再设置" = "동시통역 중엔 %@(으)로 바꿔요. Chrome 등 시스템 기본값을 쓰는 앱은 따로 설정할 필요가 없어요";+"%@听你说话用" = "%@이(가) 듣는 마이크";+"固定用这个,不跟着系统切换" = "시스템 설정과 관계없이 이걸 써요";+"现在:%@" = "현재: %@";+"关掉同声传译或退出%@时,换回 %@" = "동시통역을 끄거나 %1$@을(를) 종료하면 %2$@(으)로 돌아가요";+"立即还原" = "지금 되돌리기";+"同声传译已关,别的软件听不到你说话" = "동시통역이 꺼져 있어요. 다른 앱에 내 목소리가 들리지 않아요";+"还原" = "되돌리기";+"跟随系统的网页听不到译文" = "기본 마이크를 쓰는 페이지엔 번역이 안 들려요";+"换回" = "다시 바꾸기";+"切换" = "전환";+"自动(%@)" = "자동(%@)";"听的时候显示" = "듣는 동안 표시";"选择任意模式都会正常保存记录、生成纪要" = "어떤 모드든 회의 기록 저장과 회의록 작성은 그대로 진행됩니다";"切换显示方式" = "표시 방식 전환";@@ -643,12 +660,20 @@"按住" = "누르기";"说%@ → %@" = "%1$@ → %2$@";"%@已选虚拟麦克风" = "%@ 가상 마이크 선택됨";+"系统麦克风已换成 %@" = "시스템 마이크: %@";+"同声传译选项" = "동시통역 옵션";+"系统麦克风还是 %@" = "시스템 마이크가 아직 %@예요";+"别的软件现在听不到你说话" = "다른 앱에 내 목소리가 들리지 않아요";+"系统麦克风被换成了 %@" = "시스템 마이크가 %@(으)로 바뀌었어요";"%@没选虚拟麦克风,对方听不到译文" = "%@에서 가상 마이크를 안 골라 상대가 번역을 못 들어요";"虚拟麦克风尚未设置好,对方听不到你的声音" = "가상 마이크가 설정되지 않아 상대가 내 목소리를 들을 수 없습니다";"纪要、文字记录和字幕都在一个窗口里" = "회의록, 대화 기록, 자막을 한 창에서 확인합니다";"填入 API key 后可生成纪要;文字记录照常保存" = "API key를 입력하면 회의록을 작성할 수 있으며, 대화 기록은 그대로 저장됩니다";"有人说话时显示" = "누군가 말할 때 표시";"收起前等待" = "접기 전 대기";+"同声传译设置…" = "동시통역 설정…";+"系统麦克风换成 %@" = "시스템 마이크를 %@(으)로";+"还原系统麦克风" = "시스템 마이크 되돌리기";"搜索标题和原话" = "제목과 원문 검색";"开启字幕后,每场会议都会自动保存在这里。" = "자막을 켜면 모든 회의가 자동으로 여기에 저장됩니다.";"没有找到“%@”" = "“%@” 검색 결과 없음";diff --git a/Resources/zh-Hans.lproj/Localizable.strings b/Resources/zh-Hans.lproj/Localizable.stringsindex d46c9e4..8e6c206 100644--- a/Resources/zh-Hans.lproj/Localizable.strings+++ b/Resources/zh-Hans.lproj/Localizable.strings@@ -207,6 +207,7 @@"翻译暂不可用" = "翻译暂不可用";/* MicUsersView */+"跟随系统的软件会自动换好;在软件里自己选过麦克风的,要在软件里改。" = "跟随系统的软件会自动换好;在软件里自己选过麦克风的,要在软件里改。";"这里只显示正在用麦克风的会议软件和常见会议软件,麦克风要在各软件里自己换。" = "这里只显示正在用麦克风的会议软件和常见会议软件,麦克风要在各软件里自己换。";"会议软件的麦克风" = "会议软件的麦克风";"实时更新" = "实时更新";@@ -221,6 +222,7 @@"顺便关掉自动调节麦克风音量和降噪,译文会更清楚" = "顺便关掉自动调节麦克风音量和降噪,译文会更清楚";"进会议后,点麦克风图标旁边的 ⌃" = "进会议后,点麦克风图标旁边的 ⌃";"在选择麦克风菜单里点 %@" = "在选择麦克风菜单里点 %@";+"在会议网页的音频设置里,把麦克风选为 %@ 或“默认”" = "在会议网页的音频设置里,把麦克风选为 %@ 或“默认”";"在会议网页的音频设置里,把麦克风选为 %@" = "在会议网页的音频设置里,把麦克风选为 %@";"想让所有网页默认用它:Chrome 设置 › 隐私和安全 › 网站设置 › 麦克风" = "想让所有网页默认用它:Chrome 设置 › 隐私和安全 › 网站设置 › 麦克风";"打开%@的音频设置" = "打开%@的音频设置";@@ -378,6 +380,7 @@"右侧 option" = "右侧 option";"按住说话" = "按住说话";"%@已选虚拟麦克风,对方能听到译文" = "%@已选虚拟麦克风,对方能听到译文";+"系统麦克风已换成 %@,用默认麦克风的会议软件不用再选" = "系统麦克风已换成 %@,用默认麦克风的会议软件不用再选";"最后一步:在会议软件中,将麦克风选为 " = "最后一步:在会议软件中,将麦克风选为 ";"等你选好…" = "等你选好…";@@ -462,9 +465,23 @@"对方只能听到虚拟麦克风里的声音" = "对方只能听到虚拟麦克风里的声音";"虚拟麦克风(自动)" = "虚拟麦克风(自动)";"高级:声音输出到 · %@" = "高级:声音输出到 · %@";-"在会议软件里把麦克风选成「%@」" = "在会议软件里把麦克风选成「%@」";+"%@ 已装好" = "%@ 已装好";"试音通过" = "试音通过";"已装好" = "已装好";+"系统麦克风" = "系统麦克风";+"自动切换系统麦克风" = "自动切换系统麦克风";+"同声传译打开时换成 %@,Chrome 等跟随系统的软件不用再设置" = "同声传译打开时换成 %@,Chrome 等跟随系统的软件不用再设置";+"%@听你说话用" = "%@听你说话用";+"固定用这个,不跟着系统切换" = "固定用这个,不跟着系统切换";+"现在:%@" = "现在:%@";+"关掉同声传译或退出%@时,换回 %@" = "关掉同声传译或退出%@时,换回 %@";+"立即还原" = "立即还原";+"同声传译已关,别的软件听不到你说话" = "同声传译已关,别的软件听不到你说话";+"还原" = "还原";+"跟随系统的网页听不到译文" = "跟随系统的网页听不到译文";+"换回" = "换回";+"切换" = "切换";+"自动(%@)" = "自动(%@)";"听的时候显示" = "听的时候显示";"选择任意模式都会正常保存记录、生成纪要" = "选择任意模式都会正常保存记录、生成纪要";"切换显示方式" = "切换显示方式";@@ -643,12 +660,20 @@"按住" = "按住";"说%@ → %@" = "说%@ → %@";"%@已选虚拟麦克风" = "%@已选虚拟麦克风";+"系统麦克风已换成 %@" = "系统麦克风已换成 %@";+"同声传译选项" = "同声传译选项";+"系统麦克风还是 %@" = "系统麦克风还是 %@";+"别的软件现在听不到你说话" = "别的软件现在听不到你说话";+"系统麦克风被换成了 %@" = "系统麦克风被换成了 %@";"%@没选虚拟麦克风,对方听不到译文" = "%@没选虚拟麦克风,对方听不到译文";"虚拟麦克风尚未设置好,对方听不到你的声音" = "虚拟麦克风尚未设置好,对方听不到你的声音";"纪要、文字记录和字幕都在一个窗口里" = "纪要、文字记录和字幕都在一个窗口里";"填入 API key 后可生成纪要;文字记录照常保存" = "填入 API key 后可生成纪要;文字记录照常保存";"有人说话时显示" = "有人说话时显示";"收起前等待" = "收起前等待";+"同声传译设置…" = "同声传译设置…";+"系统麦克风换成 %@" = "系统麦克风换成 %@";+"还原系统麦克风" = "还原系统麦克风";"搜索标题和原话" = "搜索标题和原话";"开启字幕后,每场会议都会自动保存在这里。" = "开启字幕后,每场会议都会自动保存在这里。";"没有找到“%@”" = "没有找到“%@”";diff --git a/Sources/LiveSubs/AppModel.swift b/Sources/LiveSubs/AppModel.swiftindex ba444f5..cc67a0b 100644--- a/Sources/LiveSubs/AppModel.swift+++ b/Sources/LiveSubs/AppModel.swift@@ -24,6 +24,9 @@ final class AppModel: ObservableObject {@Published var speakTestShown = false/// Meeting apps and the microphone each reads; refreshed every second once the virtual mic exists.@Published var micUsers: [MicUser] = []+ lazy var systemMic = SystemMic(settings: settings)+ /// Whether the system default input is the virtual mic, and anything left to put back.+ @Published private(set) var systemMicState: SystemMic.State = .off/// The app whose "怎么改" sheet is open in Settings.@Published var micGuide: MicUser?/// Settings › 同声传译: the voice list under "对方听到" is open.@@ -139,6 +142,7 @@ final class AppModel: ObservableObject {await self?.translator.interpret(wav: wav, source: from, target: to, trace: trace)}speak.roomLanguage = { [weak self] in self?.listen.activeLang?.code }+ speak.inputDevice = { [weak self] in self?.systemMic.recordingDevice }applyVoice()speak.onStatus = { [weak self] text in self?.status = text }speak.onLive = { [weak self] phase, src, dst in@@ -236,6 +240,44 @@ final class AppModel: ObservableObject {if devices.map(\.uid) != outputs.map(\.uid) { outputs = devices }if listen.isRunning && !systemAudioOK { systemAudioOK = true }refreshMicUsers()+ refreshSystemMic()+ }++ // MARK: System microphone++ /// Switching the system mic only helps when our voice goes into the virtual mic.+ var wantsSystemMic: Bool {+ guard settings.speakEnabled, settings.autoSystemMic, virtualMic != nil else { return false }+ return settings.speakOutput.isEmpty || (outputs.first { $0.uid == settings.speakOutput }?.isVirtualMic ?? true)+ }++ func refreshSystemMic() {+ let state = systemMic.refresh(wanted: wantsSystemMic)+ if state != systemMicState { systemMicState = state }+ }++ /// Switches or lets go to match the settings (同声传译, 自动切换, 声音输出到).+ func applySystemMic() {+ // Speaking off: turning it off already put the mic back; a crash leftover waits for 还原.+ if wantsSystemMic { systemMic.engage(wanted: true) } else if settings.speakEnabled { systemMic.release() }+ refreshSystemMic()+ }++ /// 还原: the real mic back now. While speaking it stays back until 换回 or the next time speaking starts.+ func restoreSystemMic() {+ systemMic.release()+ refreshSystemMic()+ }++ /// 换回 / 切换: the virtual mic as the system default again.+ func switchSystemMic() {+ systemMic.engage(wanted: true)+ refreshSystemMic()+ }++ func setAutoSystemMic(_ on: Bool) {+ settings.autoSystemMic = on+ applySystemMic()}func refreshMicUsers() {@@ -297,6 +339,7 @@ final class AppModel: ObservableObject {// system-audio tap and rebuild the voice output.speak.resetOutput()listen.reconnectAudio()+ if settings.speakEnabled { applySystemMic() }objectWillChange.send()}@@ -514,9 +557,11 @@ final class AppModel: ObservableObject {if settings.talkKey.isRightOption && !RightOptionKey.allowed { RightOptionKey.requestAccess() }applyTalkKey()refreshOutputs()+ applySystemMic()Task { await speak.prepare() }} else {applyTalkKey()+ restoreSystemMic()Task { await speak.teardownAnalyzer() }}}@@ -839,6 +884,18 @@ final class AppModel: ObservableObject {debugLog("diag report:\n" + diagnostics.report(version: "", model: settings.aiModel))case "micTest": installer.runTest()case "micNext": installer.next()+ case "sysMic":+ refreshSystemMic()+ debugLog("system mic state=\(systemMicState) default=\(AudioDevices.defaultInput?.name ?? "-") saved=\(AudioDevices.inputs().first { $0.uid == settings.savedSystemInput }?.name ?? "-") recording=\(systemMic.recordingDevice?.name ?? "-") engine=\(speak.micDeviceName) auto=\(settings.autoSystemMic) wanted=\(wantsSystemMic)")+ case "sysMicSet":+ // Simulates another app or the user moving the system mic (part of a device name).+ if let d = AudioDevices.inputs().first(where: { $0.name.localizedCaseInsensitiveContains(arg) }) { AudioDevices.setDefaultInput(d) }+ refreshSystemMic()+ case "sysMicRestore": restoreSystemMic()+ case "sysMicSwitch": switchSystemMic()+ case "sysMicAuto": setAutoSystemMic(arg != "off")+ case "speakMic":+ settings.speakMic = arg.isEmpty ? "" : systemMic.realInputs.first { $0.name.localizedCaseInsensitiveContains(arg) }?.uid ?? ""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)" })")@@ -995,6 +1052,7 @@ final class AppModel: ObservableObject {case "speakOutput":// speakOutput:<part of a device name>, or empty for the virtual mic (automatic).settings.speakOutput = arg.isEmpty ? "" : AudioDevices.outputs().first { $0.name.localizedCaseInsensitiveContains(arg) }?.uid ?? ""+ applySystemMic()speak.resetOutput()debugLog("speak output=\(speak.outputDevice()?.name ?? "-")")case "voicePicker": voicePickerOpen = arg != "off"@@ -1096,6 +1154,8 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate {func applicationWillTerminate(_ notification: Notification) {model.stop()+ // Other apps would be left on the virtual mic, hearing nothing.+ model.systemMic.release()}/// Dock icon or Finder: bring back what is open; the main window only when nothing is.diff --git a/Sources/LiveSubs/MicUsersView.swift b/Sources/LiveSubs/MicUsersView.swiftindex 0461134..e9a1a41 100644--- a/Sources/LiveSubs/MicUsersView.swift+++ b/Sources/LiveSubs/MicUsersView.swift@@ -27,7 +27,8 @@ struct MicUsersSection: View {}// The tinted problem row would otherwise square off the card's corners..clipShape(RoundedRectangle(cornerRadius: 12))- Text("这里只显示正在用麦克风的会议软件和常见会议软件,麦克风要在各软件里自己换。")+ Text(model.settings.autoSystemMic ? L("跟随系统的软件会自动换好;在软件里自己选过麦克风的,要在软件里改。")+ : L("这里只显示正在用麦克风的会议软件和常见会议软件,麦克风要在各软件里自己换。")).font(.system(size: 11)).foregroundStyle(Palette.tertiary).fixedSize(horizontal: false, vertical: true).padding(.horizontal, 4)@@ -119,7 +120,10 @@ struct MicGuideView: View {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)"),+ // With the system mic switched, a page left on "default" needs nothing; one set to a+ // specific mic still has to be changed in the page.+ return [model.settings.autoSystemMic ? L("在会议网页的音频设置里,把麦克风选为 \(micName) 或“默认”")+ : L("在会议网页的音频设置里,把麦克风选为 \(micName)"),L("想让所有网页默认用它:Chrome 设置 › 隐私和安全 › 网站设置 › 麦克风"), tune]case "com.apple.Safari", "com.microsoft.edgemac", "company.thebrowser.Browser":return [L("在会议网页的音频设置里,把麦克风选为 \(micName)"), tune]diff --git a/Sources/LiveSubs/Onboarding.swift b/Sources/LiveSubs/Onboarding.swiftindex 1100c66..eb4ec15 100644--- a/Sources/LiveSubs/Onboarding.swift+++ b/Sources/LiveSubs/Onboarding.swift@@ -523,6 +523,16 @@ struct OnboardingView: View {.padding(.horizontal, 16).padding(.vertical, 12).frame(maxWidth: .infinity, alignment: .leading).background(RoundedRectangle(cornerRadius: 12).fill(Palette.okPale))+ } else if case .switched = model.systemMicState {+ // Apps on the default mic already hear it; only ones set to a specific mic need a change.+ HStack(spacing: 10) {+ Image(systemName: "checkmark.circle.fill").foregroundStyle(Palette.ok)+ Text("系统麦克风已换成 \(model.virtualMic?.name ?? "BlackHole 2ch"),用默认麦克风的会议软件不用再选")+ .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())diff --git a/Sources/LiveSubs/Settings.swift b/Sources/LiveSubs/Settings.swiftindex ba2b585..55c6568 100644--- a/Sources/LiveSubs/Settings.swift+++ b/Sources/LiveSubs/Settings.swift@@ -43,6 +43,18 @@ final class AppSettings: ObservableObject {@Published var speakOutput: String {didSet { save() }}+ /// While speaking, make the virtual mic the system default input (and put it back after).+ @Published var autoSystemMic: Bool {+ didSet { save() }+ }+ /// The microphone Cicada records my voice from (UID), "" = the real mic the system had.+ @Published var speakMic: String {+ didSet { save() }+ }+ /// The real system input replaced by the virtual mic, kept until it's put back (survives a crash).+ @Published var savedSystemInput: String {+ didSet { save() }+ }@Published var recordAudio: Bool {didSet { save() }}@@ -112,6 +124,9 @@ final class AppSettings: ObservableObject {?? speakLocale(forLanguage: LiveSubs.myLanguage(systemLanguages: Locale.preferredLanguages))speakTo = defaults.string(forKey: "speakTo") ?? "room"speakOutput = defaults.string(forKey: "speakOutput") ?? ""+ autoSystemMic = defaults.object(forKey: "autoSystemMic") as? Bool ?? true+ speakMic = defaults.string(forKey: "speakMic") ?? ""+ savedSystemInput = defaults.string(forKey: "savedSystemInput") ?? ""recordAudio = defaults.object(forKey: "recordAudio") as? Bool ?? trueoverlayAuto = defaults.object(forKey: "overlayAuto") as? Bool ?? trueoverlayHideAfter = defaults.object(forKey: "overlayHideAfter") as? Double ?? 4@@ -138,6 +153,9 @@ final class AppSettings: ObservableObject {defaults.set(speakFrom, forKey: "speakFrom")defaults.set(speakTo, forKey: "speakTo")defaults.set(speakOutput, forKey: "speakOutput")+ defaults.set(autoSystemMic, forKey: "autoSystemMic")+ defaults.set(speakMic, forKey: "speakMic")+ defaults.set(savedSystemInput, forKey: "savedSystemInput")defaults.set(recordAudio, forKey: "recordAudio")defaults.set(overlayAuto, forKey: "overlayAuto")defaults.set(overlayHideAfter, forKey: "overlayHideAfter")diff --git a/Sources/LiveSubs/SettingsWindow.swift b/Sources/LiveSubs/SettingsWindow.swiftindex 666959d..b91b418 100644--- a/Sources/LiveSubs/SettingsWindow.swift+++ b/Sources/LiveSubs/SettingsWindow.swift@@ -56,7 +56,7 @@ struct SettingsRow<Trailing: View>: View {Spacer(minLength: 12)trailing}- .padding(.horizontal, 16)+ .padding(.horizontal, 16).padding(.vertical, 6).frame(minHeight: 46)if divider { Divider().padding(.leading, 16) }}@@ -488,6 +488,7 @@ struct SettingsView: View {Divider().padding(.leading, 50)VoiceSection(model: model, settings: settings, ling: model.ling)}+ if model.virtualMic != nil { systemMicSection }if model.virtualMic != nil { MicUsersSection(model: model) }DisclosureGroup {SettingsCard {@@ -495,6 +496,7 @@ struct SettingsView: View {PillMenu(value: outputName,options: [("", L("虚拟麦克风(自动)"))] + model.outputs.map { ($0.uid, $0.name) }) {settings.speakOutput = $0+ model.applySystemMic()}}}@@ -530,7 +532,7 @@ struct SettingsView: View {StepMark(done: true, number: 1)VStack(alignment: .leading, spacing: 2) {Text("虚拟麦克风").font(.system(size: 13, weight: .semibold)).foregroundStyle(Palette.ink)- Text("在会议软件里把麦克风选成「\(name)」").font(.system(size: 11)).foregroundStyle(Palette.tertiary)+ Text("\(name) 已装好").font(.system(size: 11)).foregroundStyle(Palette.tertiary)}Spacer(minLength: 8)HStack(spacing: 6) {@@ -544,6 +546,60 @@ struct SettingsView: View {}}+ /// 系统麦克风: the virtual mic as the system default while speaking, and the real mic Cicada records from.+ private var systemMicSection: some View {+ let virtual = model.virtualMic?.name ?? "BlackHole 2ch"+ let inputs = model.systemMic.realInputs+ // A chosen mic that's unplugged reads as 自动 until it's back.+ let chosen = inputs.first { $0.uid == settings.speakMic }?.name+ let auto = model.systemMic.recordingDevice?.name+ return VStack(alignment: .leading, spacing: 8) {+ Text("系统麦克风").font(.system(size: 13, weight: .semibold)).foregroundStyle(Palette.ink).padding(.horizontal, 4)+ SettingsCard {+ SettingsRow(title: L("自动切换系统麦克风"),+ detail: L("同声传译打开时换成 \(virtual),Chrome 等跟随系统的软件不用再设置")) {+ Toggle("自动切换系统麦克风", isOn: Binding(get: { settings.autoSystemMic }, set: { model.setAutoSystemMic($0) }))+ .toggleStyle(.switch).labelsHidden().controlSize(.small).tint(Palette.ink)+ }+ SettingsRow(title: L("\(appDisplayName)听你说话用"), detail: L("固定用这个,不跟着系统切换"),+ divider: systemMicStatus != nil) {+ PillMenu(value: chosen ?? (auto.map { L("自动(\($0))") } ?? L("自动")),+ options: [("", L("自动"))] + inputs.map { ($0.uid, $0.name) }) {+ settings.speakMic = $0+ }+ }+ if let status = systemMicStatus {+ HStack(spacing: 12) {+ Circle().fill(status.ok ? Palette.ok : Palette.accent).frame(width: 8, height: 8)+ VStack(alignment: .leading, spacing: 2) {+ Text(status.title).font(.system(size: 13)).foregroundStyle(Palette.ink)+ Text(status.detail).font(.system(size: 11)).foregroundStyle(Palette.tertiary)+ }+ Spacer(minLength: 8)+ SoftButton(status.button, dark: !status.ok, action: status.action)+ }+ .padding(.horizontal, 16).frame(minHeight: 52)+ }+ }+ }+ }++ /// The status row: what the system mic is now and the one thing to do about it.+ private var systemMicStatus: (ok: Bool, title: String, detail: String, button: String, action: () -> Void)? {+ let virtual = model.virtualMic?.name ?? "BlackHole 2ch"+ switch model.systemMicState {+ case .switched(let original):+ return (true, L("现在:\(virtual)"), L("关掉同声传译或退出\(appDisplayName)时,换回 \(original)"), L("立即还原"), model.restoreSystemMic)+ case .notRestored:+ return (false, L("现在:\(virtual)"), L("同声传译已关,别的软件听不到你说话"), L("还原"), model.restoreSystemMic)+ case .moved(let to):+ return (false, L("现在:\(to)"), L("跟随系统的网页听不到译文"), L("换回"), model.switchSystemMic)+ case .off:+ guard model.wantsSystemMic else { return nil }+ return (false, L("现在:\(AudioDevices.defaultInput?.name ?? "-")"), L("跟随系统的网页听不到译文"), L("切换"), model.switchSystemMic)+ }+ }+private var micTested: Bool {installer.passed || (model.speakTester.result.map { $0.broken != .room && $0.heardSeconds > 0 } ?? false)}diff --git a/Sources/LiveSubs/SpeakEngine.swift b/Sources/LiveSubs/SpeakEngine.swiftindex bca618d..987e1f8 100644--- a/Sources/LiveSubs/SpeakEngine.swift+++ b/Sources/LiveSubs/SpeakEngine.swift@@ -26,7 +26,10 @@ enum AudioDevices {return status == noErr ? value as String : nil}- static func outputs() -> [OutputDevice] {+ static func outputs() -> [OutputDevice] { devices(scope: kAudioObjectPropertyScopeOutput) }++ /// Devices with streams on one side (output or input), minus Cicada's own aggregate devices.+ static func devices(scope: AudioObjectPropertyScope) -> [OutputDevice] {var addr = AudioObjectPropertyAddress(mSelector: kAudioHardwarePropertyDevices,mScope: kAudioObjectPropertyScopeGlobal,mElement: kAudioObjectPropertyElementMain)@@ -36,7 +39,7 @@ enum AudioDevices {guard AudioObjectGetPropertyData(AudioObjectID(kAudioObjectSystemObject), &addr, 0, nil, &size, &ids) == noErr else { return [] }return ids.compactMap { id invar streams = AudioObjectPropertyAddress(mSelector: kAudioDevicePropertyStreams,- mScope: kAudioObjectPropertyScopeOutput,+ mScope: scope,mElement: kAudioObjectPropertyElementMain)var s: UInt32 = 0guard AudioObjectGetPropertyDataSize(id, &streams, 0, nil, &s) == noErr, s > 0,@@ -91,6 +94,8 @@ final class SpeakEngine {/// When the latest `speak` call started sending audio, and how it was voiced.private(set) var firstAudioAt: Date?private(set) var lastVoice = ""+ /// The real microphone to record from; the system default may be the virtual mic.+ var inputDevice: (() -> OutputDevice?)?/// Language the room speaks (for "follow the room").var roomLanguage: (() -> String?)?@@ -136,6 +141,9 @@ final class SpeakEngine {return room == settings.speakFromLang.code ? "en" : room}+ /// Debug: the device the mic engine reads.+ var micDeviceName: String { AudioDevices.inputDevice(of: mic) }+func setRecording(_ url: URL?) {micQueue.sync {micRecorder = nil@@ -309,6 +317,7 @@ final class SpeakEngine {private func startMic(format: AVAudioFormat, input cont: AsyncStream<AnalyzerInput>.Continuation) {let inputNode = mic.inputNode+ AudioDevices.pinInput(mic, to: inputDevice?())let inFormat = inputNode.outputFormat(forBus: 0)guard inFormat.sampleRate > 0 else {onStatus?(L("没有可用的麦克风"))diff --git a/Sources/LiveSubs/SystemMic.swift b/Sources/LiveSubs/SystemMic.swiftnew file mode 100644index 0000000..38bc4d8--- /dev/null+++ b/Sources/LiveSubs/SystemMic.swift@@ -0,0 +1,171 @@+import AVFoundation+import CoreAudio+import Foundation++/// Input side of `AudioDevices`: the devices that can record, and the system default input.+extension AudioDevices {+ static func inputs() -> [OutputDevice] { devices(scope: kAudioObjectPropertyScopeInput) }++ static var defaultInput: OutputDevice? {+ var id = AudioObjectID(0)+ var size = UInt32(MemoryLayout<AudioObjectID>.size)+ var addr = AudioObjectPropertyAddress(mSelector: kAudioHardwarePropertyDefaultInputDevice,+ mScope: kAudioObjectPropertyScopeGlobal, mElement: kAudioObjectPropertyElementMain)+ guard AudioObjectGetPropertyData(AudioObjectID(kAudioObjectSystemObject), &addr, 0, nil, &size, &id) == noErr else { return nil }+ return inputs().first { $0.id == id }+ }++ /// Points an engine's input at a device. Call while the engine is stopped and before reading the+ /// input format, which then follows the device. nil leaves it where it is.+ static func pinInput(_ engine: AVAudioEngine, to device: OutputDevice?) {+ guard let device, let unit = engine.inputNode.audioUnit else { return }+ var cur = AudioObjectID(0)+ var size = UInt32(MemoryLayout<AudioObjectID>.size)+ AudioUnitGetProperty(unit, kAudioOutputUnitProperty_CurrentDevice, kAudioUnitScope_Global, 0, &cur, &size)+ guard cur != device.id else { return }+ var id = device.id+ let status = AudioUnitSetProperty(unit, kAudioOutputUnitProperty_CurrentDevice, kAudioUnitScope_Global, 0,+ &id, UInt32(MemoryLayout<AudioObjectID>.size))+ debugLog("mic: recording from \(device.name) status=\(status)")+ }++ /// The device an engine's input is reading now (for the debug log).+ static func inputDevice(of engine: AVAudioEngine) -> String {+ guard let unit = engine.inputNode.audioUnit else { return "-" }+ var cur = AudioObjectID(0)+ var size = UInt32(MemoryLayout<AudioObjectID>.size)+ AudioUnitGetProperty(unit, kAudioOutputUnitProperty_CurrentDevice, kAudioUnitScope_Global, 0, &cur, &size)+ return name(cur) ?? "\(cur)"+ }++ @discardableResult+ static func setDefaultInput(_ device: OutputDevice) -> Bool {+ var id = device.id+ var addr = AudioObjectPropertyAddress(mSelector: kAudioHardwarePropertyDefaultInputDevice,+ mScope: kAudioObjectPropertyScopeGlobal, mElement: kAudioObjectPropertyElementMain)+ let status = AudioObjectSetPropertyData(AudioObjectID(kAudioObjectSystemObject), &addr, 0, nil,+ UInt32(MemoryLayout<AudioObjectID>.size), &id)+ if status != noErr { debugLog("system mic: set default input \(device.name) failed \(status)") }+ return status == noErr+ }+}++/// Which real microphone to come back to and which one Cicada records from. Pure, so it's tested.+/// Devices are compared by UID: IDs change when Core Audio restarts (the BlackHole install does).+enum SystemMicPlan {+ struct Device: Equatable {+ var uid: String+ var isVirtual: Bool+ }++ /// The microphone to put back when we let go of the system default. The one saved when we+ /// switched, while it's still plugged in; else the current default if it's real (the user+ /// already chose it); else the first real one. Never a virtual mic: putting BlackHole "back"+ /// would leave every other app deaf.+ static func original(saved: String, current: String?, inputs: [Device]) -> String? {+ let real = inputs.filter { !$0.isVirtual }+ if real.contains(where: { $0.uid == saved }) { return saved }+ if let current, real.contains(where: { $0.uid == current }) { return current }+ return real.first?.uid+ }++ /// What Cicada itself records from: the one picked in settings, else the original. Cicada must+ /// never follow the system default onto the virtual mic, or it would hear its own voice.+ static func recording(chosen: String, saved: String, current: String?, inputs: [Device]) -> String? {+ if inputs.contains(where: { $0.uid == chosen && !$0.isVirtual }) { return chosen }+ return original(saved: saved, current: current, inputs: inputs)+ }+}++/// Points the system default input at the virtual mic while 同声传译 is on, so a meeting page in+/// Chrome (and any app left on "default") hears the translation without being set up, and puts it+/// back when speaking stops or Cicada quits. The device we switched from is saved in settings so+/// a crash can be undone on the next launch.+@MainActor+final class SystemMic {+ enum State: Equatable {+ /// Not switched, nothing to undo.+ case off+ /// The system mic is the virtual mic; `original` comes back when speaking stops.+ case switched(original: String)+ /// Speaking is off but the system mic is still the virtual mic (Cicada quit uncleanly).+ case notRestored(original: String)+ /// Speaking is on but something else (AirPods, the user) moved the system mic away.+ case moved(to: String)+ }++ let settings: AppSettings+ private(set) var state: State = .off++ init(settings: AppSettings) { self.settings = settings }++ private var plan: [SystemMicPlan.Device] {+ AudioDevices.inputs().map { .init(uid: $0.uid, isVirtual: $0.isVirtualMic) }+ }++ private func device(_ uid: String?) -> OutputDevice? {+ guard let uid else { return nil }+ return AudioDevices.inputs().first { $0.uid == uid }+ }++ /// The device Cicada records my voice from; nil leaves the engine on the system default.+ var recordingDevice: OutputDevice? {+ device(SystemMicPlan.recording(chosen: settings.speakMic, saved: settings.savedSystemInput,+ current: AudioDevices.defaultInput?.uid, inputs: plan))+ }++ /// Real microphones for the settings menu.+ var realInputs: [OutputDevice] { AudioDevices.inputs().filter { !$0.isVirtualMic } }++ /// Makes the virtual mic the system default, remembering the real one it replaces.+ /// `wanted` is false when switching makes no sense (feature off, voice sent elsewhere).+ func engage(wanted: Bool) {+ guard wanted else { release(); return }+ guard let virtual = AudioDevices.inputs().first(where: \.isVirtualMic) else { refresh(wanted: wanted); return }+ let current = AudioDevices.defaultInput+ // Keep a save left over from a crash: by now the default is the virtual mic.+ if settings.savedSystemInput.isEmpty || device(settings.savedSystemInput) == nil,+ let original = SystemMicPlan.original(saved: settings.savedSystemInput, current: current?.uid, inputs: plan) {+ settings.savedSystemInput = original+ }+ if current?.uid != virtual.uid {+ AudioDevices.setDefaultInput(virtual)+ debugLog("system mic: \(current?.name ?? "-") → \(virtual.name), will restore \(device(settings.savedSystemInput)?.name ?? "-")")+ }+ refresh(wanted: wanted)+ }++ /// Puts the saved real microphone back, if the system default is still the virtual mic.+ func release() {+ let current = AudioDevices.defaultInput+ if current?.isVirtualMic ?? false,+ let back = device(SystemMicPlan.original(saved: settings.savedSystemInput, current: nil, inputs: plan)) {+ AudioDevices.setDefaultInput(back)+ debugLog("system mic: restored \(back.name)")+ }+ if !settings.savedSystemInput.isEmpty { settings.savedSystemInput = "" }+ state = .off+ }++ /// Re-reads the system default (polled): spots a crash left over or a device that took over.+ @discardableResult+ func refresh(wanted: Bool) -> State {+ let saved = settings.savedSystemInput+ let current = AudioDevices.defaultInput+ let originalName = device(SystemMicPlan.original(saved: saved, current: nil, inputs: plan))?.name ?? ""+ let next: State+ if saved.isEmpty {+ next = .off+ } else if current?.isVirtualMic ?? false {+ next = wanted ? .switched(original: originalName) : .notRestored(original: originalName)+ } else if wanted {+ next = .moved(to: current?.name ?? "")+ } else {+ // Someone already put a real mic back: nothing left to undo.+ settings.savedSystemInput = ""+ next = .off+ }+ state = next+ return next+ }+}diff --git a/Sources/LiveSubs/Views.swift b/Sources/LiveSubs/Views.swiftindex 799586b..4d3d98f 100644--- a/Sources/LiveSubs/Views.swift+++ b/Sources/LiveSubs/Views.swift@@ -171,11 +171,33 @@ struct MenuPanelView: View {Circle().fill(Palette.ok).frame(width: 7, height: 7)Text("\(user.name)已选虚拟麦克风").font(.system(size: 12)).foregroundStyle(Palette.secondary)}+ } else if settings.speakEnabled, !model.micUsers.contains(where: { $0.state.isOther }),+ case .switched = model.systemMicState {+ HStack(spacing: 6) {+ Circle().fill(Palette.ok).frame(width: 7, height: 7)+ Text("系统麦克风已换成 \(model.virtualMic?.name ?? "BlackHole 2ch")").font(.system(size: 12))+ .foregroundStyle(Palette.secondary).lineLimit(1)+ }}}Spacer()- Toggle("同声传译", isOn: Binding(get: { settings.speakEnabled }, set: { model.enableSpeaking($0) }))- .toggleStyle(.switch).labelsHidden().tint(Palette.ink)+ HStack(spacing: 8) {+ speakMenu+ Toggle("同声传译", isOn: Binding(get: { settings.speakEnabled }, set: { model.enableSpeaking($0) }))+ .toggleStyle(.switch).labelsHidden().tint(Palette.ink)+ }+ }+ if let strip = systemMicStrip {+ HStack(spacing: 10) {+ VStack(alignment: .leading, spacing: 2) {+ Text(strip.title).font(.system(size: 12)).foregroundStyle(Palette.accentInk)+ Text(strip.detail).font(.system(size: 11)).foregroundStyle(Palette.secondary)+ }+ Spacer()+ SoftButton(strip.button, dark: true, action: strip.action)+ }+ .padding(10).frame(maxWidth: .infinity, alignment: .leading)+ .background(RoundedRectangle(cornerRadius: 9).fill(Palette.accentPale))}if settings.speakEnabled, model.virtualMic != nil, let user = model.micUsers.first(where: { $0.state.isOther }) {HStack {@@ -271,6 +293,45 @@ struct MenuPanelView: View {}}+extension MenuPanelView {+ /// ⋯ next to the 同声传译 switch: its settings, 试一句, and putting the system mic back by hand.+ var speakMenu: some View {+ Menu {+ Button("同声传译设置…") { model.openSettings(.speak) }+ Button("试一句") { model.openSettings(.speak); model.speakTestShown = true }+ .disabled(model.virtualMic == nil)+ Divider()+ switch model.systemMicState {+ case .moved, .off where model.wantsSystemMic:+ Button("系统麦克风换成 \(model.virtualMic?.name ?? "BlackHole 2ch")") { model.switchSystemMic() }+ default:+ Button("还原系统麦克风") { model.restoreSystemMic() }+ .disabled(model.systemMicState == .off)+ }+ } label: {+ Image(systemName: "ellipsis").font(.system(size: 12, weight: .semibold)).foregroundStyle(Palette.secondary)+ .frame(width: 26, height: 22)+ .background(RoundedRectangle(cornerRadius: 6).fill(Palette.fill))+ .contentShape(Rectangle())+ }+ .menuStyle(.button).buttonStyle(.plain).menuIndicator(.hidden).fixedSize()+ .help("同声传译选项")+ }++ /// Something left the system mic wrong: say what, and the one button that fixes it.+ var systemMicStrip: (title: String, detail: String, button: String, action: () -> Void)? {+ let virtual = model.virtualMic?.name ?? "BlackHole 2ch"+ switch model.systemMicState {+ case .notRestored:+ return (L("系统麦克风还是 \(virtual)"), L("别的软件现在听不到你说话"), L("还原"), model.restoreSystemMic)+ case .moved(let to):+ return (L("系统麦克风被换成了 \(to)"), L("跟随系统的网页听不到译文"), L("换回"), model.switchSystemMic)+ default:+ return nil+ }+ }+}+struct KeyCap: View {let text: Stringinit(_ text: String) { self.text = text }diff --git a/Sources/LiveSubs/VoicePicker.swift b/Sources/LiveSubs/VoicePicker.swiftindex 58b45e2..83c8198 100644--- a/Sources/LiveSubs/VoicePicker.swift+++ b/Sources/LiveSubs/VoicePicker.swift@@ -335,7 +335,7 @@ struct VoiceCloneSheet: View {HStack(spacing: 8) { Spinner(size: 14); Text("正在听写…").font(.system(size: 12)).foregroundStyle(Palette.secondary) }default:SoftButton(recorder.phase == .idle ? L("开始录") : L("再录一次"), dark: true) {- recorder.start(locale: ownLocale)+ recorder.start(locale: ownLocale, device: model.systemMic.recordingDevice)}.disabled(!consent)}@@ -390,7 +390,7 @@ struct VoiceCloneSheet: View {Text("听起来不像或有杂音?换个安静的地方重录一次。录音仅保存在本机,可随时删除。").font(.system(size: 12)).foregroundStyle(Palette.tertiary)HStack {- SoftButton(L("重录")) { player?.stop(); recorder.start(locale: ownLocale) }+ SoftButton(L("重录")) { player?.stop(); recorder.start(locale: ownLocale, device: model.systemMic.recordingDevice) }Spacer()SoftButton(L("用这个声音"), dark: true) { save() }}diff --git a/Sources/LiveSubs/Voices.swift b/Sources/LiveSubs/Voices.swiftindex fe09321..5d9bc96 100644--- a/Sources/LiveSubs/Voices.swift+++ b/Sources/LiveSubs/Voices.swift@@ -185,12 +185,14 @@ final class VoiceRecorder: ObservableObject {private let format = AVAudioFormat(commonFormat: .pcmFormatInt16, sampleRate: 16000, channels: 1, interleaved: true)!private var locale = "zh-CN"- func start(locale: String) {+ /// `device`: the real mic; the system default may be the virtual mic while speaking is on.+ func start(locale: String, device: OutputDevice?) {stopEngine()self.locale = localetranscript = ""try? FileManager.default.removeItem(at: url)let input = engine.inputNode+ AudioDevices.pinInput(engine, to: device)let inFormat = input.outputFormat(forBus: 0)guard inFormat.sampleRate > 0,let f = try? AVAudioFile(forWriting: url, settings: format.settings, commonFormat: .pcmFormatInt16, interleaved: true),diff --git a/Tests/LiveSubsTests/SystemMicTests.swift b/Tests/LiveSubsTests/SystemMicTests.swiftnew file mode 100644index 0000000..b7f05d7--- /dev/null+++ b/Tests/LiveSubsTests/SystemMicTests.swift@@ -0,0 +1,37 @@+import Foundation+import Testing+@testable import LiveSubs++@Suite struct SystemMicTests {+ let builtIn = SystemMicPlan.Device(uid: "BuiltInMicrophoneDevice", isVirtual: false)+ let airpods = SystemMicPlan.Device(uid: "airpods", isVirtual: false)+ let blackhole = SystemMicPlan.Device(uid: "BlackHole2ch_UID", isVirtual: true)+ var all: [SystemMicPlan.Device] { [blackhole, builtIn, airpods] }++ @Test func savedMicComesBackWhilePluggedIn() {+ #expect(SystemMicPlan.original(saved: "airpods", current: blackhole.uid, inputs: all) == "airpods")+ }++ @Test func unpluggedSavedMicFallsBackToARealOne() {+ #expect(SystemMicPlan.original(saved: "airpods", current: blackhole.uid, inputs: [blackhole, builtIn]) == builtIn.uid)+ }++ @Test func currentRealMicIsTheOriginalWhenNothingIsSaved() {+ #expect(SystemMicPlan.original(saved: "", current: "airpods", inputs: all) == "airpods")+ }++ /// The user had already picked BlackHole as the system mic by hand: "back" must still be a real mic.+ @Test func neverRestoresToTheVirtualMic() {+ #expect(SystemMicPlan.original(saved: "", current: blackhole.uid, inputs: all) == builtIn.uid)+ #expect(SystemMicPlan.original(saved: blackhole.uid, current: blackhole.uid, inputs: all) == builtIn.uid)+ #expect(SystemMicPlan.original(saved: "", current: blackhole.uid, inputs: [blackhole]) == nil)+ }++ @Test func recordingUsesTheChosenMicElseTheOriginal() {+ #expect(SystemMicPlan.recording(chosen: "airpods", saved: builtIn.uid, current: blackhole.uid, inputs: all) == "airpods")+ #expect(SystemMicPlan.recording(chosen: "", saved: builtIn.uid, current: blackhole.uid, inputs: all) == builtIn.uid)+ // A chosen mic that's unplugged, or the virtual mic itself, is skipped.+ #expect(SystemMicPlan.recording(chosen: "gone", saved: "", current: "airpods", inputs: all) == "airpods")+ #expect(SystemMicPlan.recording(chosen: blackhole.uid, saved: "", current: blackhole.uid, inputs: all) == builtIn.uid)+ }+}diff --git a/docs/ROADMAP.md b/docs/ROADMAP.mdindex 1df557e..66909f8 100644--- a/docs/ROADMAP.md+++ b/docs/ROADMAP.md@@ -11,6 +11,7 @@ In rough order, and subject to change. Tell us what you need in Issues.- **Telling speakers apart.** Today lines are labeled only as "them" or "you". Next, Cicada will separate individual remote speakers (Speaker 1, Speaker 2…, renamable) and tag conclusions and to-dos with who said them.- **Local notes without an API key.** Use Apple's on-device model to generate meeting notes on supported Macs, keeping all audio and text local.- **Custom AI providers.** Support any OpenAI-compatible API endpoint besides Ling.+- **Live voice changing.** No translation: your voice goes into the meeting as a different voice, changed as you speak, without holding the talk key. Setting "I speak" and "They hear" to the same language already swaps the voice today, but it goes through text, so the room hears it only after you let go and your tone is lost.**Later**- **Speaker recognition.** Remember frequent meeting participants by voice so you don't have to rename speakers every call. Because voiceprints are biometric data, they stay on your Mac, require opt-in, and can be deleted anytime.diff --git a/docs/ROADMAP.zh-CN.md b/docs/ROADMAP.zh-CN.mdindex a825186..bb7789e 100644--- a/docs/ROADMAP.zh-CN.md+++ b/docs/ROADMAP.zh-CN.md@@ -11,6 +11,7 @@- **区分说话人**。现在只分“对方”和“你”,之后会把对方里的不同人分开(说话人 1、说话人 2……,可以改成名字),纪要里的结论和待办也会标上是谁说的。- **不用 key 也有纪要**。在支持的 Mac 上用 Apple 的本机模型整理纪要,声音和文字都不出电脑。- **自选 AI 服务**。除了 Ling,也能填其他兼容 OpenAI 接口的服务。+- **实时变声**。不翻译,只把你的声音换成另一个声音送进会议,边说边换,不用按住说话。现在把“我说”和“对方听到”设成同一种语言也能换声音,但要先识别成文字再念出来,松开后才有声音,语气也会丢。**更远**- **声纹识别**。记住常一起开会的人的声音,下次开会自动认出是谁,不用每场重新改名。声纹属于敏感生物特征,只保存在本机,由你手动开启,随时可以删掉。diff --git a/site/changelog.json b/site/changelog.jsonindex 930c0d6..a4f5e2c 100644--- a/site/changelog.json+++ b/site/changelog.json@@ -1,4 +1,18 @@[+ {+ "version": "2.3.0",+ "date": null,+ "title": "同声传译自动切换系统麦克风",+ "summary": "打开同声传译时,系统麦克风自动换成虚拟麦克风,Chrome 里的会议网页不用再手动设置;关掉或退出时自动换回。",+ "image": null,+ "items": [+ {+ "kind": "new",+ "title": "Chrome 里开会也不用设置麦克风了。",+ "text": "打开同声传译时,知了把系统麦克风换成 BlackHole 2ch,关掉同声传译或退出知了时换回原来的麦克风,用“默认”麦克风的会议网页和软件直接就能听到译文。知了自己仍然用你的真实麦克风听你说话,也可以在设置里固定一个。上次没来得及换回(比如知了意外退出),或者说话时插上 AirPods 把系统麦克风换走了,菜单栏面板会提示,点一下还原或换回;面板上同声传译旁边的 ⋯ 里也能随时还原。不想自动切换的话,可以在设置的同声传译里关掉。"+ }+ ]+ },{"version": "2.2.0","date": "2026-11-02",diff --git a/tools/README.md b/tools/README.mdindex 08a45f6..dd447b4 100644--- a/tools/README.md+++ b/tools/README.md@@ -12,6 +12,7 @@- 会议软件的麦克风:`micUsers` 把每个读麦克风的进程和列表写进日志,`micGuide:<bundle id 或名字>` 打开怎么改,`micGuideRender:<bundle id>=<png>`- 快捷键:`talkKey:right` 或 `talkKey:<keyCode>:<Carbon 修饰键>` 换说话键(被拒的原因写进日志),`toggleKey:…` 同理,`shortcuts` 把当前状态写进日志- 字幕条:`frame` 把位置写进日志,`place:x,y,宽,字号` 摆到指定位置+ - 系统麦克风:`sysMic` 把状态、默认输入、要换回的麦克风和知了实际在录的麦克风写进日志,`sysMicSet:<设备名片段>` 假装别人改了系统麦克风,`sysMicRestore` 还原,`sysMicSwitch` 换成虚拟麦克风,`sysMicAuto:<on|off>`,`speakMic:<设备名片段>` 固定知了用的麦克风(留空 = 自动)。会改本机的系统麦克风:测完 `sysMicRestore` 或退出 App- 说话同传:`speakOn` / `speakOff` 开关,`speakFile:<音频>` 把文件按实时速度当作麦克风输入,`speakOut:<路径>` 把译文语音另存一份,`speakOutput:<设备名片段>` 改输出设备(留空 = 虚拟麦克风)- 试一句:`speakTest:sample`(Mac 读一句示例)或 `speakTest:voice`(再发 `speakTestBegin` / `speakTestEnd` 当作按住、松开),结果以 `speak test:` 写进日志;`speakTestState`、`speakTestRender:<png>`、`speakTestClose`- 多开:两边都设 `CICADA_DEBUG_CHANNEL=x`(`open -n --env CICADA_DEBUG_CHANNEL=x build/Cicada.app`),命令只发给这一份,日志在 `/tmp/livesubs-dev-debug-x.log`