Skip to content

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

feat: speaker labels, simpler interpreting panel and settings, quiet meeting auto-end

wquguru32ccf79e9ec8
diff --git a/AGENTS.md b/AGENTS.md
index 9cc5f97..4661ae4 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -6,7 +6,7 @@ Cicada (知了, formerly Live Subs): a macOS menu bar app that turns what the Ma
- Surfaces: menu bar panel, live notes window (default) or subtitle bar while listening, main window (meeting records), settings, four-step onboarding (system audio, sample meeting, Ling key, speaking if wanted). A request that fits none of them gets pushed back before any UI is added.
- Nothing the user does needs the Terminal.
-- Listening: Core Audio process tap → on-device language detection and `SpeechAnalyzer` → translation. Speaking: hold right ⌥ or a shortcut → mic → Ming (with a Ling key) or on-device + translation → voice → BlackHole 2ch virtual mic.
+- Listening: Core Audio process tap → on-device language detection and `SpeechAnalyzer` → translation. Experimental voices: a bundled Core ML voiceprint model (`SpeakerID.swift`), compiled on first use. Speaking: hold right ⌥ or a shortcut → mic → Ming (with a Ling key) or on-device + translation → voice → BlackHole 2ch virtual mic.
## Hard rules
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9a3b3f4..87c4230 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,9 +5,14 @@ the release workflow publishes it as the release notes.
## Unreleased
+- Fixed: a meeting where nobody ever spoke no longer listens forever. After the 结束会议 silence time (10 minutes by default) with nothing recognized, and no meeting app in a call, Cicada stops listening quietly, without a countdown since there is nothing to keep, and the switch goes back to 开始听. 一直记录 still keeps it listening.
+- Changed: the live notes window and Settings › 诊断 no longer look blank before anyone speaks. 纪要 shows one line (有人开口后,约半分钟出第一版) above the notes' own outline, shimmering where the summary and topics will appear, with what will be pulled out (结论, 待办, 人名和术语, 鱼骨图). 文字记录 shows when listening began, two rows in the bilingual shape lines will take, and 此刻 waiting with a blinking caret; a stray "." from background noise no longer replaces it. 诊断 shows the path of a sentence with what each stage measures, the translation routes with their colours, Ling 本场还没调用 and a faded example sentence in place of dashes, an empty bar and zeros; 复制诊断信息 waits until there is something to copy.
+- New (experimental): 说话人识别, in Settings › 通用 › 实验功能 and off by default, labels the other side's lines 说话人 1, 2… by voice, on this Mac. A voice is named once it has five lines and only when at least two are heard, so a one-to-one call still reads 对方; unsure lines stay 对方. The notes window shows who is speaking with an 实验 tag and a 不准?关掉 link, and the records window, Markdown and Word exports and the notes use the same names. With a Ling key, the names fill themselves in: Ling reads how people address each other ("Thanks, George") once two voices are named, every 20 lines after that and again when the meeting ends, and the voice shows as George. Click a person above the transcript (in the records window; from the notes window it opens there) to see the line the name came from, correct it, turn it down (不是 TA) or merge two voices that are the same person; your name always wins over Ling's. Names show everywhere the numbers did, once per change of speaker as in a chat; lines whose voice isn't one of them say 未识别 rather than 对方, and to-dos in the notes name their owner (George) instead of 对方. The people above the transcript wrap onto a second line in a narrow window instead of shrinking to one letter. Turning it off hides the names again. It uses the WeSpeaker ResNet34-LM voiceprint model (VoxCeleb, CC BY 4.0), bundled with the app.
+- Changed: Settings › 同声传译 is half as long. One card at the top says whether the other side can hear you (对方听得到你, with the last delay and 试一句); only when something is wrong does it open into a checklist: what already works with a tick, and each problem (the system mic taken over or not put back, a meeting app on another mic, Input Monitoring for right ⌥) with its one button. Below are two plain groups with no helper text: 说话 (the talk key, the language they hear, the voice) and 麦克风 (switch the system mic while on, which mic Cicada listens through, where the translation goes, formerly under 高级). The on/off switch sits beside the page title. Gone: the numbered setup steps once the virtual mic is installed, the separate 系统麦克风 status row with 立即还原, the 会议软件的麦克风 list with its empty state and footnote, and the 高级 disclosure.
+- Changed: the menu bar panel's 同声传译 section says what it does. The first time you turn it on, it asks in place (the system mic switches to BlackHole 2ch, hold right ⌥ to talk, turning it off puts everything back) with 取消 / 好,打开; after that the switch just switches, and hovering it says the same. While it's on, the talk key is drawn as a key with what the room hears (对方听到 English · 腾讯会议) and a green dot; it lights up orange with 正在听… / 正在翻译… / 正在播出… while you talk. Whatever stops the room hearing you (a meeting app on another mic, the virtual mic not set up, Input Monitoring for right ⌥) shows on that key in one line with its fix, instead of a separate red strip. The ⋯ menu is gone: 设置 sits beside the switch and 先试一句 shows until you've tried one. When off, the row shows only the languages, since the key does nothing then. Fixed: System Settings › Sound (and Cicada's other Apple neighbours that read the mic) no longer shows up as a meeting app that hasn't picked the virtual mic.
- Changed: the menu bar panel's display section is easier to read. 显示方式 is three tiles with a small picture each (实时纪要, 字幕条, 不显示), and under them one card holds only the chosen mode's settings: for the notes, whether the window is open with an 打开 / 收起 button (收起 hides it without opening the records window) and 共享屏幕时让对方看到 (formerly 录屏时显示纪要窗口); for the subtitle bar, when it appears and how long it waits; for 不显示, a line saying the transcript is still saved. The ⌃⌥S shortcut sits beside the title, and the 字幕 row above (原文 + 译文) is now called 内容 so 字幕 no longer means two things. The segmented choices left in system blue (the subtitle bar's timing in the panel and Settings, 显示方式 in Settings, 双语 / 原文 / 译文 in the records window) now use the app's own grey track with a white thumb, and the two subtitle bar choices in the panel line up at the same width.
-- Changed: the records window is one white page. The title bar holds the switch, led by the logo: a white pill with the logo and 知了 · 开始听 (⌘R) when idle; while listening an ink pill where the logo breathes, bars follow the sound and the time runs, with 结束; when a meeting is about to end, a countdown ring around the logo with 继续记录. The window buttons sit on the same line. The list is one line per meeting (title and time; 未命名会议 for untitled ones, without the date the notes title starts with); the page has no card or toolbar: a grey line of facts, the title, then 纪要 / 文字记录 and 导出… (which also has 在 Finder 中显示). In a wide window, 原话 beside 导出… puts the original and translation next to the notes (off by default, remembered), and a topic's time scrolls them there. While recording, 此刻 pins the sentence being heard under the page. The window opens a little larger. Later: the list is titles only on a faint tint (time and length in the tooltip), with only the newest day shown and the rest under 更早的会议; the page is a narrower column that opens with the conclusions in one block, then the summary, then numbered topics that fold open to their points (the first and the one being discussed start open). With no meetings yet, the window shows only the logo, 还没有会议, 开始听 and 先听一段示例.
-- 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.
+- Changed: the records window is one white page. The title bar holds the switch, led by the logo: a white pill with the logo and 知了 · 开始听 (⌘R) when idle; while listening an ink pill where the logo breathes, bars follow the sound and the time runs, with 结束; when a meeting is about to end, a countdown ring around the logo with 继续记录. The window buttons sit on the same line. The list is one line per meeting (title and time; 未命名会议 for untitled ones, without the date the notes title starts with); the page has no card or toolbar: a grey line of facts, the title, then 纪要 / 文字记录 and 导出… (which also has 在 Finder 中显示). In a wide window, 原话 beside 导出… puts the original and translation next to the notes (off by default, remembered), and a topic's time scrolls them there. While recording, 此刻 pins the sentence being heard under the page. The window opens a little larger. Later: the list is titles only on a faint tint (time and length in the tooltip), with only the newest day shown and the rest under 更早的会议; the page is a narrower column that opens with the conclusions in one block, then the summary, then numbered topics that fold open to their points (the first and the one being discussed start open). With no meetings yet, the window shows only the logo, 还没有会议, 开始听 and 先听一段示例. Text has three greys (headings, body, labels); times you can click and the note numbers are in the logo's orange as ink, numbers and dates in the conclusions are highlighted, and with 说话人识别 on each speaker's label has its own colour, in the transcript and beside the notes.
+- 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 switch can be turned off in Settings.
- Changed: the installer window explains the first-open warning. While the developer certificate is pending, macOS says Apple can't verify Cicada; the window, now a little taller, says this is expected and shows the three screens to click through in miniature, each with the button ringed: 完成 (not 移到废纸篓), 隐私与安全性 in System Settings, then 仍要打开 under 安全性.
- New: 共享屏幕时让对方看到 lets screen recordings capture the live notes window, for demos and tutorials. It is off by default; turn it on in Settings › 显示, the menu bar panel, or 显示 › 共享屏幕时对方可见 in the app menu. macOS has one switch for recording and screen sharing, so while it is on people also see the notes when you share your screen: the notes window shows a breathing record mark next to its status the whole time, and clicking it turns the setting off. In a narrow English window, the title and the status line no longer break onto two lines.
- Changed: the first-run guide shows the subtitles before asking for anything else. It now goes 听声音 → 看效果 → 接 Ling → 同声传译, each step named under the progress bar. Step 1 asks only for system audio and moves on by itself once it's on; the microphone is asked for when you set up 同声传译. The sample, now a short two-person meeting voiced by Ming and drawn as a call whose subtitles never cover the speakers, comes before the Ling key, with a note that the same subtitles become notes once Ling is connected. Skipping the key (先不接) first shows what works without it (subtitles, the bilingual transcript, 同声传译 with the Mac's voices) and what waits for Ling, and that past meetings can still get notes later. The 同声传译 step starts with a yes/no, so the virtual mic checklist only appears for those who want it. A last page points to the menu bar icon before the records window opens.
diff --git a/README.md b/README.md
index 4d9aede..a6d8f6a 100644
--- a/README.md
+++ b/README.md
@@ -90,6 +90,7 @@ Without a Ling key, everything runs on Apple's on-device models plus Google Tran
| Checking the key | Ling `Ling-3.0-tiny` (one token) | — |
| Interpreting: hearing and translating what you say | Ming `Ming-3.0-audio-flash`, one step | Apple on-device transcript, then the translation chain above |
| Interpreting: the voice the room hears, voice cloning | Ming `Ming-3.0-tts-0.5B` | macOS system voices (`AVSpeechSynthesizer`); no cloning |
+| Speaker identification (说话人识别, experimental, off by default) | WeSpeaker ResNet34-LM voiceprints, bundled, on device (Core ML) | same |
<a id="ling-api-key"></a>
## Setting up a Ling API key
@@ -153,4 +154,4 @@ See [AGENTS.md](AGENTS.md) for architecture details and release workflows. The w
## License
-[Apache-2.0](LICENSE). The BlackHole 2ch virtual audio driver is licensed under the GPL; Cicada does not bundle it and downloads the official release on demand when you choose to install it.
+[Apache-2.0](LICENSE). The BlackHole 2ch virtual audio driver is licensed under the GPL; Cicada does not bundle it and downloads the official release on demand when you choose to install it. The bundled voiceprint model is [WeSpeaker](https://github.com/wenet-e2e/wespeaker)'s ResNet34-LM trained on VoxCeleb, licensed CC BY 4.0, converted to Core ML by `scripts/convert-voiceprint.py`.
diff --git a/README.zh-CN.md b/README.zh-CN.md
index d5ad721..1b05e02 100644
--- a/README.zh-CN.md
+++ b/README.zh-CN.md
@@ -90,6 +90,7 @@
| 检查 key 是否有效 | Ling `Ling-3.0-tiny`(只用一个 token) | — |
| 同声传译:听懂并翻译你说的话 | Ming `Ming-3.0-audio-flash`,一步完成 | Apple 本机识别,再走上面的翻译链 |
| 同声传译:对方听到的声音、声音克隆 | Ming `Ming-3.0-tts-0.5B` | Mac 自带语音(`AVSpeechSynthesizer`),不能克隆 |
+| 说话人识别(实验功能,默认关闭) | WeSpeaker ResNet34-LM 声纹模型,随 app 附带,本机运行(Core ML) | 同左 |
## 配置 Ling API key
@@ -152,4 +153,4 @@ scripts/package.sh # 打包正式版 DMG、zip 和 SHA-256 校验值
## 开源协议
-本项目采用 [Apache-2.0](LICENSE) 协议开源。同声传译用到的虚拟麦克风驱动 BlackHole 2ch 采用 GPL 协议,知了安装包里不打包它,而是在你点安装时直接从它的官方发布地址下载。
+本项目采用 [Apache-2.0](LICENSE) 协议开源。同声传译用到的虚拟麦克风驱动 BlackHole 2ch 采用 GPL 协议,知了安装包里不打包它,而是在你点安装时直接从它的官方发布地址下载。随 app 附带的声纹模型是 [WeSpeaker](https://github.com/wenet-e2e/wespeaker) 在 VoxCeleb 上训练的 ResNet34-LM,采用 CC BY 4.0 协议,由 `scripts/convert-voiceprint.py` 转成 Core ML。
diff --git a/Resources/en.lproj/Localizable.strings b/Resources/en.lproj/Localizable.strings
index 0e08cba..f19821f 100644
--- a/Resources/en.lproj/Localizable.strings
+++ b/Resources/en.lproj/Localizable.strings
@@ -39,6 +39,7 @@
"把 Mac 正在播放的声音变成实时双语字幕和会议纪要" = "Live bilingual subtitles and meeting notes from whatever your Mac is playing";
"网站" = "Website";
"反馈问题" = "Report an Issue";
+"声纹模型:WeSpeaker ResNet34-LM(VoxCeleb),CC BY 4.0" = "Voiceprint model: WeSpeaker ResNet34-LM (VoxCeleb), CC BY 4.0";
/* AppMenu */
"关于 %@" = "About %@";
@@ -127,6 +128,7 @@
"换后备 " = "Fallbacks ";
"无" = "none";
"Ling 请求 %d 次 · 排队最久 %.2fs · token %d/%d" = "Ling requests: %d · longest queue %.2fs · tokens %d/%d";
+"有人说话后,这里会显示每句话的耗时明细" = "Each sentence's timing shows here once someone speaks";
"这场会议 · %lld 分钟 · %lld 句 · 同声传译 %lld 次" = "This meeting · %lld min · sentences: %lld · interpreted: %lld";
"开始聆听后,这里会显示每句话的耗时明细" = "Once listening starts, the timing of every sentence shows here";
"说完到上屏" = "Speech end → on screen";
@@ -138,8 +140,22 @@
"打开日志" = "Open Log";
"打开本场数据" = "Open Meeting Data";
"暂无数据" = "No data yet";
+"一句话的路" = "A sentence's path";
+"还没有句子" = "No sentences yet";
+"听清这句话" = "Hearing it";
+"译成目标语言" = "Translating it";
+"你感到的延迟" = "The delay you feel";
+"更新一次纪要" = "One notes update";
+"翻译通道" = "Translation";
+"Ling 用量" = "Ling usage";
+"账号上限约每秒 2 次" = "The account allows about 2 per second";
"Ming 语音" = "Ming voice";
"没译出" = "Not translated";
+"本场还没调用" = "Not used yet";
+"最近的句子" = "Recent sentences";
+"示例 · 对方" = "Example · them";
+"识别" = "Recognize";
+"排队" = "Queue";
"被搜索劫持" = "Search hijack";
"限流" = "Rate limited";
"超时" = "Timeout";
@@ -149,12 +165,10 @@
"翻译通道分布" = "Translation providers";
"共 %lld 句" = "Total: %lld";
"Ling 请求速度" = "Ling request rate";
-"账号上限约每秒 2 次" = "The account allows about 2 per second";
"排队最久" = "Longest queue";
"本场用量" = "This meeting's usage";
"%.1f / 2 次每秒" = "%.1f / 2 per second";
"%lld 次 · %lld token" = "requests: %lld · tokens: %lld";
-"最近的句子" = "Recent sentences";
"还没有" = "None yet";
"你" = "You";
"对方" = "Them";
@@ -207,19 +221,13 @@
"正在识别语言…" = "Detecting language…";
"翻译暂不可用" = "Translation unavailable for now";
+/* ListenPill */
+"开始听" = "Start listening";
+"知了" = "Cicada";
+"会议已自动结束" = "Meeting ended by itself";
+"结束" = "End";
+
/* 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";
-"还没有会议软件在用麦克风,进会议后这里会显示" = "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 %@";
@@ -254,9 +262,9 @@
"依据较少" = "Little evidence";
"依据 %lld 句" = "Evidence: %lld";
"%@ · %lld 句" = "%@ · %lld lines";
-"看原话" = "See what was said";
"正在讲" = "Now";
"新" = "New";
+"看原话" = "See what was said";
"%@ 起" = "From %@";
"回到原话" = "Back to transcript";
"点击分支跳回原话" = "Click a branch to jump to what was said";
@@ -266,7 +274,14 @@
"说话的内容会出现在这里" = "What's said will appear here";
"%lld 句新内容" = "%lld new lines";
"正在说" = "Speaking";
-"有人说话时,会自动开始写纪要" = "Notes start on their own once someone speaks";
+"从这里开始听" = "Listening began";
+"原话" = "Original";
+"译文" = "Translation";
+"此刻" = "Now";
+"等有人开口" = "Waiting for someone to speak";
+"有人开口后,约半分钟出第一版" = "First notes about 30 s after someone speaks";
+"会整理出" = "You'll get";
+"待办" = "To-dos";
"已听到 %lld 句" = "Heard %lld lines";
"正在生成纪要" = "Writing notes";
"正在更新" = "Updating";
@@ -281,7 +296,6 @@
"收窄" = "Narrow";
"收成小卡" = "Collapse to card";
"这场会议的语言" = "Languages for this meeting";
-"结束" = "End";
"正在听 · " = "Listening · ";
"正在记录 · " = "Recording · ";
"%lld 句" = "%lld lines";
@@ -445,8 +459,8 @@
/* SessionStore */
"会议 %@" = "Meeting %@";
+"未识别" = "Unidentified";
"不到 1 分钟" = "Under 1 min";
-"待办" = "To-dos";
/* SettingsWindow */
"语言" = "Language";
@@ -464,7 +478,6 @@
"还差一步:允许“输入监控”" = "One more step: allow “Input Monitoring”";
"“按住右 ⌥ 说话”需要此权限。请在系统设置中勾选 %@,返回此处即可生效" = "“Hold right ⌥ to talk” needs this. Turn on %@ in System Settings, then come back";
"去允许" = "Allow";
-"知了" = "Cicada";
"再试一次" = "Try Again";
"虚拟麦克风已就绪" = "Virtual microphone ready";
"%@ · 试音通过,对方听得到" = "%@ · sound test passed, they can hear you";
@@ -488,36 +501,37 @@
"对方会听到:" = "They will hear: ";
"一段声音" = "a sound";
"虚拟麦克风未收到声音,请再试一次" = "The virtual microphone got no sound; try again";
-"说一句话,听对方听到的声音,看每一步花了多久" = "Say one sentence, hear what they hear, and see how long each step takes";
"把我说的翻译给对方" = "Translate what I say for them";
+"说话" = "Speaking";
+"按住说话" = "Hold to talk";
+"说%@,对方听到" = "You speak %@, they hear";
+"按键还需要“输入监控”权限" = "The key needs Input Monitoring";
+"系统麦克风还是 %@,别的软件听不到你" = "System mic is still %@; other apps can't hear you";
+"还原" = "Restore";
+"系统麦克风被换成了 %@" = "System mic changed to %@";
+"换回" = "Switch back";
+"系统麦克风还没换成 %@" = "System mic isn't %@ yet";
+"切换" = "Switch";
+"%@还在用 %@" = "%@ still uses %@";
+"%@没选虚拟麦克风" = "%@ isn't on the virtual mic";
+"怎么改" = "How to fix";
+"虚拟麦克风 %@" = "Virtual mic %@";
+"系统麦克风已换好,关掉时换回" = "System mic switched; it goes back when you turn this off";
+"%@已选虚拟麦克风" = "%@ is on the virtual mic";
+"说一句话,听对方听到的声音,看每一步花了多久" = "Say one sentence, hear what they hear, and see how long each step takes";
+"对方听不到你" = "They can't hear you";
+"对方听得到你" = "They can hear you";
+"同声传译没打开" = "Interpreting is off";
"上次发言:松开后 %@ 秒,对方听到译文" = "Last time: they heard the translation %@ s after you let go";
"按住说话,松开后约 1 秒,对方听到译文" = "Hold to talk; about 1 s after you let go, they hear the translation";
"按住说话,松开后约 3 秒,对方听到译文" = "Hold to talk; about 3 s after you let go, they hear the translation";
"试一句" = "Try it";
-"按住说话" = "Hold to talk";
-"单独按住右侧 ⌥;和别的键一起按不触发" = "Hold the right ⌥ alone; it does nothing with other keys";
-"按住快捷键说话,松开发送" = "Hold the shortcut to talk, let go to send";
-"声音输出到" = "Send voice to";
-"对方只能听到虚拟麦克风里的声音" = "They only hear what goes into the virtual microphone";
-"虚拟麦克风(自动)" = "Virtual microphone (auto)";
-"高级:声音输出到 · %@" = "Advanced: voice goes to · %@";
-"%@ 已装好" = "%@ 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";
+"打开时把系统麦克风换成 %@" = "Switch the system mic to %@ while on";
"%@听你说话用" = "%@ 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";
+"译文送到" = "Send the translation to";
+"自动切换系统麦克风" = "Switch the system microphone";
"自动(%@)" = "Auto (%@)";
+"虚拟麦克风(自动)" = "Virtual microphone (auto)";
"听的时候显示" = "While listening, show";
"选择任意模式都会正常保存记录、生成纪要" = "Every mode still saves the meeting and writes notes";
"切换显示方式" = "Switch display";
@@ -542,6 +556,10 @@
"提醒后结束" = "Ask, then end";
"直接结束" = "End";
"一直记录" = "Keep going";
+"实验功能" = "Experimental";
+"还在打磨,可能出错;随时能关,关掉不影响别的功能。" = "Still being tuned and may get things wrong. Turn it off any time; nothing else is affected.";
+"按声音标出说话人 1、2…,只在这台 Mac 上处理" = "Labels lines Speaker 1, 2… by voice, on this Mac only";
+"说话人识别" = "Speaker identification";
/* Shortcuts */
"右 ⌥" = "Right ⌥";
@@ -589,7 +607,6 @@
"松开就发送" = "Let go to send";
"你的话" = "Your words";
"识别 + 翻译" = "Recognize + translate";
-"识别" = "Recognize";
"合成声音" = "Voice";
"示例句子" = "Sample sentence";
"麦克风峰值 %lld dB" = "Mic peak %lld dB";
@@ -639,6 +656,24 @@
"再试一句" = "Try again";
"复制报告" = "Copy report";
+/* SpeakerID */
+"说话人 %lld" = "Speaker %lld";
+"没认出是谁:太短,或和已知的声音都不像" = "Not recognised: too short, or unlike the known voices";
+"实验" = "Beta";
+"关掉说话人识别,记录里的名字一起收起" = "Turn off speaker identification; the names in your records are hidden too";
+"Ling 从对话里认出,点一下可以改" = "Ling found this name in the conversation; click to change";
+"改名字,或和别人合并" = "Rename, or merge with someone else";
+"不准?关掉" = "Wrong? Turn off";
+"说了 %lld 句" = "%lld lines";
+"名字" = "Name";
+"Ling 正在从对话里找名字…" = "Ling is looking for names in the conversation…";
+"输入名字" = "Type a name";
+"Ling 从对话里认出" = "Found by Ling in the conversation";
+"Ling 从对话里认出:%@" = "Found by Ling in the conversation: %@";
+"不是 TA" = "Not them";
+"其实是同一个人" = "Actually the same person";
+"并入 %@" = "Merge into %@";
+
/* SystemAudioTap */
"无法启动音频采集(%d)" = "Can't start audio capture (%d)";
"无法初始化音频单元(%d)" = "Can't initialize the audio unit (%d)";
@@ -685,20 +720,12 @@
/* Views */
"自动识别(%@)" = "Auto-detect (%@)";
"%@(需下载)" = "%@ (download needed)";
-"按住" = "Hold";
-"说%@ → %@" = "%1$@ → %2$@";
-"会议已自动结束" = "Meeting ended by itself";
"系统" = "System";
"内容" = "Content";
"仅本场" = "This meeting";
-"%@已选虚拟麦克风" = "%@ 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";
+"跟随系统的网页听不到译文" = "Pages on the default mic won't hear the translation";
"显示方式" = "Display";
"轮换" = "to switch";
"屏幕上不出字幕,文字记录照常保存" = "Nothing on screen; the transcript is still saved";
@@ -707,26 +734,37 @@
"纪要窗口已打开" = "Notes window is open";
"纪要窗口已收起" = "Notes window is hidden";
"对方现在能看到纪要窗口" = "Others can see the notes window now";
-"同声传译设置…" = "Interpreting Settings…";
-"系统麦克风换成 %@" = "Switch System Mic to %@";
-"还原系统麦克风" = "Restore System Mic";
+"系统麦克风换成 %@" = "System mic switches to %@";
+"译文送进 %@" = "Translations go into %@";
+"先装好虚拟麦克风,对方才听得到" = "Install the virtual mic first so others can hear";
+"打开:%@,按住 %@ 说话\n关掉:全部还原" = "On: %@; hold %@ to talk\nOff: everything goes back";
+"先试一句 →" = "Try one sentence first →";
+"说%@ → %@" = "%1$@ → %2$@";
+"按住说%@" = "Hold to speak %@";
+"正在翻译…" = "Translating…";
+"正在播出…" = "Playing…";
+"松开后播出%@" = "Release to play in %@";
+"打开后:" = "When on:";
+"按住" = "Hold";
+"说话,松开后播出译文" = "to talk, release to play the translation";
+"关掉后全部还原" = "Turning it off puts everything back";
+"好,打开" = "Turn On";
+"虚拟麦克风还没装好" = "Virtual mic isn't set up yet";
+"对方听到 %@ · %@" = "They hear %@ · %@";
+"对方听到 %@" = "They hear %@";
"搜索" = "Search";
-"导出…" = "Export…";
-"收起更早的会议" = "Hide earlier meetings";
-"更早的会议" = "Earlier meetings";
-"还没有会议" = "No meetings yet";
-"打开会议或视频,开始听后,每一场都会存在这里。" = "Open a meeting or a video and start listening: each one is kept here.";
-"先听一段示例" = "Try a sample first";
"没有找到“%@”" = "Nothing found for “%@”";
"今天" = "Today";
"昨天" = "Yesterday";
"本周" = "This Week";
+"收起更早的会议" = "Hide earlier meetings";
+"更早的会议" = "Earlier meetings";
"未命名会议" = "Untitled meeting";
+"%lld 小时" = "%lld h";
+"%lld 小时 %lld 分" = "%lld h %lld min";
"在 Finder 中显示" = "Show in Finder";
"恢复自动标题" = "Restore Automatic Title";
"删除" = "Delete";
-"%lld 小时" = "%lld h";
-"%lld 小时 %lld 分" = "%lld h %lld min";
"英语" = "English";
"日语" = "Japanese";
"中文" = "Chinese";
@@ -736,21 +774,21 @@
"法语" = "French";
"德语" = "German";
"葡语" = "Portuguese";
-"开始听" = "Start listening";
"正在听,说话的内容会出现在这里" = "Listening; what's said will appear here";
"这场会议没有记录到内容" = "Nothing was recorded in this meeting";
-"译文" = "Translation";
+"还没有会议" = "No meetings yet";
+"打开会议或视频,开始听后,每一场都会存在这里。" = "Open a meeting or a video and start listening: each one is kept here.";
+"先听一段示例" = "Try a sample first";
+"收起原话" = "Hide original";
+"在纪要旁显示原话" = "Show the original beside the notes";
"复制为 Markdown" = "Copy as Markdown";
"导出 Markdown…" = "Export Markdown…";
"导出 Word…" = "Export Word…";
"导出字幕 SRT…" = "Export SRT Subtitles…";
-"标题" = "Title";
+"导出…" = "Export…";
"完整版纪要" = "Full notes";
"速记版纪要" = "Draft notes";
-"原话" = "Original";
-"收起原话" = "Hide original";
-"在纪要旁显示原话" = "Show the original beside the notes";
-"此刻" = "Now";
+"标题" = "Title";
"全部 %lld 句" = "All %lld lines";
"翻译中…" = "Translating…";
"正在整理纪要…" = "Writing notes…";
@@ -770,8 +808,7 @@
"%@要让系统认出虚拟麦克风,声音会断约 1 秒。" = "%@ needs to load the virtual microphone; audio will cut out for about 1 second.";
/* VoicePicker */
-"你说%@,对方听到%@" = "You speak %@, they hear %@";
-"改语言" = "Change";
+"声音" = "Voice";
"选择对方听到的声音" = "Choose the voice they hear";
"试听" = "Preview";
"系统声音" = "System voice";
diff --git a/Resources/ja.lproj/Localizable.strings b/Resources/ja.lproj/Localizable.strings
index ecfc97b..626d762 100644
--- a/Resources/ja.lproj/Localizable.strings
+++ b/Resources/ja.lproj/Localizable.strings
@@ -39,6 +39,7 @@
"把 Mac 正在播放的声音变成实时双语字幕和会议纪要" = "Mac で再生中の音声を、リアルタイムの対訳字幕と議事録に";
"网站" = "Web サイト";
"反馈问题" = "問題を報告";
+"声纹模型:WeSpeaker ResNet34-LM(VoxCeleb),CC BY 4.0" = "声紋モデル:WeSpeaker ResNet34-LM(VoxCeleb)、CC BY 4.0";
/* AppMenu */
"关于 %@" = "%@について";
@@ -127,6 +128,7 @@
"换后备 " = "代替に切替 ";
"无" = "なし";
"Ling 请求 %d 次 · 排队最久 %.2fs · token %d/%d" = "Ling リクエスト %d回 · 最長待ち %.2fs · トークン %d/%d";
+"有人说话后,这里会显示每句话的耗时明细" = "誰かが話すと、ここに一文ごとの所要時間が表示されます";
"这场会议 · %lld 分钟 · %lld 句 · 同声传译 %lld 次" = "今回の会議 · %lld分 · %lld文 · 同時通訳 %lld回";
"开始聆听后,这里会显示每句话的耗时明细" = "聞き取りを開始すると、各文の所要時間がここに表示されます";
"说完到上屏" = "発話終了→画面表示";
@@ -138,8 +140,22 @@
"打开日志" = "ログを開く";
"打开本场数据" = "この会議のデータを開く";
"暂无数据" = "データなし";
+"一句话的路" = "一文の流れ";
+"还没有句子" = "まだ文がありません";
+"听清这句话" = "文を聞き取る";
+"译成目标语言" = "訳す";
+"你感到的延迟" = "体感の遅れ";
+"更新一次纪要" = "メモを一回更新";
+"翻译通道" = "翻訳経路";
+"Ling 用量" = "Ling の使用量";
+"账号上限约每秒 2 次" = "アカウントの上限は毎秒約2回";
"Ming 语音" = "Ming の音声";
"没译出" = "翻訳なし";
+"本场还没调用" = "まだ使っていません";
+"最近的句子" = "最近の文";
+"示例 · 对方" = "例 · 相手";
+"识别" = "認識";
+"排队" = "待ち";
"被搜索劫持" = "検索に誘導された";
"限流" = "レート制限";
"超时" = "タイムアウト";
@@ -149,12 +165,10 @@
"翻译通道分布" = "翻訳経路の内訳";
"共 %lld 句" = "計%lld文";
"Ling 请求速度" = "Ling リクエスト速度";
-"账号上限约每秒 2 次" = "アカウントの上限は毎秒約2回";
"排队最久" = "最長待ち";
"本场用量" = "この会議の使用量";
"%.1f / 2 次每秒" = "%.1f / 毎秒2回";
"%lld 次 · %lld token" = "%lld回 · %lld トークン";
-"最近的句子" = "最近の文";
"还没有" = "まだありません";
"你" = "自分";
"对方" = "相手";
@@ -207,19 +221,13 @@
"正在识别语言…" = "言語を検出中…";
"翻译暂不可用" = "現在翻訳を利用できません";
+/* ListenPill */
+"开始听" = "聞き取りを開始";
+"知了" = "Cicada";
+"会议已自动结束" = "会議は自動で終了しました";
+"结束" = "終了";
+
/* MicUsersView */
-"跟随系统的软件会自动换好;在软件里自己选过麦克风的,要在软件里改。" = "システム設定に合わせるアプリは自動で切り替わります。アプリ内でマイクを選んだ場合は、そのアプリで変更してください。";
-"这里只显示正在用麦克风的会议软件和常见会议软件,麦克风要在各软件里自己换。" = "マイクを使用中の会議アプリと主な会議アプリを表示します。マイクは各アプリで切り替えてください。";
-"会议软件的麦克风" = "会議アプリのマイク";
-"实时更新" = "リアルタイム";
-"还没有会议软件在用麦克风,进会议后这里会显示" = "マイクを使っている会議アプリはまだありません。会議に参加するとここに表示されます";
-"空闲" = "待機中";
-"怎么改" = "直し方";
-"正在用虚拟麦克风" = "仮想マイクを使用中";
-"没用虚拟麦克风,对方听不到译文" = "仮想マイクではないため、相手に訳文が届きません";
-"正在用 %@,对方听不到译文" = "%@ を使用中のため、相手に訳文が届きません";
-"没开麦克风" = "マイク未使用";
-"对方能听到" = "相手に届いています";
"顺便关掉自动调节麦克风音量和降噪,译文会更清楚" = "マイク音量の自動調整とノイズ抑制もオフにすると、訳文がよりクリアに届きます";
"进会议后,点麦克风图标旁边的 ⌃" = "会議中にマイクアイコンの横の ⌃ をクリック";
"在选择麦克风菜单里点 %@" = "マイクの選択メニューで %@ を選ぶ";
@@ -254,9 +262,9 @@
"依据较少" = "根拠が少ない";
"依据 %lld 句" = "根拠 %lld文";
"%@ · %lld 句" = "%@ · %lld文";
-"看原话" = "発言を見る";
"正在讲" = "発言中";
"新" = "新";
+"看原话" = "発言を見る";
"%@ 起" = "%@〜";
"回到原话" = "発言に戻る";
"点击分支跳回原话" = "枝をクリックすると発言に戻ります";
@@ -266,7 +274,14 @@
"说话的内容会出现在这里" = "発言内容がここに表示されます";
"%lld 句新内容" = "新着 %lld文";
"正在说" = "発話中";
-"有人说话时,会自动开始写纪要" = "誰かが話し始めると、議事メモの作成が自動で始まります";
+"从这里开始听" = "ここから聞き始め";
+"原话" = "原文";
+"译文" = "翻訳";
+"此刻" = "いま";
+"等有人开口" = "誰かが話すのを待っています";
+"有人开口后,约半分钟出第一版" = "話し始めて約30秒で最初のメモ";
+"会整理出" = "まとめる内容";
+"待办" = "ToDo";
"已听到 %lld 句" = "%lld文を聞き取りました";
"正在生成纪要" = "議事メモを作成中";
"正在更新" = "更新中";
@@ -281,7 +296,6 @@
"收窄" = "幅を狭める";
"收成小卡" = "カードに折りたたむ";
"这场会议的语言" = "この会議の言語";
-"结束" = "終了";
"正在听 · " = "聞き取り中 · ";
"正在记录 · " = "記録中 · ";
"%lld 句" = "%lld文";
@@ -445,8 +459,8 @@
/* SessionStore */
"会议 %@" = "会議 %@";
+"未识别" = "未識別";
"不到 1 分钟" = "1分未満";
-"待办" = "ToDo";
/* SettingsWindow */
"语言" = "言語";
@@ -464,7 +478,6 @@
"还差一步:允许“输入监控”" = "あと一歩: 「入力監視」を許可";
"“按住右 ⌥ 说话”需要此权限。请在系统设置中勾选 %@,返回此处即可生效" = "「右⌥を押して話す」にはこの権限が必要です。システム設定で %@ をオンにして、ここに戻ってください";
"去允许" = "許可する";
-"知了" = "Cicada";
"再试一次" = "もう一度試す";
"虚拟麦克风已就绪" = "仮想マイクの準備完了";
"%@ · 试音通过,对方听得到" = "%@ · サウンドテスト合格。相手に聞こえます";
@@ -488,36 +501,37 @@
"对方会听到:" = "相手に聞こえる音声: ";
"一段声音" = "音声";
"虚拟麦克风未收到声音,请再试一次" = "仮想マイクに音声が届きませんでした。もう一度試してください";
-"说一句话,听对方听到的声音,看每一步花了多久" = "一文話して、相手に届く声を聞き、各ステップの時間を確認";
"把我说的翻译给对方" = "自分の発言を相手に翻訳して伝える";
+"说话" = "話す";
+"按住说话" = "押して話す";
+"说%@,对方听到" = "%@で話すと、相手には";
+"按键还需要“输入监控”权限" = "キーには「入力監視」の許可が必要";
+"系统麦克风还是 %@,别的软件听不到你" = "システムのマイクがまだ %@ のため、ほかのアプリに声が届きません";
+"还原" = "戻す";
+"系统麦克风被换成了 %@" = "システムのマイクが %@ に変わりました";
+"换回" = "元に戻す";
+"系统麦克风还没换成 %@" = "システムのマイクがまだ %@ ではありません";
+"切换" = "切り替える";
+"%@还在用 %@" = "%@ はまだ %@ を使用中";
+"%@没选虚拟麦克风" = "%@ は仮想マイク未選択";
+"怎么改" = "直し方";
+"虚拟麦克风 %@" = "仮想マイク %@";
+"系统麦克风已换好,关掉时换回" = "システムのマイクを切り替え済み。オフで元に戻ります";
+"%@已选虚拟麦克风" = "%@ は仮想マイクを選択済み";
+"说一句话,听对方听到的声音,看每一步花了多久" = "一文話して、相手に届く声を聞き、各ステップの時間を確認";
+"对方听不到你" = "相手に聞こえていません";
+"对方听得到你" = "相手に聞こえます";
+"同声传译没打开" = "同時通訳はオフです";
"上次发言:松开后 %@ 秒,对方听到译文" = "前回:離して %@ 秒後に相手へ訳が届きました";
"按住说话,松开后约 1 秒,对方听到译文" = "押しながら話し、離して約 1 秒で相手に訳が届きます";
"按住说话,松开后约 3 秒,对方听到译文" = "押しながら話し、離して約 3 秒で相手に訳が届きます";
"试一句" = "試してみる";
-"按住说话" = "押して話す";
-"单独按住右侧 ⌥;和别的键一起按不触发" = "右 ⌥ だけを押し続けます。他のキーと一緒では反応しません";
-"按住快捷键说话,松开发送" = "ショートカットを押しながら話し、離すと送信";
-"声音输出到" = "音声の出力先";
-"对方只能听到虚拟麦克风里的声音" = "相手に聞こえるのは仮想マイクの音だけです";
-"虚拟麦克风(自动)" = "仮想マイク(自動)";
-"高级:声音输出到 · %@" = "詳細:音声の出力先 · %@";
-"%@ 已装好" = "%@ をインストール済み";
-"试音通过" = "サウンドテスト合格";
-"已装好" = "インストール済み";
-"系统麦克风" = "システムのマイク";
-"自动切换系统麦克风" = "システムのマイクを自動で切り替える";
-"同声传译打开时换成 %@,Chrome 等跟随系统的软件不用再设置" = "同時通訳中は %@ に切り替えます。Chrome などシステムに合わせるアプリは設定不要です";
+"打开时把系统麦克风换成 %@" = "オンの間はシステムのマイクを %@ に";
"%@听你说话用" = "%@ が聞き取るマイク";
-"固定用这个,不跟着系统切换" = "システムの切り替えに関係なくこれを使います";
-"现在:%@" = "現在:%@";
-"关掉同声传译或退出%@时,换回 %@" = "同時通訳をオフにするか %1$@ を終了すると %2$@ に戻します";
-"立即还原" = "今すぐ戻す";
-"同声传译已关,别的软件听不到你说话" = "同時通訳はオフです。ほかのアプリにあなたの声が届きません";
-"还原" = "戻す";
-"跟随系统的网页听不到译文" = "システムに合わせるページに訳が届きません";
-"换回" = "元に戻す";
-"切换" = "切り替える";
+"译文送到" = "訳文の送り先";
+"自动切换系统麦克风" = "システムのマイクを自動で切り替える";
"自动(%@)" = "自動(%@)";
+"虚拟麦克风(自动)" = "仮想マイク(自動)";
"听的时候显示" = "聞き取り中の表示";
"选择任意模式都会正常保存记录、生成纪要" = "どのモードでも、会議の記録と議事メモの作成は行われます";
"切换显示方式" = "表示方法を切り替え";
@@ -542,6 +556,10 @@
"提醒后结束" = "確認してから終了";
"直接结束" = "すぐ終了";
"一直记录" = "記録を続ける";
+"实验功能" = "試験運用の機能";
+"还在打磨,可能出错;随时能关,关掉不影响别的功能。" = "調整中のため間違えることがあります。いつでもオフにでき、ほかの機能には影響しません。";
+"按声音标出说话人 1、2…,只在这台 Mac 上处理" = "声で話者 1、2… を表示します。処理はこの Mac の中だけです";
+"说话人识别" = "話者識別";
/* Shortcuts */
"右 ⌥" = "右⌥";
@@ -589,7 +607,6 @@
"松开就发送" = "離すと送信";
"你的话" = "あなたの声";
"识别 + 翻译" = "認識 + 翻訳";
-"识别" = "認識";
"合成声音" = "音声合成";
"示例句子" = "例文";
"麦克风峰值 %lld dB" = "マイクのピーク %lld dB";
@@ -639,6 +656,24 @@
"再试一句" = "もう一度";
"复制报告" = "レポートをコピー";
+/* SpeakerID */
+"说话人 %lld" = "話者 %lld";
+"没认出是谁:太短,或和已知的声音都不像" = "誰か判別できません:短すぎるか、既知の声と似ていません";
+"实验" = "試験";
+"关掉说话人识别,记录里的名字一起收起" = "話者識別をオフにします(記録の名前も隠れます)";
+"Ling 从对话里认出,点一下可以改" = "Ling が会話から見つけた名前です。クリックで変更";
+"改名字,或和别人合并" = "名前を付ける、またはほかの人とまとめる";
+"不准?关掉" = "不正確?オフにする";
+"说了 %lld 句" = "%lld 回発言";
+"名字" = "名前";
+"Ling 正在从对话里找名字…" = "Ling が会話から名前を探しています…";
+"输入名字" = "名前を入力";
+"Ling 从对话里认出" = "Ling が会話から見つけました";
+"Ling 从对话里认出:%@" = "Ling が会話から見つけました:%@";
+"不是 TA" = "この人ではない";
+"其实是同一个人" = "実は同じ人";
+"并入 %@" = "%@ にまとめる";
+
/* SystemAudioTap */
"无法启动音频采集(%d)" = "音声キャプチャを開始できません(%d)";
"无法初始化音频单元(%d)" = "オーディオユニットを初期化できません(%d)";
@@ -685,20 +720,12 @@
/* Views */
"自动识别(%@)" = "自動検出(%@)";
"%@(需下载)" = "%@(要ダウンロード)";
-"按住" = "押す";
-"说%@ → %@" = "%1$@ → %2$@";
-"会议已自动结束" = "会議は自動で終了しました";
"系统" = "システム";
"内容" = "内容";
"仅本场" = "この会議のみ";
-"%@已选虚拟麦克风" = "%@ は仮想マイクを選択済み";
-"系统麦克风已换成 %@" = "システムのマイクは %@ です";
-"同声传译选项" = "同時通訳のオプション";
"系统麦克风还是 %@" = "システムのマイクがまだ %@ です";
"别的软件现在听不到你说话" = "ほかのアプリにあなたの声が届きません";
-"系统麦克风被换成了 %@" = "システムのマイクが %@ に変わりました";
-"%@没选虚拟麦克风,对方听不到译文" = "%@ が仮想マイクを選んでいないため、相手に訳文が届きません";
-"虚拟麦克风尚未设置好,对方听不到你的声音" = "仮想マイクが未設定のため、相手にあなたの声は届きません";
+"跟随系统的网页听不到译文" = "システムに合わせるページに訳が届きません";
"显示方式" = "表示方法";
"轮换" = "で切り替え";
"屏幕上不出字幕,文字记录照常保存" = "画面には何も出しません。文字起こしは保存されます";
@@ -707,26 +734,37 @@
"纪要窗口已打开" = "議事メモのウィンドウを表示中";
"纪要窗口已收起" = "議事メモのウィンドウは非表示";
"对方现在能看到纪要窗口" = "相手にも議事メモのウィンドウが見えています";
-"同声传译设置…" = "同時通訳の設定…";
-"系统麦克风换成 %@" = "システムのマイクを %@ にする";
-"还原系统麦克风" = "システムのマイクを戻す";
+"系统麦克风换成 %@" = "システムのマイクを %@ に切り替え";
+"译文送进 %@" = "訳文を %@ に送ります";
+"先装好虚拟麦克风,对方才听得到" = "相手に聞こえるよう、先に仮想マイクを入れます";
+"打开:%@,按住 %@ 说话\n关掉:全部还原" = "オン:%@、%@ を押しながら話す\nオフ:すべて元に戻る";
+"先试一句 →" = "まず一文試す →";
+"说%@ → %@" = "%1$@ → %2$@";
+"按住说%@" = "押しながら%@で話す";
+"正在翻译…" = "翻訳中…";
+"正在播出…" = "再生中…";
+"松开后播出%@" = "離すと%@で再生";
+"打开后:" = "オンにすると:";
+"按住" = "押す";
+"说话,松开后播出译文" = "で話し、離すと訳文を再生";
+"关掉后全部还原" = "オフにするとすべて元に戻る";
+"好,打开" = "オンにする";
+"虚拟麦克风还没装好" = "仮想マイクがまだ入っていません";
+"对方听到 %@ · %@" = "相手には%@ · %@";
+"对方听到 %@" = "相手には%@で届きます";
"搜索" = "検索";
-"导出…" = "書き出す…";
-"收起更早的会议" = "以前の会議を隠す";
-"更早的会议" = "以前の会議";
-"还没有会议" = "まだ会議はありません";
-"打开会议或视频,开始听后,每一场都会存在这里。" = "会議や動画を開いて聞き取りを始めると、毎回ここに保存されます。";
-"先听一段示例" = "まずサンプルを聞く";
"没有找到“%@”" = "「%@」は見つかりません";
"今天" = "今日";
"昨天" = "昨日";
"本周" = "今週";
+"收起更早的会议" = "以前の会議を隠す";
+"更早的会议" = "以前の会議";
"未命名会议" = "無題の会議";
+"%lld 小时" = "%lld時間";
+"%lld 小时 %lld 分" = "%lld時間%lld分";
"在 Finder 中显示" = "Finder で表示";
"恢复自动标题" = "自動タイトルに戻す";
"删除" = "削除";
-"%lld 小时" = "%lld時間";
-"%lld 小时 %lld 分" = "%lld時間%lld分";
"英语" = "英語";
"日语" = "日本語";
"中文" = "中国語";
@@ -736,21 +774,21 @@
"法语" = "フランス語";
"德语" = "ドイツ語";
"葡语" = "ポルトガル語";
-"开始听" = "聞き取りを開始";
"正在听,说话的内容会出现在这里" = "聞き取り中。発言内容がここに表示されます";
"这场会议没有记录到内容" = "この会議では何も記録されませんでした";
-"译文" = "翻訳";
+"还没有会议" = "まだ会議はありません";
+"打开会议或视频,开始听后,每一场都会存在这里。" = "会議や動画を開いて聞き取りを始めると、毎回ここに保存されます。";
+"先听一段示例" = "まずサンプルを聞く";
+"收起原话" = "原文を隠す";
+"在纪要旁显示原话" = "議事録の横に原文を表示";
"复制为 Markdown" = "Markdown としてコピー";
"导出 Markdown…" = "Markdown を書き出す…";
"导出 Word…" = "Word を書き出す…";
"导出字幕 SRT…" = "SRT 字幕を書き出す…";
-"标题" = "タイトル";
+"导出…" = "書き出す…";
"完整版纪要" = "完全版の議事メモ";
"速记版纪要" = "速記版の議事メモ";
-"原话" = "原文";
-"收起原话" = "原文を隠す";
-"在纪要旁显示原话" = "議事録の横に原文を表示";
-"此刻" = "いま";
+"标题" = "タイトル";
"全部 %lld 句" = "全%lld文";
"翻译中…" = "翻訳中…";
"正在整理纪要…" = "議事メモを作成中…";
@@ -770,8 +808,7 @@
"%@要让系统认出虚拟麦克风,声音会断约 1 秒。" = "%@が仮想マイクをシステムに認識させるため、音声が約1秒途切れます。";
/* VoicePicker */
-"你说%@,对方听到%@" = "あなたは%@、相手には%@";
-"改语言" = "言語を変更";
+"声音" = "声";
"选择对方听到的声音" = "相手に聞こえる声を選ぶ";
"试听" = "試聴";
"系统声音" = "システムの声";
diff --git a/Resources/ko.lproj/Localizable.strings b/Resources/ko.lproj/Localizable.strings
index cc6db03..021d829 100644
--- a/Resources/ko.lproj/Localizable.strings
+++ b/Resources/ko.lproj/Localizable.strings
@@ -39,6 +39,7 @@
"把 Mac 正在播放的声音变成实时双语字幕和会议纪要" = "Mac에서 재생 중인 소리를 실시간 이중 언어 자막과 회의록으로";
"网站" = "웹사이트";
"反馈问题" = "문제 신고";
+"声纹模型:WeSpeaker ResNet34-LM(VoxCeleb),CC BY 4.0" = "성문 모델: WeSpeaker ResNet34-LM(VoxCeleb), CC BY 4.0";
/* AppMenu */
"关于 %@" = "%@에 관하여";
@@ -127,6 +128,7 @@
"换后备 " = "대체 전환 ";
"无" = "없음";
"Ling 请求 %d 次 · 排队最久 %.2fs · token %d/%d" = "Ling 요청 %d회 · 최장 대기 %.2fs · token %d/%d";
+"有人说话后,这里会显示每句话的耗时明细" = "누군가 말하면 문장별 소요 시간이 여기에 표시돼요";
"这场会议 · %lld 分钟 · %lld 句 · 同声传译 %lld 次" = "이번 회의 · %lld분 · %lld문장 · 동시통역 %lld회";
"开始聆听后,这里会显示每句话的耗时明细" = "듣기를 시작하면 문장별 소요 시간이 여기에 표시됩니다";
"说完到上屏" = "발화 종료 → 화면 표시";
@@ -138,8 +140,22 @@
"打开日志" = "로그 열기";
"打开本场数据" = "이번 회의 데이터 열기";
"暂无数据" = "데이터 없음";
+"一句话的路" = "한 문장의 흐름";
+"还没有句子" = "아직 문장이 없어요";
+"听清这句话" = "문장 알아듣기";
+"译成目标语言" = "번역하기";
+"你感到的延迟" = "체감 지연";
+"更新一次纪要" = "메모 한 번 갱신";
+"翻译通道" = "번역 경로";
+"Ling 用量" = "Ling 사용량";
+"账号上限约每秒 2 次" = "계정 한도는 초당 약 2회";
"Ming 语音" = "Ming 음성";
"没译出" = "번역 안 됨";
+"本场还没调用" = "아직 사용 안 함";
+"最近的句子" = "최근 문장";
+"示例 · 对方" = "예시 · 상대";
+"识别" = "인식";
+"排队" = "대기";
"被搜索劫持" = "검색 응답으로 변질";
"限流" = "요청 제한";
"超时" = "시간 초과";
@@ -149,12 +165,10 @@
"翻译通道分布" = "번역 경로 분포";
"共 %lld 句" = "총 %lld문장";
"Ling 请求速度" = "Ling 요청 속도";
-"账号上限约每秒 2 次" = "계정 한도는 초당 약 2회";
"排队最久" = "최장 대기";
"本场用量" = "이번 회의 사용량";
"%.1f / 2 次每秒" = "%.1f / 초당 2회";
"%lld 次 · %lld token" = "%lld회 · %lld token";
-"最近的句子" = "최근 문장";
"还没有" = "아직 없음";
"你" = "나";
"对方" = "상대";
@@ -207,19 +221,13 @@
"正在识别语言…" = "언어 감지 중…";
"翻译暂不可用" = "번역을 일시적으로 사용할 수 없음";
+/* ListenPill */
+"开始听" = "듣기 시작";
+"知了" = "Cicada";
+"会议已自动结束" = "회의가 자동으로 종료됨";
+"结束" = "종료";
+
/* MicUsersView */
-"跟随系统的软件会自动换好;在软件里自己选过麦克风的,要在软件里改。" = "시스템 기본값을 쓰는 앱은 자동으로 바뀌어요. 앱에서 마이크를 직접 고른 경우엔 그 앱에서 바꿔 주세요.";
-"这里只显示正在用麦克风的会议软件和常见会议软件,麦克风要在各软件里自己换。" = "마이크를 쓰는 회의 앱과 주요 회의 앱만 표시해요. 마이크는 각 앱에서 바꿔 주세요.";
-"会议软件的麦克风" = "회의 앱 마이크";
-"实时更新" = "실시간";
-"还没有会议软件在用麦克风,进会议后这里会显示" = "아직 마이크를 쓰는 회의 앱이 없어요. 회의에 들어가면 여기에 표시돼요";
-"空闲" = "대기 중";
-"怎么改" = "바꾸는 법";
-"正在用虚拟麦克风" = "가상 마이크 사용 중";
-"没用虚拟麦克风,对方听不到译文" = "가상 마이크가 아니라 상대가 번역을 못 들어요";
-"正在用 %@,对方听不到译文" = "%@ 사용 중이라 상대가 번역을 못 들어요";
-"没开麦克风" = "마이크 안 씀";
-"对方能听到" = "상대가 들어요";
"顺便关掉自动调节麦克风音量和降噪,译文会更清楚" = "마이크 음량 자동 조절과 소음 억제도 끄면 번역이 더 또렷하게 들려요";
"进会议后,点麦克风图标旁边的 ⌃" = "회의 중 마이크 아이콘 옆의 ⌃ 를 클릭";
"在选择麦克风菜单里点 %@" = "마이크 선택 메뉴에서 %@ 선택";
@@ -254,9 +262,9 @@
"依据较少" = "근거 적음";
"依据 %lld 句" = "근거 %lld문장";
"%@ · %lld 句" = "%@ · %lld문장";
-"看原话" = "원문 보기";
"正在讲" = "진행 중";
"新" = "신규";
+"看原话" = "원문 보기";
"%@ 起" = "%@부터";
"回到原话" = "원문으로 이동";
"点击分支跳回原话" = "가지를 클릭하면 원문으로 이동합니다";
@@ -266,7 +274,14 @@
"说话的内容会出现在这里" = "말한 내용이 여기에 표시됩니다";
"%lld 句新内容" = "새 내용 %lld문장";
"正在说" = "말하는 중";
-"有人说话时,会自动开始写纪要" = "누군가 말하면 자동으로 회의록 작성을 시작합니다";
+"从这里开始听" = "여기서부터 듣기 시작";
+"原话" = "원문";
+"译文" = "번역문";
+"此刻" = "지금";
+"等有人开口" = "누군가 말하길 기다리는 중";
+"有人开口后,约半分钟出第一版" = "말을 시작하면 약 30초 뒤 첫 메모";
+"会整理出" = "정리되는 것";
+"待办" = "할 일";
"已听到 %lld 句" = "%lld문장 들음";
"正在生成纪要" = "회의록 작성 중";
"正在更新" = "업데이트 중";
@@ -281,7 +296,6 @@
"收窄" = "좁게";
"收成小卡" = "카드로 접기";
"这场会议的语言" = "이 회의의 언어";
-"结束" = "종료";
"正在听 · " = "듣는 중 · ";
"正在记录 · " = "기록 중 · ";
"%lld 句" = "%lld문장";
@@ -445,8 +459,8 @@
/* SessionStore */
"会议 %@" = "회의 %@";
+"未识别" = "미식별";
"不到 1 分钟" = "1분 미만";
-"待办" = "할 일";
/* SettingsWindow */
"语言" = "언어";
@@ -464,7 +478,6 @@
"还差一步:允许“输入监控”" = "한 단계 남음: “입력 모니터링” 허용";
"“按住右 ⌥ 说话”需要此权限。请在系统设置中勾选 %@,返回此处即可生效" = "“오른쪽 ⌥를 누르고 말하기”에 이 권한이 필요합니다. 시스템 설정에서 %@을(를) 켠 뒤 돌아오세요";
"去允许" = "허용하기";
-"知了" = "Cicada";
"再试一次" = "다시 시도";
"虚拟麦克风已就绪" = "가상 마이크 준비 완료";
"%@ · 试音通过,对方听得到" = "%@ · 테스트 통과, 상대가 들을 수 있습니다";
@@ -488,36 +501,37 @@
"对方会听到:" = "상대가 듣게 될 소리: ";
"一段声音" = "소리";
"虚拟麦克风未收到声音,请再试一次" = "가상 마이크에 소리가 들어오지 않았습니다. 다시 시도하세요";
-"说一句话,听对方听到的声音,看每一步花了多久" = "한 문장 말하고, 상대가 듣는 소리와 단계별 시간을 확인";
"把我说的翻译给对方" = "내 말을 상대에게 번역";
+"说话" = "말하기";
+"按住说话" = "누르고 말하기";
+"说%@,对方听到" = "%@로 말하면 상대에게";
+"按键还需要“输入监控”权限" = "키에 ‘입력 모니터링’ 권한이 필요";
+"系统麦克风还是 %@,别的软件听不到你" = "시스템 마이크가 아직 %@(이)라 다른 앱이 듣지 못합니다";
+"还原" = "되돌리기";
+"系统麦克风被换成了 %@" = "시스템 마이크가 %@(으)로 바뀌었어요";
+"换回" = "다시 바꾸기";
+"系统麦克风还没换成 %@" = "시스템 마이크가 아직 %@이(가) 아닙니다";
+"切换" = "전환";
+"%@还在用 %@" = "%@이(가) 아직 %@ 사용 중";
+"%@没选虚拟麦克风" = "%@에서 가상 마이크 미선택";
+"怎么改" = "바꾸는 법";
+"虚拟麦克风 %@" = "가상 마이크 %@";
+"系统麦克风已换好,关掉时换回" = "시스템 마이크 전환됨, 끄면 원래대로";
+"%@已选虚拟麦克风" = "%@에서 가상 마이크 선택됨";
+"说一句话,听对方听到的声音,看每一步花了多久" = "한 문장 말하고, 상대가 듣는 소리와 단계별 시간을 확인";
+"对方听不到你" = "상대가 듣지 못합니다";
+"对方听得到你" = "상대가 들을 수 있습니다";
+"同声传译没打开" = "동시통역이 꺼져 있습니다";
"上次发言:松开后 %@ 秒,对方听到译文" = "지난번: 키를 떼고 %@초 후 상대가 번역을 들었습니다";
"按住说话,松开后约 1 秒,对方听到译文" = "누른 채 말하고, 떼면 약 1초 후 상대가 번역을 듣습니다";
"按住说话,松开后约 3 秒,对方听到译文" = "누른 채 말하고, 떼면 약 3초 후 상대가 번역을 듣습니다";
"试一句" = "테스트";
-"按住说话" = "누르고 말하기";
-"单独按住右侧 ⌥;和别的键一起按不触发" = "오른쪽 ⌥만 누르세요. 다른 키와 함께 누르면 작동하지 않습니다";
-"按住快捷键说话,松开发送" = "단축키를 누른 채 말하고, 떼면 전송";
-"声音输出到" = "음성 출력 대상";
-"对方只能听到虚拟麦克风里的声音" = "상대는 가상 마이크로 들어간 소리만 듣습니다";
-"虚拟麦克风(自动)" = "가상 마이크(자동)";
-"高级:声音输出到 · %@" = "고급: 음성 출력 · %@";
-"%@ 已装好" = "%@ 설치됨";
-"试音通过" = "사운드 테스트 통과";
-"已装好" = "설치됨";
-"系统麦克风" = "시스템 마이크";
-"自动切换系统麦克风" = "시스템 마이크 자동 전환";
-"同声传译打开时换成 %@,Chrome 等跟随系统的软件不用再设置" = "동시통역 중엔 %@(으)로 바꿔요. Chrome 등 시스템 기본값을 쓰는 앱은 따로 설정할 필요가 없어요";
+"打开时把系统麦克风换成 %@" = "켜는 동안 시스템 마이크를 %@(으)로";
"%@听你说话用" = "%@이(가) 듣는 마이크";
-"固定用这个,不跟着系统切换" = "시스템 설정과 관계없이 이걸 써요";
-"现在:%@" = "현재: %@";
-"关掉同声传译或退出%@时,换回 %@" = "동시통역을 끄거나 %1$@을(를) 종료하면 %2$@(으)로 돌아가요";
-"立即还原" = "지금 되돌리기";
-"同声传译已关,别的软件听不到你说话" = "동시통역이 꺼져 있어요. 다른 앱에 내 목소리가 들리지 않아요";
-"还原" = "되돌리기";
-"跟随系统的网页听不到译文" = "기본 마이크를 쓰는 페이지엔 번역이 안 들려요";
-"换回" = "다시 바꾸기";
-"切换" = "전환";
+"译文送到" = "번역 보낼 곳";
+"自动切换系统麦克风" = "시스템 마이크 자동 전환";
"自动(%@)" = "자동(%@)";
+"虚拟麦克风(自动)" = "가상 마이크(자동)";
"听的时候显示" = "듣는 동안 표시";
"选择任意模式都会正常保存记录、生成纪要" = "어떤 모드든 회의 기록 저장과 회의록 작성은 그대로 진행됩니다";
"切换显示方式" = "표시 방식 전환";
@@ -542,6 +556,10 @@
"提醒后结束" = "알린 뒤 종료";
"直接结束" = "바로 종료";
"一直记录" = "계속 기록";
+"实验功能" = "실험 기능";
+"还在打磨,可能出错;随时能关,关掉不影响别的功能。" = "아직 다듬는 중이라 틀릴 수 있어요. 언제든 끌 수 있고, 다른 기능에는 영향이 없어요.";
+"按声音标出说话人 1、2…,只在这台 Mac 上处理" = "목소리로 화자 1, 2…를 표시해요. 이 Mac에서만 처리해요";
+"说话人识别" = "화자 인식";
/* Shortcuts */
"右 ⌥" = "오른쪽 ⌥";
@@ -589,7 +607,6 @@
"松开就发送" = "떼면 전송";
"你的话" = "내 말";
"识别 + 翻译" = "인식 + 번역";
-"识别" = "인식";
"合成声音" = "음성 합성";
"示例句子" = "예문";
"麦克风峰值 %lld dB" = "마이크 최대 %lld dB";
@@ -639,6 +656,24 @@
"再试一句" = "다시 테스트";
"复制报告" = "보고서 복사";
+/* SpeakerID */
+"说话人 %lld" = "화자 %lld";
+"没认出是谁:太短,或和已知的声音都不像" = "누군지 알 수 없어요: 너무 짧거나 알려진 목소리와 달라요";
+"实验" = "실험";
+"关掉说话人识别,记录里的名字一起收起" = "화자 인식을 꺼요(기록의 이름도 숨겨져요)";
+"Ling 从对话里认出,点一下可以改" = "Ling이 대화에서 찾은 이름이에요. 클릭해서 바꿀 수 있어요";
+"改名字,或和别人合并" = "이름을 바꾸거나 다른 사람과 합치기";
+"不准?关掉" = "틀렸나요? 끄기";
+"说了 %lld 句" = "%lld번 발언";
+"名字" = "이름";
+"Ling 正在从对话里找名字…" = "Ling이 대화에서 이름을 찾는 중…";
+"输入名字" = "이름 입력";
+"Ling 从对话里认出" = "Ling이 대화에서 찾았어요";
+"Ling 从对话里认出:%@" = "Ling이 대화에서 찾았어요: %@";
+"不是 TA" = "이 사람 아님";
+"其实是同一个人" = "사실 같은 사람";
+"并入 %@" = "%@에 합치기";
+
/* SystemAudioTap */
"无法启动音频采集(%d)" = "오디오 캡처를 시작할 수 없습니다(%d)";
"无法初始化音频单元(%d)" = "오디오 유닛을 초기화할 수 없습니다(%d)";
@@ -685,20 +720,12 @@
/* Views */
"自动识别(%@)" = "자동 감지(%@)";
"%@(需下载)" = "%@(다운로드 필요)";
-"按住" = "누르기";
-"说%@ → %@" = "%1$@ → %2$@";
-"会议已自动结束" = "회의가 자동으로 종료됨";
"系统" = "시스템";
"内容" = "내용";
"仅本场" = "이번 회의만";
-"%@已选虚拟麦克风" = "%@ 가상 마이크 선택됨";
-"系统麦克风已换成 %@" = "시스템 마이크: %@";
-"同声传译选项" = "동시통역 옵션";
"系统麦克风还是 %@" = "시스템 마이크가 아직 %@예요";
"别的软件现在听不到你说话" = "다른 앱에 내 목소리가 들리지 않아요";
-"系统麦克风被换成了 %@" = "시스템 마이크가 %@(으)로 바뀌었어요";
-"%@没选虚拟麦克风,对方听不到译文" = "%@에서 가상 마이크를 안 골라 상대가 번역을 못 들어요";
-"虚拟麦克风尚未设置好,对方听不到你的声音" = "가상 마이크가 설정되지 않아 상대가 내 목소리를 들을 수 없습니다";
+"跟随系统的网页听不到译文" = "기본 마이크를 쓰는 페이지엔 번역이 안 들려요";
"显示方式" = "표시 방식";
"轮换" = "로 전환";
"屏幕上不出字幕,文字记录照常保存" = "화면에는 표시하지 않고, 대화 기록은 그대로 저장됩니다";
@@ -707,26 +734,37 @@
"纪要窗口已打开" = "회의록 창이 열려 있음";
"纪要窗口已收起" = "회의록 창이 숨겨져 있음";
"对方现在能看到纪要窗口" = "지금 상대도 회의록 창을 볼 수 있습니다";
-"同声传译设置…" = "동시통역 설정…";
-"系统麦克风换成 %@" = "시스템 마이크를 %@(으)로";
-"还原系统麦克风" = "시스템 마이크 되돌리기";
+"系统麦克风换成 %@" = "시스템 마이크를 %@(으)로 전환";
+"译文送进 %@" = "번역을 %@(으)로 보냅니다";
+"先装好虚拟麦克风,对方才听得到" = "상대가 들으려면 먼저 가상 마이크를 설치하세요";
+"打开:%@,按住 %@ 说话\n关掉:全部还原" = "켜기: %@, %@ 누른 채 말하기\n끄기: 모두 원래대로";
+"先试一句 →" = "먼저 한 문장 해보기 →";
+"说%@ → %@" = "%1$@ → %2$@";
+"按住说%@" = "누른 채 %@로 말하기";
+"正在翻译…" = "번역 중…";
+"正在播出…" = "재생 중…";
+"松开后播出%@" = "떼면 %@로 재생";
+"打开后:" = "켜면:";
+"按住" = "누르기";
+"说话,松开后播出译文" = "말하고, 떼면 번역 재생";
+"关掉后全部还原" = "끄면 모두 원래대로";
+"好,打开" = "켜기";
+"虚拟麦克风还没装好" = "가상 마이크가 아직 없습니다";
+"对方听到 %@ · %@" = "상대에게 %@ · %@";
+"对方听到 %@" = "상대에게 %@로 들립니다";
"搜索" = "검색";
-"导出…" = "내보내기…";
-"收起更早的会议" = "이전 회의 숨기기";
-"更早的会议" = "이전 회의";
-"还没有会议" = "아직 회의가 없습니다";
-"打开会议或视频,开始听后,每一场都会存在这里。" = "회의나 동영상을 열고 듣기를 시작하면 모두 여기에 저장됩니다.";
-"先听一段示例" = "먼저 샘플 듣기";
"没有找到“%@”" = "“%@” 검색 결과 없음";
"今天" = "오늘";
"昨天" = "어제";
"本周" = "이번 주";
+"收起更早的会议" = "이전 회의 숨기기";
+"更早的会议" = "이전 회의";
"未命名会议" = "제목 없는 회의";
+"%lld 小时" = "%lld시간";
+"%lld 小时 %lld 分" = "%lld시간 %lld분";
"在 Finder 中显示" = "Finder에서 보기";
"恢复自动标题" = "자동 제목으로 복원";
"删除" = "삭제";
-"%lld 小时" = "%lld시간";
-"%lld 小时 %lld 分" = "%lld시간 %lld분";
"英语" = "영어";
"日语" = "일본어";
"中文" = "중국어";
@@ -736,21 +774,21 @@
"法语" = "프랑스어";
"德语" = "독일어";
"葡语" = "포르투갈어";
-"开始听" = "듣기 시작";
"正在听,说话的内容会出现在这里" = "듣는 중입니다. 말한 내용이 여기에 표시됩니다";
"这场会议没有记录到内容" = "이 회의에는 기록된 내용이 없습니다";
-"译文" = "번역문";
+"还没有会议" = "아직 회의가 없습니다";
+"打开会议或视频,开始听后,每一场都会存在这里。" = "회의나 동영상을 열고 듣기를 시작하면 모두 여기에 저장됩니다.";
+"先听一段示例" = "먼저 샘플 듣기";
+"收起原话" = "원문 숨기기";
+"在纪要旁显示原话" = "회의록 옆에 원문 표시";
"复制为 Markdown" = "Markdown으로 복사하기";
"导出 Markdown…" = "Markdown 내보내기…";
"导出 Word…" = "Word 내보내기…";
"导出字幕 SRT…" = "SRT 자막 내보내기…";
-"标题" = "제목";
+"导出…" = "내보내기…";
"完整版纪要" = "전체본 회의록";
"速记版纪要" = "속기본 회의록";
-"原话" = "원문";
-"收起原话" = "원문 숨기기";
-"在纪要旁显示原话" = "회의록 옆에 원문 표시";
-"此刻" = "지금";
+"标题" = "제목";
"全部 %lld 句" = "전체 %lld문장";
"翻译中…" = "번역 중…";
"正在整理纪要…" = "회의록 작성 중…";
@@ -770,8 +808,7 @@
"%@要让系统认出虚拟麦克风,声音会断约 1 秒。" = "%@이(가) 시스템에 가상 마이크를 인식시키는 동안 소리가 약 1초간 끊깁니다.";
/* VoicePicker */
-"你说%@,对方听到%@" = "나는 %@, 상대는 %@";
-"改语言" = "언어 변경";
+"声音" = "목소리";
"选择对方听到的声音" = "상대가 들을 목소리 선택";
"试听" = "미리 듣기";
"系统声音" = "시스템 음성";
diff --git a/Resources/models/SpeakerEmbedding.mlpackage/Data/com.apple.CoreML/model.mlmodel b/Resources/models/SpeakerEmbedding.mlpackage/Data/com.apple.CoreML/model.mlmodel
new file mode 100644
index 0000000..bf16575
Binary files /dev/null and b/Resources/models/SpeakerEmbedding.mlpackage/Data/com.apple.CoreML/model.mlmodel differ
diff --git a/Resources/models/SpeakerEmbedding.mlpackage/Data/com.apple.CoreML/weights/weight.bin b/Resources/models/SpeakerEmbedding.mlpackage/Data/com.apple.CoreML/weights/weight.bin
new file mode 100644
index 0000000..99f62c3
Binary files /dev/null and b/Resources/models/SpeakerEmbedding.mlpackage/Data/com.apple.CoreML/weights/weight.bin differ
diff --git a/Resources/models/SpeakerEmbedding.mlpackage/Manifest.json b/Resources/models/SpeakerEmbedding.mlpackage/Manifest.json
new file mode 100644
index 0000000..8858e82
--- /dev/null
+++ b/Resources/models/SpeakerEmbedding.mlpackage/Manifest.json
@@ -0,0 +1,18 @@
+{
+ "fileFormatVersion": "1.0.0",
+ "itemInfoEntries": {
+ "3983D97B-88EA-4616-8CEE-E5B1972A14F2": {
+ "author": "com.apple.CoreML",
+ "description": "CoreML Model Specification",
+ "name": "model.mlmodel",
+ "path": "com.apple.CoreML/model.mlmodel"
+ },
+ "716A6228-00D2-4100-979A-48F59EC1FED1": {
+ "author": "com.apple.CoreML",
+ "description": "CoreML Model Weights",
+ "name": "weights",
+ "path": "com.apple.CoreML/weights"
+ }
+ },
+ "rootModelIdentifier": "3983D97B-88EA-4616-8CEE-E5B1972A14F2"
+}
diff --git a/Resources/zh-Hans.lproj/Localizable.strings b/Resources/zh-Hans.lproj/Localizable.strings
index 7e4902a..e924284 100644
--- a/Resources/zh-Hans.lproj/Localizable.strings
+++ b/Resources/zh-Hans.lproj/Localizable.strings
@@ -39,6 +39,7 @@
"把 Mac 正在播放的声音变成实时双语字幕和会议纪要" = "把 Mac 正在播放的声音变成实时双语字幕和会议纪要";
"网站" = "网站";
"反馈问题" = "反馈问题";
+"声纹模型:WeSpeaker ResNet34-LM(VoxCeleb),CC BY 4.0" = "声纹模型:WeSpeaker ResNet34-LM(VoxCeleb),CC BY 4.0";
/* AppMenu */
"关于 %@" = "关于 %@";
@@ -127,6 +128,7 @@
"换后备 " = "换后备 ";
"无" = "无";
"Ling 请求 %d 次 · 排队最久 %.2fs · token %d/%d" = "Ling 请求 %d 次 · 排队最久 %.2fs · token %d/%d";
+"有人说话后,这里会显示每句话的耗时明细" = "有人说话后,这里会显示每句话的耗时明细";
"这场会议 · %lld 分钟 · %lld 句 · 同声传译 %lld 次" = "这场会议 · %lld 分钟 · %lld 句 · 同声传译 %lld 次";
"开始聆听后,这里会显示每句话的耗时明细" = "开始聆听后,这里会显示每句话的耗时明细";
"说完到上屏" = "说完到上屏";
@@ -138,8 +140,22 @@
"打开日志" = "打开日志";
"打开本场数据" = "打开本场数据";
"暂无数据" = "暂无数据";
+"一句话的路" = "一句话的路";
+"还没有句子" = "还没有句子";
+"听清这句话" = "听清这句话";
+"译成目标语言" = "译成目标语言";
+"你感到的延迟" = "你感到的延迟";
+"更新一次纪要" = "更新一次纪要";
+"翻译通道" = "翻译通道";
+"Ling 用量" = "Ling 用量";
+"账号上限约每秒 2 次" = "账号上限约每秒 2 次";
"Ming 语音" = "Ming 语音";
"没译出" = "没译出";
+"本场还没调用" = "本场还没调用";
+"最近的句子" = "最近的句子";
+"示例 · 对方" = "示例 · 对方";
+"识别" = "识别";
+"排队" = "排队";
"被搜索劫持" = "被搜索劫持";
"限流" = "限流";
"超时" = "超时";
@@ -149,12 +165,10 @@
"翻译通道分布" = "翻译通道分布";
"共 %lld 句" = "共 %lld 句";
"Ling 请求速度" = "Ling 请求速度";
-"账号上限约每秒 2 次" = "账号上限约每秒 2 次";
"排队最久" = "排队最久";
"本场用量" = "本场用量";
"%.1f / 2 次每秒" = "%.1f / 2 次每秒";
"%lld 次 · %lld token" = "%lld 次 · %lld token";
-"最近的句子" = "最近的句子";
"还没有" = "还没有";
"你" = "你";
"对方" = "对方";
@@ -207,19 +221,13 @@
"正在识别语言…" = "正在识别语言…";
"翻译暂不可用" = "翻译暂不可用";
+/* ListenPill */
+"开始听" = "开始听";
+"知了" = "知了";
+"会议已自动结束" = "会议已自动结束";
+"结束" = "结束";
+
/* MicUsersView */
-"跟随系统的软件会自动换好;在软件里自己选过麦克风的,要在软件里改。" = "跟随系统的软件会自动换好;在软件里自己选过麦克风的,要在软件里改。";
-"这里只显示正在用麦克风的会议软件和常见会议软件,麦克风要在各软件里自己换。" = "这里只显示正在用麦克风的会议软件和常见会议软件,麦克风要在各软件里自己换。";
-"会议软件的麦克风" = "会议软件的麦克风";
-"实时更新" = "实时更新";
-"还没有会议软件在用麦克风,进会议后这里会显示" = "还没有会议软件在用麦克风,进会议后这里会显示";
-"空闲" = "空闲";
-"怎么改" = "怎么改";
-"正在用虚拟麦克风" = "正在用虚拟麦克风";
-"没用虚拟麦克风,对方听不到译文" = "没用虚拟麦克风,对方听不到译文";
-"正在用 %@,对方听不到译文" = "正在用 %@,对方听不到译文";
-"没开麦克风" = "没开麦克风";
-"对方能听到" = "对方能听到";
"顺便关掉自动调节麦克风音量和降噪,译文会更清楚" = "顺便关掉自动调节麦克风音量和降噪,译文会更清楚";
"进会议后,点麦克风图标旁边的 ⌃" = "进会议后,点麦克风图标旁边的 ⌃";
"在选择麦克风菜单里点 %@" = "在选择麦克风菜单里点 %@";
@@ -254,9 +262,9 @@
"依据较少" = "依据较少";
"依据 %lld 句" = "依据 %lld 句";
"%@ · %lld 句" = "%@ · %lld 句";
-"看原话" = "看原话";
"正在讲" = "正在讲";
"新" = "新";
+"看原话" = "看原话";
"%@ 起" = "%@ 起";
"回到原话" = "回到原话";
"点击分支跳回原话" = "点击分支跳回原话";
@@ -266,7 +274,14 @@
"说话的内容会出现在这里" = "说话的内容会出现在这里";
"%lld 句新内容" = "%lld 句新内容";
"正在说" = "正在说";
-"有人说话时,会自动开始写纪要" = "有人说话时,会自动开始写纪要";
+"从这里开始听" = "从这里开始听";
+"原话" = "原话";
+"译文" = "译文";
+"此刻" = "此刻";
+"等有人开口" = "等有人开口";
+"有人开口后,约半分钟出第一版" = "有人开口后,约半分钟出第一版";
+"会整理出" = "会整理出";
+"待办" = "待办";
"已听到 %lld 句" = "已听到 %lld 句";
"正在生成纪要" = "正在生成纪要";
"正在更新" = "正在更新";
@@ -281,7 +296,6 @@
"收窄" = "收窄";
"收成小卡" = "收成小卡";
"这场会议的语言" = "这场会议的语言";
-"结束" = "结束";
"正在听 · " = "正在听 · ";
"正在记录 · " = "正在记录 · ";
"%lld 句" = "%lld 句";
@@ -445,8 +459,8 @@
/* SessionStore */
"会议 %@" = "会议 %@";
+"未识别" = "未识别";
"不到 1 分钟" = "不到 1 分钟";
-"待办" = "待办";
/* SettingsWindow */
"语言" = "语言";
@@ -464,7 +478,6 @@
"还差一步:允许“输入监控”" = "还差一步:允许“输入监控”";
"“按住右 ⌥ 说话”需要此权限。请在系统设置中勾选 %@,返回此处即可生效" = "“按住右 ⌥ 说话”需要此权限。请在系统设置中勾选 %@,返回此处即可生效";
"去允许" = "去允许";
-"知了" = "知了";
"再试一次" = "再试一次";
"虚拟麦克风已就绪" = "虚拟麦克风已就绪";
"%@ · 试音通过,对方听得到" = "%@ · 试音通过,对方听得到";
@@ -488,36 +501,37 @@
"对方会听到:" = "对方会听到:";
"一段声音" = "一段声音";
"虚拟麦克风未收到声音,请再试一次" = "虚拟麦克风未收到声音,请再试一次";
-"说一句话,听对方听到的声音,看每一步花了多久" = "说一句话,听对方听到的声音,看每一步花了多久";
"把我说的翻译给对方" = "把我说的翻译给对方";
+"说话" = "说话";
+"按住说话" = "按住说话";
+"说%@,对方听到" = "说%@,对方听到";
+"按键还需要“输入监控”权限" = "按键还需要“输入监控”权限";
+"系统麦克风还是 %@,别的软件听不到你" = "系统麦克风还是 %@,别的软件听不到你";
+"还原" = "还原";
+"系统麦克风被换成了 %@" = "系统麦克风被换成了 %@";
+"换回" = "换回";
+"系统麦克风还没换成 %@" = "系统麦克风还没换成 %@";
+"切换" = "切换";
+"%@还在用 %@" = "%@还在用 %@";
+"%@没选虚拟麦克风" = "%@没选虚拟麦克风";
+"怎么改" = "怎么改";
+"虚拟麦克风 %@" = "虚拟麦克风 %@";
+"系统麦克风已换好,关掉时换回" = "系统麦克风已换好,关掉时换回";
+"%@已选虚拟麦克风" = "%@已选虚拟麦克风";
+"说一句话,听对方听到的声音,看每一步花了多久" = "说一句话,听对方听到的声音,看每一步花了多久";
+"对方听不到你" = "对方听不到你";
+"对方听得到你" = "对方听得到你";
+"同声传译没打开" = "同声传译没打开";
"上次发言:松开后 %@ 秒,对方听到译文" = "上次发言:松开后 %@ 秒,对方听到译文";
"按住说话,松开后约 1 秒,对方听到译文" = "按住说话,松开后约 1 秒,对方听到译文";
"按住说话,松开后约 3 秒,对方听到译文" = "按住说话,松开后约 3 秒,对方听到译文";
"试一句" = "试一句";
-"按住说话" = "按住说话";
-"单独按住右侧 ⌥;和别的键一起按不触发" = "单独按住右侧 ⌥;和别的键一起按不触发";
-"按住快捷键说话,松开发送" = "按住快捷键说话,松开发送";
-"声音输出到" = "声音输出到";
-"对方只能听到虚拟麦克风里的声音" = "对方只能听到虚拟麦克风里的声音";
-"虚拟麦克风(自动)" = "虚拟麦克风(自动)";
-"高级:声音输出到 · %@" = "高级:声音输出到 · %@";
-"%@ 已装好" = "%@ 已装好";
-"试音通过" = "试音通过";
-"已装好" = "已装好";
-"系统麦克风" = "系统麦克风";
-"自动切换系统麦克风" = "自动切换系统麦克风";
-"同声传译打开时换成 %@,Chrome 等跟随系统的软件不用再设置" = "同声传译打开时换成 %@,Chrome 等跟随系统的软件不用再设置";
+"打开时把系统麦克风换成 %@" = "打开时把系统麦克风换成 %@";
"%@听你说话用" = "%@听你说话用";
-"固定用这个,不跟着系统切换" = "固定用这个,不跟着系统切换";
-"现在:%@" = "现在:%@";
-"关掉同声传译或退出%@时,换回 %@" = "关掉同声传译或退出%@时,换回 %@";
-"立即还原" = "立即还原";
-"同声传译已关,别的软件听不到你说话" = "同声传译已关,别的软件听不到你说话";
-"还原" = "还原";
-"跟随系统的网页听不到译文" = "跟随系统的网页听不到译文";
-"换回" = "换回";
-"切换" = "切换";
+"译文送到" = "译文送到";
+"自动切换系统麦克风" = "自动切换系统麦克风";
"自动(%@)" = "自动(%@)";
+"虚拟麦克风(自动)" = "虚拟麦克风(自动)";
"听的时候显示" = "听的时候显示";
"选择任意模式都会正常保存记录、生成纪要" = "选择任意模式都会正常保存记录、生成纪要";
"切换显示方式" = "切换显示方式";
@@ -542,6 +556,10 @@
"提醒后结束" = "提醒后结束";
"直接结束" = "直接结束";
"一直记录" = "一直记录";
+"实验功能" = "实验功能";
+"还在打磨,可能出错;随时能关,关掉不影响别的功能。" = "还在打磨,可能出错;随时能关,关掉不影响别的功能。";
+"按声音标出说话人 1、2…,只在这台 Mac 上处理" = "按声音标出说话人 1、2…,只在这台 Mac 上处理";
+"说话人识别" = "说话人识别";
/* Shortcuts */
"右 ⌥" = "右 ⌥";
@@ -589,7 +607,6 @@
"松开就发送" = "松开就发送";
"你的话" = "你的话";
"识别 + 翻译" = "识别 + 翻译";
-"识别" = "识别";
"合成声音" = "合成声音";
"示例句子" = "示例句子";
"麦克风峰值 %lld dB" = "麦克风峰值 %lld dB";
@@ -639,6 +656,24 @@
"再试一句" = "再试一句";
"复制报告" = "复制报告";
+/* SpeakerID */
+"说话人 %lld" = "说话人 %lld";
+"没认出是谁:太短,或和已知的声音都不像" = "没认出是谁:太短,或和已知的声音都不像";
+"实验" = "实验";
+"关掉说话人识别,记录里的名字一起收起" = "关掉说话人识别,记录里的名字一起收起";
+"Ling 从对话里认出,点一下可以改" = "Ling 从对话里认出,点一下可以改";
+"改名字,或和别人合并" = "改名字,或和别人合并";
+"不准?关掉" = "不准?关掉";
+"说了 %lld 句" = "说了 %lld 句";
+"名字" = "名字";
+"Ling 正在从对话里找名字…" = "Ling 正在从对话里找名字…";
+"输入名字" = "输入名字";
+"Ling 从对话里认出" = "Ling 从对话里认出";
+"Ling 从对话里认出:%@" = "Ling 从对话里认出:%@";
+"不是 TA" = "不是 TA";
+"其实是同一个人" = "其实是同一个人";
+"并入 %@" = "并入 %@";
+
/* SystemAudioTap */
"无法启动音频采集(%d)" = "无法启动音频采集(%d)";
"无法初始化音频单元(%d)" = "无法初始化音频单元(%d)";
@@ -685,20 +720,12 @@
/* Views */
"自动识别(%@)" = "自动识别(%@)";
"%@(需下载)" = "%@(需下载)";
-"按住" = "按住";
-"说%@ → %@" = "说%@ → %@";
-"会议已自动结束" = "会议已自动结束";
"系统" = "系统";
"内容" = "内容";
"仅本场" = "仅本场";
-"%@已选虚拟麦克风" = "%@已选虚拟麦克风";
-"系统麦克风已换成 %@" = "系统麦克风已换成 %@";
-"同声传译选项" = "同声传译选项";
"系统麦克风还是 %@" = "系统麦克风还是 %@";
"别的软件现在听不到你说话" = "别的软件现在听不到你说话";
-"系统麦克风被换成了 %@" = "系统麦克风被换成了 %@";
-"%@没选虚拟麦克风,对方听不到译文" = "%@没选虚拟麦克风,对方听不到译文";
-"虚拟麦克风尚未设置好,对方听不到你的声音" = "虚拟麦克风尚未设置好,对方听不到你的声音";
+"跟随系统的网页听不到译文" = "跟随系统的网页听不到译文";
"显示方式" = "显示方式";
"轮换" = "轮换";
"屏幕上不出字幕,文字记录照常保存" = "屏幕上不出字幕,文字记录照常保存";
@@ -707,26 +734,37 @@
"纪要窗口已打开" = "纪要窗口已打开";
"纪要窗口已收起" = "纪要窗口已收起";
"对方现在能看到纪要窗口" = "对方现在能看到纪要窗口";
-"同声传译设置…" = "同声传译设置…";
"系统麦克风换成 %@" = "系统麦克风换成 %@";
-"还原系统麦克风" = "还原系统麦克风";
+"译文送进 %@" = "译文送进 %@";
+"先装好虚拟麦克风,对方才听得到" = "先装好虚拟麦克风,对方才听得到";
+"打开:%@,按住 %@ 说话\n关掉:全部还原" = "打开:%@,按住 %@ 说话\n关掉:全部还原";
+"先试一句 →" = "先试一句 →";
+"说%@ → %@" = "说%@ → %@";
+"按住说%@" = "按住说%@";
+"正在翻译…" = "正在翻译…";
+"正在播出…" = "正在播出…";
+"松开后播出%@" = "松开后播出%@";
+"打开后:" = "打开后:";
+"按住" = "按住";
+"说话,松开后播出译文" = "说话,松开后播出译文";
+"关掉后全部还原" = "关掉后全部还原";
+"好,打开" = "好,打开";
+"虚拟麦克风还没装好" = "虚拟麦克风还没装好";
+"对方听到 %@ · %@" = "对方听到 %@ · %@";
+"对方听到 %@" = "对方听到 %@";
"搜索" = "搜索";
-"导出…" = "导出…";
-"收起更早的会议" = "收起更早的会议";
-"更早的会议" = "更早的会议";
-"还没有会议" = "还没有会议";
-"打开会议或视频,开始听后,每一场都会存在这里。" = "打开会议或视频,开始听后,每一场都会存在这里。";
-"先听一段示例" = "先听一段示例";
"没有找到“%@”" = "没有找到“%@”";
"今天" = "今天";
"昨天" = "昨天";
"本周" = "本周";
+"收起更早的会议" = "收起更早的会议";
+"更早的会议" = "更早的会议";
"未命名会议" = "未命名会议";
+"%lld 小时" = "%lld 小时";
+"%lld 小时 %lld 分" = "%lld 小时 %lld 分";
"在 Finder 中显示" = "在 Finder 中显示";
"恢复自动标题" = "恢复自动标题";
"删除" = "删除";
-"%lld 小时" = "%lld 小时";
-"%lld 小时 %lld 分" = "%lld 小时 %lld 分";
"英语" = "英语";
"日语" = "日语";
"中文" = "中文";
@@ -736,21 +774,21 @@
"法语" = "法语";
"德语" = "德语";
"葡语" = "葡语";
-"开始听" = "开始听";
"正在听,说话的内容会出现在这里" = "正在听,说话的内容会出现在这里";
"这场会议没有记录到内容" = "这场会议没有记录到内容";
-"译文" = "译文";
+"还没有会议" = "还没有会议";
+"打开会议或视频,开始听后,每一场都会存在这里。" = "打开会议或视频,开始听后,每一场都会存在这里。";
+"先听一段示例" = "先听一段示例";
+"收起原话" = "收起原话";
+"在纪要旁显示原话" = "在纪要旁显示原话";
"复制为 Markdown" = "复制为 Markdown";
"导出 Markdown…" = "导出 Markdown…";
"导出 Word…" = "导出 Word…";
"导出字幕 SRT…" = "导出字幕 SRT…";
-"标题" = "标题";
+"导出…" = "导出…";
"完整版纪要" = "完整版纪要";
"速记版纪要" = "速记版纪要";
-"原话" = "原话";
-"收起原话" = "收起原话";
-"在纪要旁显示原话" = "在纪要旁显示原话";
-"此刻" = "此刻";
+"标题" = "标题";
"全部 %lld 句" = "全部 %lld 句";
"翻译中…" = "翻译中…";
"正在整理纪要…" = "正在整理纪要…";
@@ -770,8 +808,7 @@
"%@要让系统认出虚拟麦克风,声音会断约 1 秒。" = "%@要让系统认出虚拟麦克风,声音会断约 1 秒。";
/* VoicePicker */
-"你说%@,对方听到%@" = "你说%@,对方听到%@";
-"改语言" = "改语言";
+"声音" = "声音";
"选择对方听到的声音" = "选择对方听到的声音";
"试听" = "试听";
"系统声音" = "系统声音";
diff --git a/Sources/LiveSubs/AboutPanel.swift b/Sources/LiveSubs/AboutPanel.swift
index 321e4a2..55651c6 100644
--- a/Sources/LiveSubs/AboutPanel.swift
+++ b/Sources/LiveSubs/AboutPanel.swift
@@ -27,6 +27,10 @@ enum AboutPanel {
linked[.link] = url
text.append(NSAttributedString(string: title, attributes: linked))
}
+ var note = plain
+ note[.foregroundColor] = NSColor.secondaryLabelColor
+ note[.font] = NSFont.systemFont(ofSize: 10)
+ text.append(NSAttributedString(string: "\n" + L("声纹模型:WeSpeaker ResNet34-LM(VoxCeleb),CC BY 4.0"), attributes: note))
if let dev = DevBuild.label {
var secondary = plain
secondary[.foregroundColor] = NSColor.secondaryLabelColor
diff --git a/Sources/LiveSubs/AppModel.swift b/Sources/LiveSubs/AppModel.swift
index 79b027e..2bc9031 100644
--- a/Sources/LiveSubs/AppModel.swift
+++ b/Sources/LiveSubs/AppModel.swift
@@ -22,6 +22,8 @@ final class AppModel: ObservableObject {
}
/// The 试一句 sheet in settings.
@Published var speakTestShown = false
+ /// The panel is asking, the first time, what turning 同声传译 on changes.
+ @Published var speakAsking = 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)
@@ -84,6 +86,11 @@ final class AppModel: ObservableObject {
lazy var notes = NotesEngine(ling: ling, store: store)
lazy var notesWindow = NotesWindowController(model: self)
let sample = SamplePlayer()
+ let speakers = SpeakerTagger()
+ lazy var speakerNamer = SpeakerNamer(ling: ling, store: store)
+ /// Set by the notes window; the records window's people row opens that voice's editor.
+ @Published var speakerEdit: SpeakerEditRequest?
+ private var speakerSetting: AnyCancellable?
var openOnboarding: (() -> Void)?
var openMainWindow: (() -> Void)?
@@ -109,6 +116,15 @@ final class AppModel: ObservableObject {
}
listen.onStateChange = { [weak self] in self?.refresh() }
listen.onFinal = { [weak self] seg, duration in self?.recordHeard(seg, duration: duration) }
+ speakers.onVoice = { [weak self] line, voice in
+ guard let self else { return }
+ self.store.setVoice(lineID: line, voice)
+ if let id = self.store.liveID { self.speakerNamer.guess(id) }
+ }
+ speakerSetting = settings.$speakerVoices.sink { [weak self] on in
+ TranscriptExport.voices = on
+ self?.listen.router.setVoiceCapture(on)
+ }
listen.onTranslated = { [weak self] segID, text in
guard let self, let line = self.lineForSegment[segID] else { return }
self.store.setTranslation(lineID: line, text)
@@ -356,6 +372,7 @@ final class AppModel: ObservableObject {
guard !listen.isRunning else { return }
let session = store.begin()
diagnostics.begin()
+ speakers.reset()
lineForSegment = [:]
speechHeard = false
meetingSubtitles = nil
@@ -385,7 +402,10 @@ final class AppModel: ObservableObject {
listen.stop()
listen.router.setRecording(nil)
speak.setRecording(nil)
+ // Read the whole meeting for names once more (the id outlives store.end).
+ let ended = store.liveID
store.end(at: endedAt)
+ if settings.speakerVoices, let ended { speakerNamer.guess(ended, force: true) }
notes.finish()
overlay.hide()
refresh()
@@ -572,6 +592,7 @@ final class AppModel: ObservableObject {
func enableSpeaking(_ on: Bool) {
settings.speakEnabled = on
+ if on { settings.speakConfirmed = true }
objectWillChange.send()
if on {
AVCaptureDevice.requestAccess(for: .audio) { granted in
@@ -784,7 +805,7 @@ final class AppModel: ObservableObject {
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()))) 分钟没人说话")
+ case .silence, .nobodySpoke: L("已经 \(max(1, Int((endConfig.silenceAfter / 60).rounded()))) 分钟没人说话")
}
}
@@ -802,6 +823,12 @@ final class AppModel: ObservableObject {
/// 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) {
+ if reason == .nobodySpoke {
+ // Nothing to keep or summarise: back to "开始听", not "会议已自动结束".
+ debugLog("meeting end: nobody spoke for \(Int(w.config.silenceAfter)) s, stopped")
+ stop()
+ return
+ }
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")
@@ -811,6 +838,14 @@ final class AppModel: ObservableObject {
// MARK: Meeting record
+ /// Names are typed in the records window: the notes window never takes focus.
+ func editSpeaker(session: String, voice: Int) {
+ speakerEdit = SpeakerEditRequest(session: session, voice: voice)
+ mainShow = nil
+ mainShow = "\(session),transcript"
+ openMainWindow?()
+ }
+
private func recordHeard(_ seg: Segment, duration: Double) {
guard let start = store.liveStart else { return }
lineCounter += 1
@@ -819,6 +854,10 @@ 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))
+ // A line with hardly a letter ("." from a breath or a click) gets no voiceprint.
+ if settings.speakerVoices, let samples = seg.voiceSamples, seg.text.filter(\.isLetter).count >= 2 {
+ speakers.tag(lineID: id, samples: samples)
+ }
heardWords()
}
@@ -902,6 +941,31 @@ final class AppModel: ObservableObject {
openOnboarding?()
case "step": onboardingStep = Int(arg) ?? 1
case "samplePlay": ensureListening(); sample.play()
+ case "speakers": settings.speakerVoices = arg == "on"
+ case "speakerGuess": speakerNamer.guess(arg, force: true)
+ case "speakersRender":
+ // speakersRender:<session id>=<png>[@width]: the people strip and the first lines with their labels.
+ let p = arg.split(separator: "=", maxSplits: 1).map(String.init)
+ guard p.count == 2, let s = store.session(p[0]) else { break }
+ let out = p[1].split(separator: "@").map(String.init)
+ let width = out.count > 1 ? CGFloat(Double(out[1]) ?? 360) : 360
+ let r = ImageRenderer(content: SpeakerPreview(model: self, session: s).environment(\.speakerNames, SpeakerLabels.names(s)).frame(width: width).background(Color.white))
+ r.scale = 2
+ if let img = r.nsImage, let tiff = img.tiffRepresentation, let rep = NSBitmapImageRep(data: tiff),
+ let png = rep.representation(using: .png, properties: [:]) {
+ try? png.write(to: URL(fileURLWithPath: out[0]))
+ }
+ case "voiceprintFile":
+ // voiceprintFile:<audio>=<json>: the app's voiceprint of a whole file, to compare with the reference model.
+ let p = arg.split(separator: "=", maxSplits: 1).map(String.init)
+ guard p.count == 2 else { break }
+ DispatchQueue.global().async {
+ let samples = Voiceprints.samples(of: URL(fileURLWithPath: p[0]))
+ let v = samples.flatMap { s in (try? Voiceprints.load())?.embed(s) }
+ let data = try? JSONSerialization.data(withJSONObject: ["seconds": Double(samples?.count ?? 0) / 16000, "v": v ?? []])
+ try? data?.write(to: URL(fileURLWithPath: p[1]))
+ debugLog("voiceprintFile: \(v == nil ? "failed" : "ok") \(p[0])")
+ }
case "micVerify": installer.install(verifyOnly: true)
case "settings":
settingsSection = SettingsSection(rawValue: arg) ?? settingsSection
@@ -1031,6 +1095,24 @@ final class AppModel: ObservableObject {
try? full.representation(using: .png, properties: [:])?.write(to: URL(fileURLWithPath: arg + ".notes.png"))
}
}
+ case "panelRender":
+ // The menu bar panel drawn offscreen with real AppKit controls: the popover closes
+ // as soon as another app is active, so it can't be caught by windowsRender.
+ let host = NSHostingView(rootView: MenuPanelView(model: self, settings: settings))
+ let size = host.fittingSize
+ let w = NSWindow(contentRect: NSRect(x: -10000, y: -10000, width: size.width, height: size.height),
+ styleMask: .borderless, backing: .buffered, defer: false)
+ w.isReleasedWhenClosed = false
+ w.contentView = host
+ w.orderBack(nil)
+ DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
+ host.layoutSubtreeIfNeeded()
+ if let rep = host.bitmapImageRepForCachingDisplay(in: host.bounds) {
+ host.cacheDisplay(in: host.bounds, to: rep)
+ try? rep.representation(using: .png, properties: [:])?.write(to: URL(fileURLWithPath: arg))
+ }
+ w.orderOut(nil)
+ }
case "settingsRender":
// settingsRender:<section>=<png>: one settings page in full, scroll view or not.
let p = arg.split(separator: "=", maxSplits: 1).map(String.init)
@@ -1068,6 +1150,10 @@ final class AppModel: ObservableObject {
case "notesRegenerate":
let p = arg.split(separator: "=").map(String.init)
if p.count == 2 { regenerateNotes(p[0], choice: p[1]) }
+ case "speakAsk":
+ // speakAsk[:off]: the panel's one-time question, as if the switch was flipped for the first time.
+ speakAsking = arg != "off"
+ case "speakConfirmed": settings.speakConfirmed = arg != "off"
case "speakOn": enableSpeaking(true)
case "speakOff": enableSpeaking(false)
case "speakOut": speak.debugOutputURL = arg.isEmpty ? nil : URL(fileURLWithPath: arg)
@@ -1140,6 +1226,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate {
private var settingsWindow: NSWindow?
private var pollTimer: Timer?
private var runningObserver: Any?
+ private var popoverClickMonitor: Any?
private lazy var menu = AppMenu(model: model)
/// Held here: a toolbar keeps only a weak reference to its delegate.
private lazy var mainToolbar = MainToolbar(model: model)
@@ -1233,6 +1320,15 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate {
// edge, pushing the top of the panel above the screen.
panel.sizingOptions = .preferredContentSize
popover.contentViewController = panel
+ // .transient closes on focus changes, but the notes panel and the subtitle bar never take
+ // focus: a click on them would leave the popover open on top. Close it ourselves.
+ popoverClickMonitor = NSEvent.addLocalMonitorForEvents(matching: [.leftMouseDown, .rightMouseDown]) { [weak self] e in
+ if let self, self.popover.isShown, let w = e.window, w !== self.popover.contentViewController?.view.window,
+ w !== self.statusItem.button?.window {
+ self.popover.performClose(nil)
+ }
+ return e
+ }
}
@objc private func togglePopover() {
diff --git a/Sources/LiveSubs/AudioRouter.swift b/Sources/LiveSubs/AudioRouter.swift
index 700f668..dccaac6 100644
--- a/Sources/LiveSubs/AudioRouter.swift
+++ b/Sources/LiveSubs/AudioRouter.swift
@@ -62,6 +62,44 @@ final class AudioRouter: @unchecked Sendable {
/// The last short pause between words, on the analyzer's clock: where it ended and how long it was.
private var pause: (end: Double, length: Double) = (0, 0)
+ /// Experimental voiceprints: the last `voiceLimit` seconds as 16 kHz mono floats, placed on
+ /// the analyzer clock so a result's time range finds its audio.
+ private let voiceConverter = PCMConverter()
+ private let voiceFormat = AVAudioFormat(commonFormat: .pcmFormatFloat32, sampleRate: 16000, channels: 1, interleaved: false)!
+ private var voiceCapture = false
+ private var voice: [Float] = []
+ private var voiceStart = 0.0
+ private let voiceLimit = 90.0
+
+ func setVoiceCapture(_ on: Bool) {
+ queue.async { [self] in
+ voiceCapture = on
+ if !on { voice = []; voiceStart = 0 }
+ }
+ }
+
+ /// 16 kHz mono audio between two analyzer-clock times, or nil when it's no longer kept.
+ func voiceSamples(from start: Double, to end: Double) -> [Float]? {
+ queue.sync {
+ let a = Int(((start - voiceStart) * 16000).rounded()), b = Int(((end - voiceStart) * 16000).rounded())
+ guard a >= 0, b > a, b <= voice.count + 1600 else { return nil }
+ // A voiceprint uses at most `Voiceprints.maxSeconds`; don't copy more.
+ return Array(voice[a..<min(b, voice.count, a + Int(Voiceprints.maxSeconds * 16000))])
+ }
+ }
+
+ private func keepVoice(_ mono: AVAudioPCMBuffer) {
+ guard voiceCapture, continuation != nil,
+ let b = voiceConverter.convert(mono, to: voiceFormat), let d = b.floatChannelData else { return }
+ if voice.isEmpty { voiceStart = fed }
+ voice.append(contentsOf: UnsafeBufferPointer(start: d[0], count: Int(b.frameLength)))
+ let over = voice.count - Int(voiceLimit * 16000)
+ if over > 16000 {
+ voice.removeFirst(over)
+ voiceStart += Double(over) / 16000
+ }
+ }
+
private var recordURL: URL?
private var recorder: AVAudioFile?
@@ -102,6 +140,7 @@ final class AudioRouter: @unchecked Sendable {
guard let format, let converted = converter.convert(mono, to: format) else { return }
continuation?.yield(AnalyzerInput(buffer: converted))
+ keepVoice(mono)
if continuation != nil { fed += seconds }
record(converted)
ring.append((converted, seconds, voiced))
@@ -143,6 +182,10 @@ final class AudioRouter: @unchecked Sendable {
queue.sync {
fed = 0
pause = (0, 0)
+ // The clock restarts; replayed audio (below) keeps its samples at the new times.
+ let keptVoice = voice
+ voice = []
+ voiceStart = 0
if self.format != format {
ring.removeAll()
ringSeconds = 0
@@ -156,6 +199,7 @@ final class AudioRouter: @unchecked Sendable {
}
for buffer in replay.reversed() { continuation.yield(AnalyzerInput(buffer: buffer)) }
fed = acc
+ voice = Array(keptVoice.suffix(Int(acc * 16000)))
}
self.format = format
self.continuation?.finish()
@@ -176,6 +220,8 @@ final class AudioRouter: @unchecked Sendable {
continuation = nil
ring.removeAll()
ringSeconds = 0
+ voice = []
+ voiceStart = 0
voicedTotal = 0
silenceRun = 0
sinceGap = 0
diff --git a/Sources/LiveSubs/Diagnostics.swift b/Sources/LiveSubs/Diagnostics.swift
index c936fb9..1f0bc96 100644
--- a/Sources/LiveSubs/Diagnostics.swift
+++ b/Sources/LiveSubs/Diagnostics.swift
@@ -185,17 +185,26 @@ struct DiagnosticsView: View {
var body: some View {
VStack(alignment: .leading, spacing: 14) {
Text(subtitle).font(.system(size: 12)).foregroundStyle(Palette.secondary).padding(.top, -8)
- HStack(spacing: 8) {
- tile(L("说完到上屏"), diagnostics.endToEnd, dark: true)
- tile(L("识别定稿"), diagnostics.recognize)
- tile(L("翻译"), diagnostics.translate)
- tile(L("纪要一轮"), diagnostics.notesRounds)
+ if empty {
+ // Nothing measured yet: four dashes, a grey bar and zeros read as broken. Show
+ // what each stage is and the shape a sentence will take instead.
+ pipeline
+ emptyChannels
+ emptyRecent
+ } else {
+ HStack(spacing: 8) {
+ tile(L("说完到上屏"), diagnostics.endToEnd, dark: true)
+ tile(L("识别定稿"), diagnostics.recognize)
+ tile(L("翻译"), diagnostics.translate)
+ tile(L("纪要一轮"), diagnostics.notesRounds)
+ }
+ providers
+ lingCard
+ recent
}
- providers
- lingCard
- recent
HStack(spacing: 8) {
- SoftButton(copied ? L("已复制") : L("复制诊断信息"), dark: true) { copy() }
+ SoftButton(copied ? L("已复制") : L("复制诊断信息"), dark: !empty) { copy() }
+ .disabled(empty)
// The meeting folder holds metrics.jsonl; the log only exists in dev builds or with `debug` on.
SoftButton(diagnostics.folder() == nil ? L("打开日志") : L("打开本场数据")) {
NSWorkspace.shared.open(diagnostics.folder() ?? URL(fileURLWithPath: DevBuild.logPath))
@@ -207,8 +216,11 @@ struct DiagnosticsView: View {
.onReceive(timer) { tick = $0 }
}
+ private var empty: Bool { diagnostics.sentences.isEmpty && diagnostics.calls.isEmpty }
+
private var subtitle: String {
guard let s = diagnostics.startedAt else { return L("开始聆听后,这里会显示每句话的耗时明细") }
+ if empty { return L("有人说话后,这里会显示每句话的耗时明细") }
let m = Int((diagnostics.endedAt ?? tick).timeIntervalSince(s) / 60)
return L("这场会议 · \(m) 分钟 · \(diagnostics.heard.count) 句 · 同声传译 \(diagnostics.said.count) 次")
}
@@ -226,6 +238,101 @@ struct DiagnosticsView: View {
.overlay(RoundedRectangle(cornerRadius: 12).stroke(dark ? .clear : Palette.line, lineWidth: 1))
}
+ // MARK: Before any sentence
+
+ private var pipeline: some View {
+ VStack(alignment: .leading, spacing: 16) {
+ HStack {
+ Text("一句话的路").font(.system(size: 13, weight: .semibold)).foregroundStyle(Palette.ink)
+ Spacer()
+ Text("还没有句子").font(.system(size: 12)).foregroundStyle(Palette.tertiary)
+ }
+ TimelineView(.animation(minimumInterval: 1 / 30)) { ctx in
+ GeometryReader { g in
+ ZStack(alignment: .leading) {
+ Capsule().fill(Palette.fill).frame(height: 4)
+ Circle().fill(Palette.accent).frame(width: 10, height: 10)
+ .offset(x: phase(ctx.date, period: 2.4) * (g.size.width - 10))
+ }
+ .frame(maxHeight: .infinity)
+ }
+ }
+ .frame(height: 10).padding(.horizontal, 14).accessibilityHidden(true)
+ HStack(alignment: .top, spacing: 8) {
+ stage(L("识别定稿"), L("听清这句话"))
+ stage(L("翻译"), L("译成目标语言"))
+ stage(L("说完到上屏"), L("你感到的延迟"))
+ stage(L("纪要一轮"), L("更新一次纪要"))
+ }
+ }
+ .padding(16)
+ .background(RoundedRectangle(cornerRadius: 12).fill(Color.white))
+ .overlay(RoundedRectangle(cornerRadius: 12).stroke(Palette.line, lineWidth: 1))
+ }
+
+ private func stage(_ title: String, _ detail: String) -> some View {
+ VStack(alignment: .leading, spacing: 4) {
+ Text(title).font(.system(size: 12, weight: .semibold)).foregroundStyle(Palette.ink).lineLimit(2)
+ .fixedSize(horizontal: false, vertical: true)
+ Text(detail).font(.system(size: 11)).foregroundStyle(Palette.tertiary).lineLimit(2)
+ .fixedSize(horizontal: false, vertical: true)
+ Text("– s").font(.system(size: 18, weight: .bold).monospacedDigit()).foregroundStyle(Palette.placeholder)
+ }
+ .frame(maxWidth: .infinity, alignment: .leading).padding(.horizontal, 4)
+ }
+
+ private var emptyChannels: some View {
+ SettingsCard {
+ SettingsRow(title: L("翻译通道")) {
+ HStack(spacing: 12) {
+ ForEach(["ling", "google", "apple"], id: \.self) { v in
+ HStack(spacing: 5) {
+ RoundedRectangle(cornerRadius: 2).fill(Self.color(v)).frame(width: 8, height: 8)
+ Text(Self.name(v)).font(.system(size: 12)).foregroundStyle(Palette.secondary)
+ }
+ }
+ }
+ }
+ SettingsRow(title: L("Ling 用量"), detail: L("账号上限约每秒 2 次"), divider: false) {
+ Text("本场还没调用").font(.system(size: 12)).foregroundStyle(Palette.tertiary)
+ }
+ }
+ }
+
+ private var emptyRecent: some View {
+ VStack(alignment: .leading, spacing: 12) {
+ Text("最近的句子").font(.system(size: 13, weight: .semibold)).foregroundStyle(Palette.ink)
+ HStack(spacing: 10) {
+ Text("示例 · 对方").font(.system(size: 12)).foregroundStyle(Palette.tertiary).frame(width: 150, alignment: .leading)
+ HStack(spacing: 1) {
+ RoundedRectangle(cornerRadius: 2).fill(Color(red: 0.42, green: 0.44, blue: 0.50)).frame(width: 70)
+ RoundedRectangle(cornerRadius: 2).fill(Color(red: 0.96, green: 0.78, blue: 0.71)).frame(width: 18)
+ RoundedRectangle(cornerRadius: 2).fill(Palette.ink).frame(width: 46)
+ }
+ .frame(height: 10)
+ Spacer(minLength: 0)
+ Text("2.4s").font(.system(size: 12, weight: .semibold).monospacedDigit())
+ }
+ .opacity(0.5)
+ HStack(spacing: 14) {
+ legend(Color(red: 0.42, green: 0.44, blue: 0.50), L("识别"))
+ legend(Color(red: 0.96, green: 0.78, blue: 0.71), L("排队"))
+ legend(Palette.ink, L("翻译"))
+ }
+ }
+ .padding(14)
+ .frame(maxWidth: .infinity, alignment: .leading)
+ .background(RoundedRectangle(cornerRadius: 12).fill(Color.white))
+ .overlay(RoundedRectangle(cornerRadius: 12).stroke(Palette.line, lineWidth: 1))
+ }
+
+ private func legend(_ color: Color, _ title: String) -> some View {
+ HStack(spacing: 5) {
+ RoundedRectangle(cornerRadius: 2).fill(color).frame(width: 8, height: 8)
+ Text(title).font(.system(size: 11)).foregroundStyle(Palette.tertiary)
+ }
+ }
+
private static func color(_ via: String) -> Color {
switch via {
case "ling": Palette.ink
diff --git a/Sources/LiveSubs/ListenEngine.swift b/Sources/LiveSubs/ListenEngine.swift
index d251025..b13b5f7 100644
--- a/Sources/LiveSubs/ListenEngine.swift
+++ b/Sources/LiveSubs/ListenEngine.swift
@@ -8,6 +8,8 @@ struct Segment {
let text: String
let sourceCode: String
var translation: String?
+ /// The sentence's audio, 16 kHz mono, when telling voices apart is on.
+ var voiceSamples: [Float]? = nil
}
/// System audio → language detection → on-device transcription → translation.
@@ -121,6 +123,7 @@ final class ListenEngine {
debugLog("listen start mode=\(settings.sourceMode) target=\(resolvedTarget)")
guard startTap() else { return }
+ router.setVoiceCapture(settings.speakerVoices)
isRunning = true
startTickTimer()
@@ -326,13 +329,18 @@ final class ListenEngine {
}
let conf = chars > 0 ? weighted / Double(chars) : 1
let provisional = volatileTranslation.isEmpty ? nil : volatileTranslation
- let seg = Segment(id: nextSegmentID, text: text, sourceCode: activeLang?.code ?? "auto", translation: provisional)
+ var seg = Segment(id: nextSegmentID, text: text, sourceCode: activeLang?.code ?? "auto", translation: provisional)
+ if settings.speakerVoices {
+ seg.voiceSamples = router.voiceSamples(from: CMTimeGetSeconds(result.range.start), to: CMTimeGetSeconds(result.range.end))
+ }
nextSegmentID += 1
// How long ago, in real time, the sentence's last word was spoken.
let ago = router.fedSeconds() - CMTimeGetSeconds(result.range.end)
finalTiming[seg.id] = (Date(), ago.isFinite && ago >= 0 && ago < 30 ? ago : nil)
if finalTiming.count > 40, let oldest = finalTiming.keys.min() { finalTiming[oldest] = nil }
- segments.append(seg)
+ var shown = seg
+ shown.voiceSamples = nil // the audio only travels to the meeting record
+ segments.append(shown)
// Only the last few are shown; in notes mode nothing clears them after a pause.
if segments.count > 30 { segments.removeFirst(segments.count - 30) }
if segments.count > 8 { segments.removeFirst(segments.count - 8) }
@@ -346,6 +354,8 @@ final class ListenEngine {
onFinal?(seg, spoken)
} else {
unconfirmed.append((seg, Date(), spoken))
+ // Held lines keep their audio only while recent: an undecided language must not pile up minutes of it.
+ if unconfirmed.count > 20 { unconfirmed[unconfirmed.count - 21].seg.voiceSamples = nil }
}
translateSegment(id: seg.id)
if settings.sourceMode == .auto, conf < 0.6, text.count >= 4 {
diff --git a/Sources/LiveSubs/MeetingEnd.swift b/Sources/LiveSubs/MeetingEnd.swift
index 39feb90..5ad4c6b 100644
--- a/Sources/LiveSubs/MeetingEnd.swift
+++ b/Sources/LiveSubs/MeetingEnd.swift
@@ -26,6 +26,8 @@ struct MeetingEndWatch: Equatable {
/// The meeting app (by name) hung up.
case appLeft(String)
case silence
+ /// Nobody spoke at all: there is nothing to keep, so it just stops, without a countdown.
+ case nobodySpoke
}
struct Pending: Equatable {
@@ -60,12 +62,15 @@ struct MeetingEndWatch: Equatable {
}
/// `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.
+ /// keeps listening for the silence time (the subtitles stay ready), then stops quietly: a
+ /// forgotten switch shouldn't listen to an empty room for hours. 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
+ let inACall = config.followApps && !calls.isEmpty
+ if config.silence != .off, !inACall, now.timeIntervalSince(lastSpeech) >= config.silenceAfter { return .nobodySpoke }
return nil
}
if config.followApps {
diff --git a/Sources/LiveSubs/MicUsers.swift b/Sources/LiveSubs/MicUsers.swift
index 796cc6b..44d5fe1 100644
--- a/Sources/LiveSubs/MicUsers.swift
+++ b/Sources/LiveSubs/MicUsers.swift
@@ -52,6 +52,12 @@ enum MicUsers {
return nil
}
+ /// Apple's own processes that read the mic for themselves (System Settings › Sound's level
+ /// meter, Siri, Voice Memos) never carry a meeting: listing them only raises false alarms.
+ static func isSystemUI(_ app: String) -> Bool {
+ app.hasPrefix("com.apple.") && app != "com.apple.Safari" && app != "com.apple.FaceTime"
+ }
+
/// 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,
@@ -59,7 +65,7 @@ enum MicUsers {
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 }
+ guard let app = owner(of: r.bundleID, running: ids), app != ownBundleID, !isSystemUI(app) else { continue }
inputs[app, default: []].formUnion(r.inputs)
}
var users = inputs.map { app, devices -> MicUser in
diff --git a/Sources/LiveSubs/MicUsersView.swift b/Sources/LiveSubs/MicUsersView.swift
index e9a1a41..7f2718b 100644
--- a/Sources/LiveSubs/MicUsersView.swift
+++ b/Sources/LiveSubs/MicUsersView.swift
@@ -1,82 +1,6 @@
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(model.settings.autoSystemMic ? L("跟随系统的软件会自动换好;在软件里自己选过麦克风的,要在软件里改。")
- : L("这里只显示正在用麦克风的会议软件和常见会议软件,麦克风要在各软件里自己换。"))
- .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 } }
}
diff --git a/Sources/LiveSubs/Notes.swift b/Sources/LiveSubs/Notes.swift
index fdea1dc..427d10f 100644
--- a/Sources/LiveSubs/Notes.swift
+++ b/Sources/LiveSubs/Notes.swift
@@ -225,7 +225,8 @@ final class NotesEngine: ObservableObject {
let base = final || fresh ? MeetingNotes() : (id == shownID ? notes : session.notes ?? MeetingNotes())
let from = final ? 0 : min(base.covered, lines.count)
let lang = language(id)
- let prompt = Self.prompt(notes: base, lines: lines, from: from, language: lang, final: final)
+ let names = TranscriptExport.voices ? SpeakerLabels.names(session) : [:]
+ let prompt = Self.prompt(notes: base, lines: lines, from: from, language: lang, final: final, names: names)
let started = Date()
do {
// The final pass sends only the transcript, with no notes in the reader's language to
@@ -310,10 +311,14 @@ final class NotesEngine: ObservableObject {
static func clock(_ t: Double) -> String { TranscriptExport.clock(t) }
- static func prompt(notes: MeetingNotes, lines: [TranscriptLine], from: Int, language: String, final: Bool) -> String {
+ static func prompt(notes: MeetingNotes, lines: [TranscriptLine], from: Int, language: String, final: Bool,
+ names: [Int: String] = [:]) -> String {
+ let numbers = TranscriptExport.voices ? SpeakerLabels.numbers(lines) : [:]
func line(_ i: Int) -> String {
let l = lines[i]
- return "[L\(i + 1) \(clock(l.t)) \(l.speaker == "me" ? "你" : "对方")] \(l.src)"
+ // A named voice goes as its name: notes then say "George" rather than "说话人2".
+ let who = l.speaker == "me" ? "你" : numbers[l.id].map { names[$0] ?? "说话人\($0)" } ?? (numbers.isEmpty ? "对方" : "未识别")
+ return "[L\(i + 1) \(clock(l.t)) \(who)] \(l.src)"
}
var current = "{}"
if !notes.isEmpty, let data = try? JSONEncoder().encode(Compact(notes)), let s = String(data: data, encoding: .utf8) {
@@ -331,7 +336,7 @@ final class NotesEngine: ObservableObject {
if context < from {
p += "Already covered (context only):\n" + (context..<from).map(line).joined(separator: "\n") + "\n\n"
}
- p += "\(final ? "Transcript" : "New lines") (id, mm:ss, speaker 对方=the other side / 你=me, text). Speech recognition makes mistakes, often in names: correct them from context.\n"
+ p += "\(final ? "Transcript" : "New lines") (id, mm:ss, speaker 对方=the other side / 你=me / a name or 说话人N=one person on the other side, told apart by voice and possibly wrong / 未识别=someone on the other side not identified, text). Speech recognition makes mistakes, often in names: correct them from context.\n"
p += (from..<lines.count).map(line).joined(separator: "\n")
// The model splits too eagerly when only told how long a topic should be: say plainly
// whether this update may start one.
@@ -352,7 +357,7 @@ final class NotesEngine: ObservableObject {
"topics": [{"start": seconds, "title": "short title", "summary": "one sentence", "points": [{"text": "key point", "evidence": ["L4"]}], "evidence": ["L3"],
"fishbone": null or {"question": "the problem or question", "branches": [{"label": "2-6 words", "detail": "one short line", "t": seconds, "evidence": ["L5"]}]}}],
"conclusions": [{"text": "...", "evidence": ["L7", "L8"]}],
- "todos": [{"text": "...", "owner": "对方" or "你" or null, "evidence": ["L9"]}],
+ "todos": [{"text": "...", "owner": \(numbers.isEmpty ? "\"对方\" or \"你\" or null" : "the person's label from the transcript (a name like \"George\", or \"说话人2\"), \"你\", or null when unclear"), "evidence": ["L9"]}],
"terms": [{"name": "correct spelling", "note": "who or what, a few words", "heard": ["how it was misrecognised"]}]}
Rules (be brief: these notes are read at a glance during the meeting):
- title: a name for the whole meeting, like a calendar entry (at most 12 Chinese characters or 6 words; no date, no quotes, not "会议" alone). Keep the current title unless the meeting's subject has clearly changed.
diff --git a/Sources/LiveSubs/NotesViews.swift b/Sources/LiveSubs/NotesViews.swift
index 3e55f71..d539792 100644
--- a/Sources/LiveSubs/NotesViews.swift
+++ b/Sources/LiveSubs/NotesViews.swift
@@ -155,11 +155,12 @@ private struct DocumentNotesView: View {
VStack(alignment: .leading, spacing: 40) {
let items = notes.conclusions + notes.todos
if !items.isEmpty {
- VStack(alignment: .leading, spacing: 12) {
+ VStack(alignment: .leading, spacing: 8) {
Text(notes.todos.isEmpty ? L("结论") : L("结论和待办"))
- .font(.system(size: 12)).foregroundStyle(Palette.secondary)
+ .font(.system(size: 12, weight: .medium)).foregroundStyle(Palette.secondary)
+ .padding(.bottom, 2)
ForEach(Array(items.enumerated()), id: \.offset) { i, item in
- conclusion(item, todo: i >= notes.conclusions.count)
+ conclusion(item, index: i + 1, todo: i >= notes.conclusions.count)
}
}
.padding(.horizontal, 24).padding(.vertical, 22)
@@ -168,13 +169,13 @@ private struct DocumentNotesView: View {
}
if !notes.summary.isEmpty {
- Text(notes.summary).font(.system(size: 15)).lineSpacing(9).foregroundStyle(Palette.secondary)
+ Text(notes.summary).font(.system(size: 15)).lineSpacing(9).foregroundStyle(Palette.body)
.textSelection(.enabled).fixedSize(horizontal: false, vertical: true)
}
if !notes.topics.isEmpty {
VStack(alignment: .leading, spacing: 0) {
- Text("议题").font(.system(size: 12)).foregroundStyle(Palette.secondary).padding(.bottom, 8)
+ Text("议题").font(.system(size: 12, weight: .medium)).foregroundStyle(Palette.tertiary).padding(.bottom, 8)
ForEach(Array(notes.topics.enumerated()), id: \.element.id) { i, topic in
let current = live && i == notes.topics.count - 1
Rectangle().fill(MainWindowView.hairline).frame(height: 1)
@@ -189,7 +190,7 @@ private struct DocumentNotesView: View {
if !notes.terms.isEmpty {
VStack(alignment: .leading, spacing: 10) {
- Text("人名和术语").font(.system(size: 12)).foregroundStyle(Palette.secondary)
+ Text("人名和术语").font(.system(size: 12, weight: .medium)).foregroundStyle(Palette.tertiary)
FlowLayout(spacing: 6) {
ForEach(notes.terms) { t in
(Text(t.name).bold() + Text(t.note.isEmpty ? "" : " \(t.note)"))
@@ -203,20 +204,51 @@ private struct DocumentNotesView: View {
}
}
- /// A conclusion reads as a sentence; clicking it jumps to the lines behind it.
- private func conclusion(_ item: NoteItem, todo: Bool) -> some View {
- HStack(alignment: .firstTextBaseline, spacing: 10) {
- if todo { Image(systemName: "circle").font(.system(size: 13)).foregroundStyle(Palette.secondary) }
- Text(item.text + (item.owner.map { "(\($0))" } ?? ""))
- .font(.system(size: 17, weight: .medium)).lineSpacing(5)
- .foregroundStyle(item.support == 0 ? Palette.secondary : Palette.ink)
+ /// A conclusion reads as a plain sentence, numbered, with its numbers and dates marked; clicking it
+ /// jumps to the lines behind it. One with little support stays grey.
+ private func conclusion(_ item: NoteItem, index: Int, todo: Bool) -> some View {
+ let weak = item.support == 0
+ let text = item.text + (item.owner.map { "(\($0))" } ?? "")
+ return HStack(alignment: .firstTextBaseline, spacing: 8) {
+ Group {
+ if todo { Image(systemName: "circle").font(.system(size: 11)) } else { Text("\(index)").font(.system(size: 12).monospacedDigit()) }
+ }
+ .fontWeight(.semibold).foregroundStyle(weak ? Palette.secondary : Palette.link).frame(width: 16, alignment: .leading)
+ Text(weak ? AttributedString(text) : Highlight.facts(text))
+ .font(.system(size: 15)).lineSpacing(5)
+ .foregroundStyle(weak ? Palette.secondary : Palette.ink)
.fixedSize(horizontal: false, vertical: true)
.frame(maxWidth: .infinity, alignment: .leading)
- if item.support == 0 { Tag(L("依据较少")) }
+ if weak { Tag(L("依据较少")) }
+ if let t = item.t, !weak { TimeLink(text: NotesEngine.clock(t), t: t, onJump: onJump) }
+ }
+ .padding(.vertical, 3)
+ }
+}
+
+/// Numbers with their units and day words ("5000 元", "20 岁", "3月3日", "周五晚上") in a conclusion,
+/// marked so the facts can be picked out at a glance.
+enum Highlight {
+ private static let pattern = try! NSRegularExpression(pattern:
+ "(\\d+\\s*月\\s*\\d+\\s*[日号])"
+ + "|((下|本|这|上)?(周|星期|礼拜)[一二三四五六日天](早上|上午|中午|下午|晚上)?)"
+ + "|(\\d[\\d,.]*\\s*(万|千|百|亿)?\\s*(元|块|美元|岁|人|个|次|天|周|个月|月|年|小时|分钟|点|号|%|%|k|K)?)"
+ + "|((今天|明天|后天|昨天|月底|月初|年底)(早上|上午|中午|下午|晚上)?)")
+
+ static func facts(_ text: String) -> AttributedString {
+ var out = AttributedString(text)
+ let ns = text as NSString
+ for m in pattern.matches(in: text, range: NSRange(location: 0, length: ns.length)) {
+ // A lone digit (list numbers, "第1") is noise; keep multi-digit numbers, units and days.
+ let hit = ns.substring(with: m.range)
+ if hit.count < 2 { continue }
+ guard let r = Range(m.range, in: text),
+ let lo = AttributedString.Index(r.lowerBound, within: out),
+ let hi = AttributedString.Index(r.upperBound, within: out) else { continue }
+ out[lo..<hi].backgroundColor = Palette.mark
+ out[lo..<hi].font = .system(size: 15, weight: .semibold)
}
- .contentShape(Rectangle())
- .onTapGesture { if let t = item.t { onJump(t) } }
- .help(item.t.map { L("\(NotesEngine.clock($0)) · \(item.support) 句") } ?? "")
+ return out
}
}
@@ -241,9 +273,9 @@ private struct DocumentTopicRow: View {
HStack(alignment: .firstTextBaseline, spacing: 8) {
Button { withAnimation(.easeOut(duration: 0.2)) { open.toggle() } } label: {
HStack(alignment: .firstTextBaseline, spacing: 8) {
- Text(String(format: "%02d", index + 1)).font(.system(size: 12, weight: .bold).monospacedDigit())
- .foregroundStyle(Palette.secondary).frame(width: 28, alignment: .leading)
- Text(topic.title).font(.system(size: 16, weight: .semibold)).foregroundStyle(Palette.ink)
+ Text(String(format: "%02d", index + 1)).font(.system(size: 12, weight: .semibold).monospacedDigit())
+ .foregroundStyle(Palette.link).frame(width: 28, alignment: .leading)
+ Text(topic.title).font(.system(size: 15, weight: .semibold)).foregroundStyle(Palette.ink)
.multilineTextAlignment(.leading)
if current { Tag(L("正在讲"), live: true) }
if fresh.contains(topic.title) && !current { Tag(L("新"), live: true) }
@@ -261,13 +293,13 @@ private struct DocumentTopicRow: View {
if open {
VStack(alignment: .leading, spacing: 7) {
if !topic.summary.isEmpty {
- Text(topic.summary).font(.system(size: 15)).lineSpacing(6).foregroundStyle(Palette.secondary)
+ Text(topic.summary).font(.system(size: 14)).lineSpacing(6).foregroundStyle(Palette.body)
.fixedSize(horizontal: false, vertical: true)
}
ForEach(Array(topic.points.enumerated()), id: \.offset) { i, p in
HStack(alignment: .firstTextBaseline, spacing: 8) {
Text("·").foregroundStyle(Palette.secondary)
- Text(p).font(.system(size: 15)).lineSpacing(5).textSelection(.enabled)
+ Text(p).font(.system(size: 14)).lineSpacing(5).foregroundStyle(Palette.ink).textSelection(.enabled)
.fixedSize(horizontal: false, vertical: true)
if fresh.contains(p) { Tag(L("新"), live: true) }
}
@@ -366,9 +398,10 @@ struct TimeLink: View {
var body: some View {
Button { onJump(t) } label: {
Text(text).font(.system(size: 12).monospacedDigit())
- .foregroundStyle(hover ? Palette.ink : Palette.tertiary)
+ .fontWeight(.medium)
+ .foregroundStyle(Palette.link)
+ .underline(hover)
.padding(.horizontal, 6).padding(.vertical, 2)
- .background(RoundedRectangle(cornerRadius: 5).fill(hover ? Palette.fill : .clear))
.fixedSize()
}
.buttonStyle(.plain)
@@ -478,6 +511,10 @@ struct TranscriptListView: View {
var partial = ""
var partialTime: Double?
var jumpTo: Double?
+ /// Experimental: line id → speaker number for the other side's lines (SpeakerLabels).
+ var speakers: [String: Int] = [:]
+ /// When listening began, for the start mark shown before the first line.
+ var startedAt: Date?
@State private var following = true
@State private var seenCount = 0
@@ -486,7 +523,8 @@ struct TranscriptListView: View {
/// The caption keeps the last sentence after it is finished: only show text not yet a line.
private var showsPartial: Bool {
let p = partial.trimmingCharacters(in: .whitespacesAndNewlines)
- guard live, !p.isEmpty else { return false }
+ // A lone "." from background noise is not someone speaking.
+ guard live, p.rangeOfCharacter(from: .alphanumerics) != nil else { return false }
guard let last = lines.last?.src else { return true }
return !last.contains(p) && !p.contains(last)
}
@@ -515,6 +553,7 @@ struct TranscriptListView: View {
ScrollView {
LazyVStack(alignment: .leading, spacing: 10) {
let gs = groups
+ let starts = SpeakerLabels.runStarts(lines, speakers)
ForEach(Array(gs.enumerated()), id: \.element.start) { gi, g in
// One lazy child per topic group, with an id to scroll to before it is drawn.
VStack(alignment: .leading, spacing: 10) {
@@ -524,7 +563,8 @@ struct TranscriptListView: View {
}
FramedList {
ForEach(Array(g.lines.enumerated()), id: \.element.id) { i, l in
- row(l).id(l.id)
+ // With voices told apart, a name only where the speaker changes (and atop each topic).
+ row(l, label: speakers.isEmpty || i == 0 || starts.contains(l.id)).id(l.id)
if i < g.lines.count - 1 { Divider() }
}
if gi == gs.count - 1, showsPartial {
@@ -536,8 +576,12 @@ struct TranscriptListView: View {
.id(groupID(g.start))
}
if lines.isEmpty && !showsPartial {
- Text("说话的内容会出现在这里").font(.system(size: 13)).foregroundStyle(Palette.tertiary)
- .frame(maxWidth: .infinity).padding(.top, 40)
+ if live {
+ TranscriptWaitingView(startedAt: startedAt)
+ } else {
+ Text("说话的内容会出现在这里").font(.system(size: 13)).foregroundStyle(Palette.tertiary)
+ .frame(maxWidth: .infinity).padding(.top, 40)
+ }
}
Color.clear.frame(height: 1).id("bottom")
}
@@ -650,7 +694,7 @@ struct TranscriptListView: View {
return a
}
- private func row(_ l: TranscriptLine) -> some View {
+ private func row(_ l: TranscriptLine, label: Bool = true) -> some View {
let isMatch = l.id == currentMatch
let latest = live && l.id == lines.last?.id
let dim = searching && !matches(l)
@@ -659,7 +703,10 @@ struct TranscriptListView: View {
.foregroundStyle(latest || isMatch ? Palette.accentInk : Palette.tertiary)
.frame(width: l.t >= 3600 ? 56 : 40, alignment: .leading).padding(.top, 2)
VStack(alignment: .leading, spacing: 4) {
- if l.speaker == "me" { Text("你").font(.system(size: 11, weight: .semibold)).foregroundStyle(Palette.accentInk) }
+ if !label {
+ } else if l.speaker == "me" { Text("你").font(.system(size: 11, weight: .semibold)).foregroundStyle(Palette.accentInk) }
+ else if let n = speakers[l.id] { SpeakerTag(number: n) }
+ else if !speakers.isEmpty { UnknownSpeakerTag() }
Text(highlighted(l.src, current: isMatch)).font(.system(size: 14)).lineSpacing(2).textSelection(.enabled)
if bilingual, let d = l.dst, d != l.src {
Text(highlighted(d, current: isMatch)).font(.system(size: 13)).foregroundStyle(Palette.secondary)
@@ -693,6 +740,75 @@ struct TranscriptListView: View {
}
}
+/// The transcript before anyone has spoken: the start mark, two rows in the bilingual shape
+/// lines will take, and 此刻 waiting for the first words.
+struct TranscriptWaitingView: View {
+ var startedAt: Date?
+
+ private static let time: DateFormatter = { let f = DateFormatter(); f.dateFormat = "HH:mm"; return f }()
+
+ var body: some View {
+ VStack(alignment: .leading, spacing: 0) {
+ HStack(spacing: 10) {
+ if let startedAt { Text(Self.time.string(from: startedAt)).monospacedDigit() }
+ Rectangle().fill(MainWindowView.hairline).frame(height: 1)
+ Text("从这里开始听")
+ }
+ .font(.system(size: 12)).foregroundStyle(Palette.tertiary)
+ .padding(.bottom, 14)
+ FramedList {
+ skeletonRow(0.7, 0.88)
+ Divider()
+ skeletonRow(0.54, 0.66).opacity(0.55)
+ }
+ HStack(spacing: 16) {
+ legend(Palette.placeholder.opacity(0.6), L("原话"))
+ legend(Palette.ink, L("译文"))
+ }
+ .padding(.top, 10).padding(.leading, 2)
+ VStack(alignment: .leading, spacing: 6) {
+ Text("此刻").font(.system(size: 11, weight: .bold)).foregroundStyle(Palette.accentInk)
+ HStack(spacing: 3) {
+ Text("等有人开口").font(.system(size: 15)).foregroundStyle(Palette.tertiary)
+ BlinkingCaret()
+ }
+ }
+ .frame(maxWidth: .infinity, alignment: .leading)
+ .padding(.horizontal, 16).padding(.vertical, 14)
+ .background(RoundedRectangle(cornerRadius: 14).fill(Palette.raised))
+ .padding(.top, 28)
+ }
+ .padding(.top, 8)
+ }
+
+ private func skeletonRow(_ a: CGFloat, _ b: CGFloat) -> some View {
+ VStack(alignment: .leading, spacing: 8) {
+ SkeletonBar(fraction: a, height: 9)
+ SkeletonBar(fraction: b, height: 11)
+ }
+ .padding(14)
+ }
+
+ private func legend(_ color: Color, _ title: String) -> some View {
+ HStack(spacing: 6) {
+ Capsule().fill(color).frame(width: 14, height: 4)
+ Text(title)
+ }
+ .font(.system(size: 12)).foregroundStyle(Palette.tertiary)
+ }
+}
+
+/// A text caret blinking once a second.
+struct BlinkingCaret: View {
+ var body: some View {
+ TimelineView(.periodic(from: .now, by: 0.5)) { ctx in
+ Rectangle().fill(Palette.accent).frame(width: 2, height: 17)
+ .opacity(Int(ctx.date.timeIntervalSinceReferenceDate * 2) % 2 == 0 ? 1 : 0)
+ }
+ .accessibilityHidden(true)
+ }
+}
+
// MARK: - Small parts
struct SectionTitle: View {
@@ -766,28 +882,6 @@ func phase(_ date: Date, period: Double, delay: Double = 0) -> Double {
return (t.truncatingRemainder(dividingBy: period) + period).truncatingRemainder(dividingBy: period) / period
}
-/// Listening, nobody has spoken yet: five sound bars with a soft ring pulsing behind them.
-struct ListeningMark: View {
- var body: some View {
- TimelineView(.animation(minimumInterval: 1 / 30)) { ctx in
- let ring = phase(ctx.date, period: 2)
- ZStack {
- Circle().fill(Palette.accentPale)
- .scaleEffect(0.8 + 0.8 * ring).opacity(0.55 * (1 - ring))
- HStack(spacing: 6) {
- ForEach(0..<5, id: \.self) { i in
- let p = phase(ctx.date, period: 1.1, delay: Double(i) * 0.15)
- Capsule().fill(Palette.accent).frame(width: 6, height: 44)
- .scaleEffect(x: 1, y: 0.25 + 0.75 * (0.5 - 0.5 * cos(p * 2 * .pi)))
- }
- }
- }
- .frame(width: 120, height: 120)
- }
- .accessibilityHidden(true)
- }
-}
-
/// A small orange ring spinner.
struct Spinner: View {
var size: CGFloat = 16
@@ -855,17 +949,72 @@ struct SkeletonBar: View {
}
}
-/// Listening, nothing said yet.
+/// Listening, nothing said yet: one quiet status row, then the notes' own shape waiting to be
+/// filled, so the first version lands where the reader is already looking.
struct NotesListeningView: View {
var body: some View {
- VStack(spacing: 22) {
- ListeningMark()
- VStack(spacing: 8) {
- Text("正在听").font(.system(size: 17, weight: .bold))
- Text("有人说话时,会自动开始写纪要").font(.system(size: 13)).foregroundStyle(Palette.secondary)
+ VStack(alignment: .leading, spacing: 22) {
+ HStack(spacing: 12) {
+ SoundBars()
+ Text("有人开口后,约半分钟出第一版").font(.system(size: 13)).foregroundStyle(Palette.ink)
+ Spacer(minLength: 0)
+ }
+ .padding(.horizontal, 14).padding(.vertical, 12)
+ .background(RoundedRectangle(cornerRadius: 12).fill(Palette.accentPale.opacity(0.7)))
+ VStack(alignment: .leading, spacing: 10) {
+ Text("总结").font(.system(size: 15, weight: .bold)).foregroundStyle(Palette.placeholder)
+ SkeletonBar(fraction: 0.94, height: 10)
+ SkeletonBar(fraction: 0.8, height: 10)
+ SkeletonBar(fraction: 0.56, height: 10)
+ }
+ VStack(alignment: .leading, spacing: 12) {
+ Text("议题").font(.system(size: 15, weight: .bold)).foregroundStyle(Palette.placeholder)
+ topicSlot(time: "00:00", lines: [0.52, 0.88, 0.7])
+ topicSlot(time: "--:--", lines: [0.4, 0.76]).opacity(0.6)
+ }
+ // Wraps: the English chips don't fit one line in a narrow window.
+ FlowLayout(spacing: 6) {
+ Text("会整理出").font(.system(size: 12)).foregroundStyle(Palette.tertiary).padding(.vertical, 4)
+ ForEach([L("结论"), L("待办"), L("人名和术语"), L("鱼骨图")], id: \.self) { t in
+ Text(t).font(.system(size: 12)).foregroundStyle(Palette.secondary).fixedSize()
+ .padding(.horizontal, 10).padding(.vertical, 4)
+ .background(Capsule().fill(Palette.fill))
+ }
}
+ .padding(.top, 4)
}
- .frame(maxWidth: .infinity)
+ }
+
+ private func topicSlot(time: String, lines: [CGFloat]) -> some View {
+ HStack(alignment: .top, spacing: 12) {
+ Text(time).font(.system(size: 12).monospacedDigit()).foregroundStyle(Palette.placeholder)
+ VStack(alignment: .leading, spacing: 8) {
+ ForEach(Array(lines.enumerated()), id: \.offset) { i, f in
+ SkeletonBar(fraction: f, height: i == 0 ? 11 : 8)
+ }
+ }
+ }
+ .padding(14)
+ .overlay(RoundedRectangle(cornerRadius: 12).strokeBorder(Palette.line, style: StrokeStyle(lineWidth: 1.5, dash: [5, 4])))
+ }
+}
+
+/// Four small orange bars rising and falling: "listening", at the size of a line of text.
+struct SoundBars: View {
+ var height: CGFloat = 22
+
+ var body: some View {
+ TimelineView(.animation(minimumInterval: 1 / 30)) { ctx in
+ HStack(spacing: 3) {
+ ForEach(0..<4, id: \.self) { i in
+ let p = phase(ctx.date, period: 1.1, delay: Double(i) * 0.15)
+ Capsule().fill(Palette.accent).frame(width: 3, height: height)
+ .scaleEffect(x: 1, y: 0.3 + 0.7 * (0.5 - 0.5 * cos(p * 2 * .pi)))
+ }
+ }
+ }
+ .frame(height: height)
+ .accessibilityHidden(true)
}
}
diff --git a/Sources/LiveSubs/NotesWindow.swift b/Sources/LiveSubs/NotesWindow.swift
index 0714965..8e448f6 100644
--- a/Sources/LiveSubs/NotesWindow.swift
+++ b/Sources/LiveSubs/NotesWindow.swift
@@ -613,13 +613,9 @@ struct NotesWindowView: View {
} else if engine.state == .noKey || engine.state == .invalidKey {
Spacer()
} else if live && heard == 0 {
- VStack {
- Spacer()
- NotesListeningView()
- Spacer()
- Spacer()
+ ScrollView {
+ NotesListeningView().padding(.horizontal, 24).padding(.vertical, 12)
}
- .frame(maxWidth: .infinity)
} else if live || (session != nil && engine.generatingID == session?.id) { // nil == nil is not "generating"
ScrollView {
NotesGeneratingView(heard: heard).padding(.horizontal, 24).padding(.vertical, 12)
@@ -671,9 +667,18 @@ struct NotesWindowView: View {
private var transcript: some View {
let ms = matches
- return TranscriptListView(lines: session?.lines ?? [], topics: engine.notes.topics, terms: searchTerms,
- currentMatch: ms.isEmpty ? nil : ms[currentIndex], live: live,
- partial: model.liveSource, partialTime: elapsed, jumpTo: jumpTo)
+ let lines = session?.lines ?? []
+ let speakers = model.settings.speakerVoices ? SpeakerLabels.numbers(lines) : [:]
+ return VStack(alignment: .leading, spacing: 10) {
+ if !speakers.isEmpty, let s = session {
+ SpeakerStrip(model: model, session: s) { voice in model.editSpeaker(session: s.id, voice: voice) }
+ }
+ TranscriptListView(lines: lines, topics: engine.notes.topics, terms: searchTerms,
+ currentMatch: ms.isEmpty ? nil : ms[currentIndex], live: live,
+ partial: model.liveSource, partialTime: elapsed, jumpTo: jumpTo, speakers: speakers,
+ startedAt: store.liveStart)
+ }
+ .environment(\.speakerNames, session.map(SpeakerLabels.names) ?? [:])
}
@ViewBuilder
diff --git a/Sources/LiveSubs/SessionStore.swift b/Sources/LiveSubs/SessionStore.swift
index 8c0c8df..74d59a9 100644
--- a/Sources/LiveSubs/SessionStore.swift
+++ b/Sources/LiveSubs/SessionStore.swift
@@ -11,6 +11,14 @@ struct TranscriptLine: Codable, Identifiable, Equatable {
var dst: String?
var srcLang: String
var dstLang: String
+ /// Experimental: which of the other side's voices said it (SpeakerID.swift); nil when unknown.
+ var voice: Int? = nil
+}
+
+/// A name Ling found for a voice, and the line it is based on ("00:06 “Sure, Emma…”").
+struct VoiceGuess: Codable, Equatable {
+ var name: String
+ var evidence: String
}
struct Session: Codable, Identifiable, Equatable {
@@ -24,6 +32,11 @@ struct Session: Codable, Identifiable, Equatable {
var notes: MeetingNotes?
/// The user renamed it; nil in older sessions, where any title but the default counts as renamed.
var renamed: Bool?
+ /// Experimental 说话人识别: names the user gave voices, keyed by voice id. An empty name means
+ /// "not Ling's guess": the voice shows as 说话人 N.
+ var voiceNames: [String: String]? = nil
+ /// Names Ling read from the conversation, keyed by voice id; shown until the user says otherwise.
+ var voiceGuesses: [String: VoiceGuess]? = nil
var duration: TimeInterval { (endedAt ?? Date()).timeIntervalSince(startedAt) }
@@ -146,6 +159,48 @@ final class SessionStore: ObservableObject {
scheduleSave(id)
}
+ func setVoice(lineID: String, _ voice: Int) {
+ guard let id = liveID, let i = index(id),
+ let j = sessions[i].lines.firstIndex(where: { $0.id == lineID }) else { return }
+ sessions[i].lines[j].voice = voice
+ scheduleSave(id)
+ }
+
+ /// The user names a voice. nil drops their name (Ling's guess shows again); "" keeps 说话人 N.
+ func setVoiceName(_ id: String, voice: Int, _ name: String?) {
+ guard let i = index(id) else { return }
+ var names = sessions[i].voiceNames ?? [:]
+ names[String(voice)] = name?.trimmingCharacters(in: .whitespacesAndNewlines)
+ sessions[i].voiceNames = names.isEmpty ? nil : names
+ saveNow(id)
+ }
+
+ /// Ling's latest guesses; earlier ones stay for voices it no longer mentions.
+ func setVoiceGuesses(_ id: String, _ guesses: [Int: VoiceGuess]) {
+ guard let i = index(id), !guesses.isEmpty else { return }
+ var all = sessions[i].voiceGuesses ?? [:]
+ for (v, g) in guesses { all[String(v)] = g }
+ guard all != sessions[i].voiceGuesses else { return }
+ sessions[i].voiceGuesses = all
+ saveNow(id)
+ }
+
+ /// The user said two voices are the same person: `from`'s lines become `into`'s.
+ func mergeVoice(_ id: String, _ from: Int, into: Int) {
+ guard let i = index(id), from != into else { return }
+ for j in sessions[i].lines.indices where sessions[i].lines[j].voice == from { sessions[i].lines[j].voice = into }
+ if var names = sessions[i].voiceNames, let moved = names.removeValue(forKey: String(from)) {
+ // A turned-down guess ("") stays with the voice it was about; a real name moves over.
+ if names[String(into)] == nil, !moved.isEmpty { names[String(into)] = moved }
+ sessions[i].voiceNames = names.isEmpty ? nil : names
+ }
+ if var guesses = sessions[i].voiceGuesses, let moved = guesses.removeValue(forKey: String(from)) {
+ if guesses[String(into)] == nil { guesses[String(into)] = moved }
+ sessions[i].voiceGuesses = guesses.isEmpty ? nil : guesses
+ }
+ saveNow(id)
+ }
+
func setNotes(_ id: String, _ notes: MeetingNotes) {
guard let i = index(id) else { return }
sessions[i].notes = notes
@@ -208,7 +263,16 @@ enum TranscriptExport {
: String(format: "%02d:%02d", s / 60, s % 60)
}
- static func speakerName(_ line: TranscriptLine) -> String { line.speaker == "me" ? L("你") : L("对方") }
+ /// Experimental speaker numbers on (设置 › 通用 › 实验功能); kept in step by AppModel.
+ nonisolated(unsafe) static var voices = false
+
+ static func speakerName(_ line: TranscriptLine, _ numbers: [String: Int] = [:], _ names: [Int: String] = [:]) -> String {
+ if line.speaker == "me" { return L("你") }
+ if let n = numbers[line.id] { return SpeakerLabels.label(n, names) }
+ return numbers.isEmpty ? L("对方") : L("未识别")
+ }
+
+ static func speakerNumbers(_ s: Session) -> [String: Int] { voices ? SpeakerLabels.numbers(s.lines) : [:] }
static func header(_ s: Session) -> String {
let mins = Int(s.duration / 60)
@@ -243,8 +307,9 @@ enum TranscriptExport {
var out = "# \(s.displayTitle)\n\n\(header(s))\n\n"
let notes = notesMarkdown(s.notes)
if !notes.isEmpty { out += notes + "## \(L("文字记录"))\n\n" }
+ let numbers = speakerNumbers(s), names = SpeakerLabels.names(s)
for l in s.lines {
- out += "**[\(clock(l.t))] \(speakerName(l))** \n\(l.src)\n"
+ out += "**[\(clock(l.t))] \(speakerName(l, numbers, names))** \n\(l.src)\n"
if let d = l.dst, d != l.src { out += "> \(d)\n" }
out += "\n"
}
@@ -303,8 +368,9 @@ enum TranscriptExport {
}
add(L("文字记录"), size: 15, weight: .bold, after: 6)
}
+ let numbers = speakerNumbers(s), names = SpeakerLabels.names(s)
for l in s.lines {
- add("[\(clock(l.t))] \(speakerName(l))", size: 9, weight: .semibold, color: .darkGray, after: 2)
+ add("[\(clock(l.t))] \(speakerName(l, numbers, names))", size: 9, weight: .semibold, color: .darkGray, after: 2)
add(l.src, size: 11, after: 2)
if let d = l.dst, d != l.src { add(d, size: 11, color: NSColor(calibratedWhite: 0.3, alpha: 1), after: 10) }
}
diff --git a/Sources/LiveSubs/Settings.swift b/Sources/LiveSubs/Settings.swift
index 59151d8..3cc82a8 100644
--- a/Sources/LiveSubs/Settings.swift
+++ b/Sources/LiveSubs/Settings.swift
@@ -31,6 +31,10 @@ final class AppSettings: ObservableObject {
@Published var speakEnabled: Bool {
didSet { save() }
}
+ /// The user has seen what turning 同声传译 on changes (the panel asks once, in place).
+ @Published var speakConfirmed: Bool {
+ didSet { save() }
+ }
/// Locale of the language I speak.
@Published var speakFrom: String {
didSet { save() }
@@ -108,6 +112,11 @@ final class AppSettings: ObservableObject {
didSet { save() }
}
+ /// Experimental: tell the other side's voices apart (说话人 1、2…). Off by default.
+ @Published var speakerVoices: Bool {
+ didSet { save() }
+ }
+
/// Record per-sentence timings (never text) and show the 诊断 tab. On by default in dev builds.
@Published var diagnostics: Bool {
didSet { save() }
@@ -126,6 +135,8 @@ final class AppSettings: ObservableObject {
subtitles = defaults.string(forKey: "subtitles") ?? "both"
notesLanguage = defaults.string(forKey: "notesLanguage") ?? "mine"
speakEnabled = defaults.bool(forKey: "speakEnabled")
+ // Anyone who had it on before this question existed already knows.
+ speakConfirmed = defaults.object(forKey: "speakConfirmed") as? Bool ?? defaults.bool(forKey: "speakEnabled")
speakFrom = defaults.string(forKey: "speakFrom")
?? speakLocale(forLanguage: LiveSubs.myLanguage(systemLanguages: Locale.preferredLanguages))
speakTo = defaults.string(forKey: "speakTo") ?? "room"
@@ -146,6 +157,7 @@ final class AppSettings: ObservableObject {
silenceMinutes = defaults.object(forKey: "silenceMinutes") as? Double ?? 10
diagnostics = defaults.object(forKey: "diagnostics") as? Bool ?? DevBuild.isDev
notesCapturable = defaults.bool(forKey: "notesCapturable")
+ speakerVoices = defaults.bool(forKey: "speakerVoices")
}
private func save() {
@@ -157,6 +169,7 @@ final class AppSettings: ObservableObject {
defaults.set(subtitles, forKey: "subtitles")
defaults.set(notesLanguage, forKey: "notesLanguage")
defaults.set(speakEnabled, forKey: "speakEnabled")
+ defaults.set(speakConfirmed, forKey: "speakConfirmed")
defaults.set(speakFrom, forKey: "speakFrom")
defaults.set(speakTo, forKey: "speakTo")
defaults.set(speakOutput, forKey: "speakOutput")
@@ -176,6 +189,7 @@ final class AppSettings: ObservableObject {
defaults.set(silenceMinutes, forKey: "silenceMinutes")
defaults.set(diagnostics, forKey: "diagnostics")
defaults.set(notesCapturable, forKey: "notesCapturable")
+ defaults.set(speakerVoices, forKey: "speakerVoices")
}
/// Target language. "Follow system" translates into my language, or into the next system
diff --git a/Sources/LiveSubs/SettingsWindow.swift b/Sources/LiveSubs/SettingsWindow.swift
index cd8a7fd..7e6c202 100644
--- a/Sources/LiveSubs/SettingsWindow.swift
+++ b/Sources/LiveSubs/SettingsWindow.swift
@@ -259,6 +259,23 @@ struct TalkKeyPermissionRow: View {
}
}
+/// A check, an exclamation mark, or (speaking off) a grey dash, in a small circle.
+struct HealthMark: View {
+ let ok: Bool
+ let on: Bool
+ /// On a tinted problem row the pale circle would vanish.
+ var onTint = false
+ var body: some View {
+ ZStack {
+ Circle().fill(onTint ? Color.white : !ok ? Palette.accentPale : on ? Palette.okPale : Palette.fill)
+ Image(systemName: !ok ? "exclamationmark" : on ? "checkmark" : "minus")
+ .font(.system(size: 9, weight: .bold))
+ .foregroundStyle(!ok ? Palette.accent : on ? Palette.ok : Palette.tertiary)
+ }
+ .frame(width: 20, height: 20)
+ }
+}
+
let appDisplayName = Bundle.main.object(forInfoDictionaryKey: "CFBundleName") as? String ?? L("知了")
// MARK: - Virtual microphone checklist
@@ -407,7 +424,14 @@ struct SettingsView: View {
/// The current section without the scroll view (also drawn by the `settingsRender` debug command).
var page: some View {
VStack(alignment: .leading, spacing: 16) {
- Text(model.settingsSection.title).font(.system(size: 20, weight: .bold)).foregroundStyle(Palette.ink)
+ HStack {
+ Text(model.settingsSection.title).font(.system(size: 20, weight: .bold)).foregroundStyle(Palette.ink)
+ Spacer()
+ if model.settingsSection == .speak {
+ Toggle("把我说的翻译给对方", isOn: Binding(get: { settings.speakEnabled }, set: { model.enableSpeaking($0) }))
+ .toggleStyle(.switch).labelsHidden().tint(Palette.ink)
+ }
+ }
switch model.settingsSection {
case .speak: speak
case .overlay: overlay
@@ -465,70 +489,146 @@ struct SettingsView: View {
// MARK: Sections
+ /// One card says whether the room hears you; it opens into a checklist only when something
+ /// is wrong. Below it, plain settings: what you say with, and which microphones.
private var speak: some View {
VStack(alignment: .leading, spacing: 14) {
- HStack(spacing: 10) {
- Text(latencyLine).font(.system(size: 12)).foregroundStyle(Palette.secondary)
+ if model.virtualMic == nil {
+ SettingsCard { MicSetupCard(installer: installer, deviceName: nil) }
+ } else {
+ speakHealth
+ }
+ group(L("说话")) {
+ SettingsRow(title: L("按住说话")) { ShortcutField(model: model, role: .talk) }
+ SettingsRow(title: L("说\(settings.speakFromLang.name),对方听到")) {
+ PillMenu(value: settings.speakTo == "room" ? L("跟随对方(\(targetName(model.speak.targetCode)))") : targetName(settings.speakTo),
+ options: [("room", L("跟随对方"))] + targetLanguages.map { ($0.code, $0.name) }) {
+ settings.speakTo = $0
+ model.objectWillChange.send()
+ }
+ }
+ VoiceSection(model: model, settings: settings, ling: model.ling)
+ }
+ if model.virtualMic != nil { micSettings }
+ }
+ .sheet(isPresented: $model.speakTestShown) {
+ SpeakTestView(model: model, tester: model.speakTester) {
+ if model.speakTester.busy { model.speakTester.cancel() }
+ model.speakTestShown = false
+ }
+ }
+ .sheet(item: $model.micGuide) { user in
+ MicGuideView(model: model, bundleID: user.bundleID, name: user.name) { model.micGuide = nil }
+ }
+ }
+
+ private func group<C: View>(_ title: String, @ViewBuilder _ content: () -> C) -> some View {
+ VStack(alignment: .leading, spacing: 8) {
+ Text(title).font(.system(size: 12, weight: .semibold)).foregroundStyle(Palette.tertiary).padding(.horizontal, 4)
+ SettingsCard { content() }
+ }
+ .padding(.top, 4)
+ }
+
+ /// Something keeping the room from hearing you, with the one button that fixes it.
+ private struct SpeakProblem: Identifiable {
+ let id: String
+ let text: String
+ let button: String
+ let action: () -> Void
+ }
+
+ private var speakProblems: [SpeakProblem] {
+ var out: [SpeakProblem] = []
+ if settings.speakEnabled && model.talkNeedsPermission {
+ out.append(.init(id: "key", text: L("按键还需要“输入监控”权限"), button: L("去允许"), action: model.allowTalkKey))
+ }
+ // A switched-away or never-restored system mic matters even with speaking off.
+ let virtual = model.virtualMic?.name ?? "BlackHole 2ch"
+ switch model.systemMicState {
+ case .notRestored:
+ out.append(.init(id: "sysmic", text: L("系统麦克风还是 \(virtual),别的软件听不到你"), button: L("还原"), action: model.restoreSystemMic))
+ case .moved(let to):
+ out.append(.init(id: "sysmic", text: L("系统麦克风被换成了 \(to)"), button: L("换回"), action: model.switchSystemMic))
+ case .off where model.wantsSystemMic:
+ out.append(.init(id: "sysmic", text: L("系统麦克风还没换成 \(virtual)"), button: L("切换"), action: model.switchSystemMic))
+ default: break
+ }
+ if settings.speakEnabled {
+ for user in model.micUsers where user.state.isOther {
+ let text: String
+ if case .otherMic(let mic) = user.state, !mic.isEmpty { text = L("\(user.name)还在用 \(mic)") }
+ else { text = L("\(user.name)没选虚拟麦克风") }
+ out.append(.init(id: user.bundleID, text: text, button: L("怎么改"), action: { model.micGuide = user }))
+ }
+ }
+ return out
+ }
+
+ /// What already works, listed above the problems so the broken step reads in context.
+ private var speakOK: [String] {
+ var out = [L("虚拟麦克风 \(model.virtualMic?.name ?? "BlackHole 2ch")")]
+ if case .switched = model.systemMicState { out.append(L("系统麦克风已换好,关掉时换回")) }
+ if settings.speakEnabled {
+ out += model.micUsers.filter { $0.state == .virtualMic }.map { L("\($0.name)已选虚拟麦克风") }
+ }
+ return out
+ }
+
+ private var speakHealth: some View {
+ let problems = speakProblems
+ let on = settings.speakEnabled
+ let ok = problems.isEmpty
+ return SettingsCard {
+ HStack(spacing: 12) {
+ HealthMark(ok: ok, on: on)
+ VStack(alignment: .leading, spacing: 2) {
+ Text(!ok ? L("对方听不到你") : on ? L("对方听得到你") : L("同声传译没打开"))
+ .font(.system(size: 13, weight: .semibold)).foregroundStyle(ok ? Palette.ink : Palette.accentInk)
+ Text(latencyLine).font(.system(size: 11)).foregroundStyle(Palette.tertiary)
+ .fixedSize(horizontal: false, vertical: true)
+ }
Spacer(minLength: 8)
Button { model.speakTestShown = true } label: {
HStack(spacing: 5) {
Image(systemName: "play.fill").font(.system(size: 9))
Text("试一句").font(.system(size: 12, weight: .semibold))
}
- .foregroundStyle(Color.white).padding(.horizontal, 12).frame(height: 28)
- .background(RoundedRectangle(cornerRadius: 7).fill(Palette.ink))
+ .foregroundStyle(ok ? Color.white : Palette.ink).padding(.horizontal, 12).frame(height: 28)
+ .background(RoundedRectangle(cornerRadius: 7).fill(ok ? Palette.ink : Palette.fill))
.contentShape(Rectangle())
}
.buttonStyle(.plain)
- .disabled(model.virtualMic == nil)
- .opacity(model.virtualMic == nil ? 0.4 : 1)
.help("说一句话,听对方听到的声音,看每一步花了多久")
- Toggle("把我说的翻译给对方", isOn: Binding(get: { settings.speakEnabled }, set: { model.enableSpeaking($0) }))
- .toggleStyle(.switch).labelsHidden().controlSize(.small).tint(Palette.ink)
}
- .padding(.top, -8)
- SettingsCard {
- micStep
- Divider().padding(.leading, 50)
- HStack(spacing: 12) {
- StepMark(done: !model.talkNeedsPermission, number: 2)
- VStack(alignment: .leading, spacing: 2) {
- Text("按住说话").font(.system(size: 13, weight: .semibold)).foregroundStyle(Palette.ink)
- Text(settings.talkKey.isRightOption ? L("单独按住右侧 ⌥;和别的键一起按不触发") : L("按住快捷键说话,松开发送"))
- .font(.system(size: 11)).foregroundStyle(Palette.tertiary)
+ .padding(.horizontal, 16).padding(.vertical, 12)
+ if !ok {
+ ForEach(speakOK, id: \.self) { line in
+ Divider().padding(.leading, 16)
+ HStack(spacing: 12) {
+ HealthMark(ok: true, on: true)
+ Text(line).font(.system(size: 13)).foregroundStyle(Palette.ink)
+ Spacer()
}
- Spacer(minLength: 8)
- ShortcutField(model: model, role: .talk)
+ .padding(.horizontal, 16).frame(minHeight: 40)
}
- .padding(.horizontal, 16).padding(.vertical, 12)
- if settings.speakEnabled && model.talkNeedsPermission { TalkKeyPermissionRow(model: model) }
- 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 {
- SettingsRow(title: L("声音输出到"), detail: L("对方只能听到虚拟麦克风里的声音"), divider: false) {
- PillMenu(value: outputName,
- options: [("", L("虚拟麦克风(自动)"))] + model.outputs.map { ($0.uid, $0.name) }) {
- settings.speakOutput = $0
- model.applySystemMic()
- }
+ ForEach(problems) { p in
+ Divider().padding(.leading, 16)
+ HStack(spacing: 12) {
+ HealthMark(ok: false, on: true, onTint: true)
+ Text(p.text).font(.system(size: 13)).foregroundStyle(Palette.accentInk)
+ .fixedSize(horizontal: false, vertical: true)
+ Spacer(minLength: 8)
+ SoftButton(p.button, dark: true, action: p.action)
}
+ .padding(.horizontal, 16).padding(.vertical, 8).frame(minHeight: 46)
+ .background(Palette.accentPale)
}
- .padding(.top, 8)
- } label: {
- Text("高级:声音输出到 · \(outputName)").font(.system(size: 12)).foregroundStyle(Palette.secondary)
- }
- .padding(.horizontal, 4)
- }
- .sheet(isPresented: $model.speakTestShown) {
- SpeakTestView(model: model, tester: model.speakTester) {
- if model.speakTester.busy { model.speakTester.cancel() }
- model.speakTestShown = false
}
}
+ // The tinted problem rows would otherwise square off the card's corners.
+ .clipShape(RoundedRectangle(cornerRadius: 12))
+ .overlay(RoundedRectangle(cornerRadius: 12).stroke(ok ? Color.clear : Palette.accent.opacity(0.35), lineWidth: 1))
}
/// The last measured press, else what to expect.
@@ -541,86 +641,35 @@ struct SettingsView: View {
return L("上次发言:松开后 \(String(format: "%.1f", v)) 秒,对方听到译文")
}
- /// Step 1: the checklist until the virtual mic is loaded, then one line.
- @ViewBuilder
- private var micStep: some View {
- if let name = model.virtualMic?.name {
- HStack(spacing: 12) {
- 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)
- }
- Spacer(minLength: 8)
- HStack(spacing: 6) {
- Circle().fill(micTested ? Palette.ok : Palette.placeholder).frame(width: 8, height: 8)
- Text(micTested ? L("试音通过") : L("已装好")).font(.system(size: 12)).foregroundStyle(Palette.secondary)
- }
- }
- .padding(.horizontal, 16).padding(.vertical, 12)
- } else {
- MicSetupCard(installer: installer, deviceName: nil)
- }
- }
-
- /// 系统麦克风: the virtual mic as the system default while speaking, and the real mic Cicada records from.
- private var systemMicSection: some View {
+ /// 麦克风: the virtual mic as the system default while speaking, the real mic Cicada records
+ /// from, and where the spoken translation goes. Their state shows in the card above.
+ private var micSettings: 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
- }
+ return group(L("麦克风")) {
+ SettingsRow(title: L("打开时把系统麦克风换成 \(virtual)")) {
+ Toggle("自动切换系统麦克风", isOn: Binding(get: { settings.autoSystemMic }, set: { model.setAutoSystemMic($0) }))
+ .toggleStyle(.switch).labelsHidden().controlSize(.small).tint(Palette.ink)
+ }
+ SettingsRow(title: L("\(appDisplayName)听你说话用")) {
+ 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)
+ }
+ SettingsRow(title: L("译文送到"), divider: false) {
+ PillMenu(value: outputName,
+ options: [("", L("虚拟麦克风(自动)"))] + model.outputs.map { ($0.uid, $0.name) }) {
+ settings.speakOutput = $0
+ model.applySystemMic()
}
}
}
}
- /// 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)
- }
-
private var outputName: String {
if settings.speakOutput.isEmpty { return L("虚拟麦克风(自动)") }
return model.outputs.first { $0.uid == settings.speakOutput }?.name ?? L("虚拟麦克风(自动)")
@@ -690,6 +739,32 @@ struct SettingsView: View {
}
}
AppRows(updates: model.updates, loginItem: model.loginItem, model: model)
+ experiments
+ }
+ }
+
+ /// Features still being tuned: off by default, each one switch, safe to turn off.
+ private var experiments: some View {
+ VStack(alignment: .leading, spacing: 8) {
+ VStack(alignment: .leading, spacing: 2) {
+ Text("实验功能").font(.system(size: 13, weight: .semibold)).foregroundStyle(Palette.secondary)
+ Text("还在打磨,可能出错;随时能关,关掉不影响别的功能。").font(.system(size: 11)).foregroundStyle(Palette.tertiary)
+ }
+ .padding(.top, 4)
+ SettingsCard {
+ HStack(spacing: 12) {
+ HStack(spacing: 6) {
+ Text("说话人识别").font(.system(size: 13)).foregroundStyle(Palette.ink)
+ ExperimentBadge()
+ }
+ Spacer(minLength: 12)
+ Toggle("说话人识别", isOn: $settings.speakerVoices)
+ .toggleStyle(.switch).labelsHidden().controlSize(.small).tint(Palette.ink)
+ }
+ .padding(.horizontal, 16).padding(.vertical, 6).frame(minHeight: 46)
+ .contentShape(Rectangle())
+ .help(L("按声音标出说话人 1、2…,只在这台 Mac 上处理"))
+ }
}
}
}
diff --git a/Sources/LiveSubs/SpeakerID.swift b/Sources/LiveSubs/SpeakerID.swift
new file mode 100644
index 0000000..0fcc0cd
--- /dev/null
+++ b/Sources/LiveSubs/SpeakerID.swift
@@ -0,0 +1,610 @@
+import Accelerate
+import AVFoundation
+import CoreML
+import Foundation
+import SwiftUI
+
+// Experimental 说话人识别: telling the other side's voices apart (设置 › 通用 › 实验功能). Each heard line's
+// audio becomes a voiceprint (WeSpeaker ResNet34-LM, VoxCeleb, CC BY 4.0, bundled as Core ML),
+// voiceprints are grouped as they arrive, and a voice is only named once it has a few lines. The
+// thresholds were tuned on AMI meetings; the model comes from `scripts/convert-voiceprint.py`.
+
+/// Kaldi log-mel filterbank, as `torchaudio.compliance.kaldi.fbank` computes it with the defaults the
+/// model was trained on: 16 kHz, 25 ms Povey windows every 10 ms, DC removed, pre-emphasis 0.97,
+/// 512-point power spectrum, 80 mel bins from 20 Hz to 8 kHz, natural log.
+enum Fbank {
+ static let bins = 80
+ static let frameLength = 400
+ static let shift = 160
+ private static let fftSize = 512
+
+ private static let window: [Float] = (0..<frameLength).map {
+ pow(0.5 - 0.5 * cos(2 * Float.pi * Float($0) / Float(frameLength - 1)), 0.85)
+ }
+
+ /// `bins` rows of `fftSize / 2 + 1` weights (the Nyquist column is always zero, as in Kaldi).
+ private static let melBanks: [Float] = {
+ func mel(_ f: Double) -> Double { 1127 * log(1 + f / 700) }
+ let cols = fftSize / 2 + 1
+ let lo = mel(20), hi = mel(8000), delta = (hi - lo) / Double(bins + 1)
+ var w = [Float](repeating: 0, count: bins * cols)
+ for m in 0..<bins {
+ let left = lo + Double(m) * delta, center = left + delta, right = center + delta
+ for k in 0..<(fftSize / 2) {
+ let x = mel(Double(k) * 16000 / Double(fftSize))
+ let v = min((x - left) / (center - left), (right - x) / (right - center))
+ if v > 0 { w[m * cols + k] = Float(v) }
+ }
+ }
+ return w
+ }()
+
+ private static let setup = vDSP_create_fftsetup(9, FFTRadix(kFFTRadix2))!
+
+ /// Frames × `bins`, row-major. `samples` are 16 kHz mono in -1...1.
+ static func compute(_ samples: [Float]) -> [Float] {
+ guard samples.count >= frameLength else { return [] }
+ let frames = 1 + (samples.count - frameLength) / shift
+ let cols = fftSize / 2 + 1
+ var out = [Float](repeating: 0, count: frames * bins)
+ var frame = [Float](repeating: 0, count: fftSize)
+ var re = [Float](repeating: 0, count: fftSize / 2), im = re
+ var power = [Float](repeating: 0, count: cols)
+ var mels = [Float](repeating: 0, count: bins)
+ for f in 0..<frames {
+ let start = f * shift
+ for i in 0..<frameLength { frame[i] = samples[start + i] * 32768 }
+ for i in frameLength..<fftSize { frame[i] = 0 }
+ var mean: Float = 0
+ vDSP_meanv(frame, 1, &mean, vDSP_Length(frameLength))
+ for i in 0..<frameLength { frame[i] -= mean }
+ for i in stride(from: frameLength - 1, to: 0, by: -1) { frame[i] -= 0.97 * frame[i - 1] }
+ frame[0] -= 0.97 * frame[0]
+ vDSP_vmul(frame, 1, window, 1, &frame, 1, vDSP_Length(frameLength))
+ re.withUnsafeMutableBufferPointer { rp in
+ im.withUnsafeMutableBufferPointer { ip in
+ var split = DSPSplitComplex(realp: rp.baseAddress!, imagp: ip.baseAddress!)
+ frame.withUnsafeBytes { raw in
+ vDSP_ctoz(raw.bindMemory(to: DSPComplex.self).baseAddress!, 2, &split, 1, vDSP_Length(fftSize / 2))
+ }
+ vDSP_fft_zrip(setup, &split, 1, 9, FFTDirection(FFT_FORWARD))
+ }
+ }
+ // vDSP's real FFT returns twice the true values, Nyquist packed into im[0].
+ power[0] = re[0] * re[0] / 4
+ power[cols - 1] = im[0] * im[0] / 4
+ for k in 1..<(fftSize / 2) { power[k] = (re[k] * re[k] + im[k] * im[k]) / 4 }
+ vDSP_mmul(melBanks, 1, power, 1, &mels, 1, vDSP_Length(bins), 1, vDSP_Length(cols))
+ for b in 0..<bins { out[f * bins + b] = log(max(mels[b], .ulpOfOne)) }
+ }
+ return out
+ }
+}
+
+/// The bundled voiceprint model. Command Line Tools can't compile Core ML models, so the
+/// `.mlpackage` is compiled on first use and the result kept in Application Support.
+final class Voiceprints: @unchecked Sendable {
+ static let minSeconds = 0.5
+ /// Longer lines are cut: 20 s is plenty to know a voice and bounds the work.
+ static let maxSeconds = 20.0
+
+ private let model: MLModel
+
+ private init(model: MLModel) { self.model = model }
+
+ static func load() throws -> Voiceprints {
+ guard let pkg = Bundle.main.url(forResource: "SpeakerEmbedding", withExtension: "mlpackage") else {
+ throw CocoaError(.fileNoSuchFile)
+ }
+ let size = (try? FileManager.default.attributesOfItem(atPath: pkg.appendingPathComponent("Data/com.apple.CoreML/weights/weight.bin").path)[.size] as? Int) ?? 0
+ let cache = FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask)[0]
+ .appendingPathComponent(DevBuild.supportFolder).appendingPathComponent("SpeakerEmbedding-\(size).mlmodelc")
+ if !FileManager.default.fileExists(atPath: cache.path) {
+ let compiled = try MLModel.compileModel(at: pkg)
+ try? FileManager.default.removeItem(at: cache)
+ try FileManager.default.moveItem(at: compiled, to: cache)
+ }
+ let config = MLModelConfiguration()
+ // Variable-length input doesn't compile for the Neural Engine; the GPU path is quick enough.
+ config.computeUnits = .cpuAndGPU
+ return Voiceprints(model: try MLModel(contentsOf: cache, configuration: config))
+ }
+
+ /// A whole audio file as 16 kHz mono floats (debug and tests).
+ static func samples(of url: URL) -> [Float]? {
+ guard let file = try? AVAudioFile(forReading: url),
+ let format = AVAudioFormat(commonFormat: .pcmFormatFloat32, sampleRate: 16000, channels: 1, interleaved: false),
+ let input = AVAudioPCMBuffer(pcmFormat: file.processingFormat, frameCapacity: AVAudioFrameCount(file.length)),
+ (try? file.read(into: input)) != nil,
+ let out = PCMConverter().convert(input, to: format), let d = out.floatChannelData else { return nil }
+ return Array(UnsafeBufferPointer(start: d[0], count: Int(out.frameLength)))
+ }
+
+ /// A unit-length 256-d voiceprint for 16 kHz mono samples, or nil when too short.
+ func embed(_ samples: [Float]) -> [Float]? {
+ guard Double(samples.count) >= Self.minSeconds * 16000 else { return nil }
+ let clip = samples.count > Int(Self.maxSeconds * 16000) ? Array(samples.prefix(Int(Self.maxSeconds * 16000))) : samples
+ var feats = Fbank.compute(clip)
+ let frames = feats.count / Fbank.bins
+ guard frames >= 50 else { return nil }
+ // Mean normalisation per bin over the clip, as in training.
+ for b in 0..<Fbank.bins {
+ var sum: Float = 0
+ for f in 0..<frames { sum += feats[f * Fbank.bins + b] }
+ let mean = sum / Float(frames)
+ for f in 0..<frames { feats[f * Fbank.bins + b] -= mean }
+ }
+ guard let input = try? MLMultiArray(shape: [1, NSNumber(value: frames), NSNumber(value: Fbank.bins)], dataType: .float32) else { return nil }
+ feats.withUnsafeBufferPointer { src in
+ input.withUnsafeMutableBytes { dst, _ in
+ dst.copyMemory(from: UnsafeRawBufferPointer(src))
+ }
+ }
+ guard let out = try? model.prediction(from: MLDictionaryFeatureProvider(dictionary: ["feats": input])),
+ let embs = out.featureValue(for: "embs")?.multiArrayValue else { return nil }
+ var v = (0..<embs.count).map { Float(truncating: embs[$0]) }
+ var norm: Float = 0
+ vDSP_svesq(v, 1, &norm, vDSP_Length(v.count))
+ guard norm > 0 else { return nil }
+ vDSP_vsdiv(v, 1, [norm.squareRoot()], &v, 1, vDSP_Length(v.count))
+ return v
+ }
+}
+
+/// Groups voiceprints as lines arrive, never revising a line already labelled. A line joins the
+/// closest voice when similar enough; a long line unlike every voice starts a new one; anything
+/// else stays unlabelled ("对方"). Tuned on AMI dev meetings.
+struct VoiceClusterer {
+ static let newSeconds = 2.0
+ static let join: Float = 0.5
+ static let startNew: Float = 0.5
+
+ private(set) var sums: [[Float]] = []
+
+ /// The user said two voices are one: later lines like either go to `into`.
+ mutating func merge(_ from: Int, into: Int) {
+ guard sums.indices.contains(from), sums.indices.contains(into), from != into else { return }
+ vDSP_vadd(sums[into], 1, sums[from], 1, &sums[into], 1, vDSP_Length(sums[into].count))
+ sums[from] = [Float](repeating: 0, count: sums[from].count) // never the closest again
+ }
+
+ mutating func label(_ v: [Float], seconds: Double) -> Int? {
+ var best = -1, bestSim: Float = -1
+ for (i, s) in sums.enumerated() {
+ var dot: Float = 0, sq: Float = 0
+ vDSP_dotpr(v, 1, s, 1, &dot, vDSP_Length(v.count))
+ vDSP_svesq(s, 1, &sq, vDSP_Length(s.count))
+ let sim = dot / max(sq.squareRoot(), .ulpOfOne)
+ if sim > bestSim { bestSim = sim; best = i }
+ }
+ if best >= 0, bestSim >= Self.join {
+ vDSP_vadd(sums[best], 1, v, 1, &sums[best], 1, vDSP_Length(v.count))
+ return best
+ }
+ if seconds >= Self.newSeconds, sums.isEmpty || bestSim < Self.startNew {
+ sums.append(v)
+ return sums.count - 1
+ }
+ return nil
+ }
+}
+
+/// What the transcript shows for the other side's lines. A voice gets a number only once it has
+/// `shownAfter` lines, and only when at least two voices have, so a one-to-one call stays "对方".
+/// Numbers follow the order voices reached `shownAfter` lines, so a number never moves once shown.
+enum SpeakerLabels {
+ static let shownAfter = 5
+
+ /// A line long enough to say whose voice it is: three words, or four characters of Chinese or
+ /// Japanese. "Yeah." or a stray "." can make a group of their own; they don't count towards a name.
+ static func substantive(_ text: String) -> Bool {
+ let words = text.split(whereSeparator: { $0.isWhitespace }).filter { $0.contains(where: \.isLetter) }
+ if words.count >= 3 { return true }
+ return text.unicodeScalars.filter { $0.properties.isIdeographic || (0x3040...0x30FF).contains($0.value) || (0xAC00...0xD7A3).contains($0.value) }.count >= 4
+ }
+
+ /// Voice id → 1-based speaker number, for the voices on show.
+ static func voiceNumbers(_ lines: [TranscriptLine]) -> [Int: Int] {
+ var count: [Int: Int] = [:], reached: [Int: Int] = [:]
+ for (i, l) in lines.enumerated() where l.speaker == "them" {
+ guard let v = l.voice, substantive(l.src) else { continue }
+ count[v, default: 0] += 1
+ if count[v] == shownAfter { reached[v] = i }
+ }
+ let shown = reached.keys.sorted { reached[$0]! < reached[$1]! }
+ guard shown.count >= 2 else { return [:] }
+ return Dictionary(uniqueKeysWithValues: shown.enumerated().map { ($1, $0 + 1) })
+ }
+
+ /// Line id → 1-based speaker number; lines without one show as 对方.
+ static func numbers(_ lines: [TranscriptLine]) -> [String: Int] {
+ let number = voiceNumbers(lines)
+ var out: [String: Int] = [:]
+ for l in lines where l.speaker == "them" {
+ if let v = l.voice, let n = number[v] { out[l.id] = n }
+ }
+ return out
+ }
+
+ /// Speaker number → name: the user's, else Ling's guess (unless the user turned it down).
+ static func names(_ s: Session) -> [Int: String] {
+ guard s.voiceNames != nil || s.voiceGuesses != nil else { return [:] }
+ var out: [Int: String] = [:]
+ for (v, n) in voiceNumbers(s.lines) {
+ if let mine = s.voiceNames?[String(v)] {
+ if !mine.isEmpty { out[n] = mine }
+ } else if let g = s.voiceGuesses?[String(v)] {
+ out[n] = g.name
+ }
+ }
+ return out
+ }
+
+ /// Speaker number → Ling's guess, for the voices whose shown name is that guess.
+ static func guessed(_ s: Session) -> [Int: VoiceGuess] {
+ var out: [Int: VoiceGuess] = [:]
+ for (v, n) in voiceNumbers(s.lines) where s.voiceNames?[String(v)] == nil {
+ if let g = s.voiceGuesses?[String(v)] { out[n] = g }
+ }
+ return out
+ }
+
+ /// Lines where the speaker changes: the transcript shows the name there only, as chat apps do.
+ /// Keys: 你, a speaker number, or 未识别 (a voice not on show).
+ static func runStarts(_ lines: [TranscriptLine], _ numbers: [String: Int]) -> Set<String> {
+ var out: Set<String> = [], last: String?
+ for l in lines {
+ let key = l.speaker == "me" ? "me" : numbers[l.id].map { "n\($0)" } ?? "?"
+ if key != last { out.insert(l.id) }
+ last = key
+ }
+ return out
+ }
+
+ /// "George", else "说话人 2".
+ static func label(_ number: Int, _ names: [Int: String]) -> String { names[number] ?? L("说话人 \(number)") }
+
+ /// Distinct voices on show, for the people row.
+ static func shownCount(_ lines: [TranscriptLine]) -> Int { Set(numbers(lines).values).count }
+}
+
+/// Runs voiceprints off the main thread and hands back a voice per line, in arrival order.
+@MainActor
+final class SpeakerTagger {
+ private let queue = DispatchQueue(label: "com.wquguru.cicada.voiceprint", qos: .utility)
+ private nonisolated(unsafe) var model: Voiceprints?
+ private nonisolated(unsafe) var loadFailed = false
+ private nonisolated(unsafe) var clusterer = VoiceClusterer()
+ var onVoice: ((_ lineID: String, _ voice: Int) -> Void)?
+
+ /// A new meeting: forget the voices of the last one.
+ func reset() { queue.async { [self] in clusterer = VoiceClusterer() } }
+
+ func merge(_ from: Int, into: Int) { queue.async { [self] in clusterer.merge(from, into: into) } }
+
+ func tag(lineID: String, samples: [Float]) {
+ let seconds = Double(samples.count) / 16000
+ queue.async { [self] in
+ if model == nil, !loadFailed {
+ do { model = try Voiceprints.load() } catch {
+ loadFailed = true
+ debugLog("voiceprint model failed to load: \(error)")
+ }
+ }
+ guard let model, let v = model.embed(samples), let voice = clusterer.label(v, seconds: seconds) else { return }
+ DispatchQueue.main.async { [weak self] in
+ MainActor.assumeIsolated { self?.onVoice?(lineID, voice) }
+ }
+ }
+ }
+}
+
+// MARK: - Names from the conversation
+
+/// Asks Ling who 说话人 1, 2… are, from how people address each other. Only text is sent; a guess is
+/// a suggestion the user takes or ignores, never applied by itself.
+enum SpeakerNameGuess {
+ /// The transcript as Ling sees it, newest 400 lines, with speaker labels; nil when no voices are shown.
+ static func content(_ s: Session) -> String? {
+ let numbers = SpeakerLabels.numbers(s.lines)
+ guard !numbers.isEmpty else { return nil }
+ let lines = s.lines.suffix(400)
+ var out = "Meeting transcript. Speakers: 你 = the user; 说话人N = one person on the other side, told apart by voice; 对方 = someone on the other side, not identified.\n"
+ for (i, l) in lines.enumerated() {
+ let who = l.speaker == "me" ? "你" : numbers[l.id].map { "说话人\($0)" } ?? "对方"
+ out += "[L\(i + 1) \(TranscriptExport.clock(l.t)) \(who)] \(l.src)\n"
+ }
+ return out
+ }
+
+ static let instruction = """
+ Who are the people labelled 说话人N? Name one only when the transcript makes it clear: they introduce \
+ themselves, or someone addresses them by name and they answer next, or others name them as they speak. \
+ Use the name as written. Leave out anyone you are unsure of. Reply as JSON: \
+ {"speakers": [{"speaker": 2, "name": "George", "evidence": "L12"}]}, with an empty list if none.
+ """
+
+ /// Voice id → guess, with the evidence line quoted ("03:21 “Thanks, George”"). A name Ling gives
+ /// two voices goes to the one with more lines: two people rarely share a name in one meeting.
+ static func parse(_ reply: String, _ s: Session) -> [Int: VoiceGuess] {
+ guard let data = reply.data(using: .utf8),
+ let obj = try? JSONSerialization.jsonObject(with: data) as? [String: Any],
+ let list = obj["speakers"] as? [[String: Any]] else { return [:] }
+ let voiceOf = Dictionary(uniqueKeysWithValues: SpeakerLabels.voiceNumbers(s.lines).map { ($1, $0) })
+ let lines = Array(s.lines.suffix(400))
+ func count(_ v: Int) -> Int { s.lines.filter { $0.voice == v }.count }
+ var out: [Int: VoiceGuess] = [:]
+ for item in list {
+ guard let n = (item["speaker"] as? Int) ?? Int("\(item["speaker"] ?? "")"), let v = voiceOf[n],
+ let name = (item["name"] as? String)?.trimmingCharacters(in: .whitespacesAndNewlines),
+ !name.isEmpty, name.count <= 40 else { continue }
+ if let other = out.first(where: { $0.value.name == name })?.key {
+ if count(other) >= count(v) { continue }
+ out[other] = nil
+ }
+ var evidence = ""
+ if let e = item["evidence"] as? String, let i = Int(e.drop(while: { !$0.isNumber })), lines.indices.contains(i - 1) {
+ let l = lines[i - 1]
+ evidence = "\(TranscriptExport.clock(l.t)) “\(l.src.count > 60 ? String(l.src.prefix(60)) + "…" : l.src)”"
+ }
+ out[v] = VoiceGuess(name: name, evidence: evidence)
+ }
+ return out
+ }
+}
+
+/// The notes window asking the records window to open the editor for one voice.
+struct SpeakerEditRequest: Equatable {
+ let session: String
+ let voice: Int
+}
+
+/// Asks Ling for names on its own: once two voices are on show, again every 20 lines, and once more
+/// when the meeting ends. Guesses go straight into the meeting (`Session.voiceGuesses`); the user corrects.
+@MainActor
+final class SpeakerNamer: ObservableObject {
+ @Published private(set) var busy: Set<String> = []
+ private var askedAt: [String: Int] = [:]
+ private let ling: LingClient
+ private let store: SessionStore
+
+ init(ling: LingClient, store: SessionStore) {
+ self.ling = ling
+ self.store = store
+ }
+
+ var available: Bool { ling.hasKey }
+
+ /// `force`: the meeting just ended, so read it all once more.
+ func guess(_ id: String, force: Bool = false) {
+ guard ling.hasKey, !busy.contains(id), let s = store.session(id) else { return }
+ guard force || s.lines.count >= (askedAt[id] ?? -1000) + 20, let content = SpeakerNameGuess.content(s) else { return }
+ // Everyone already has a name the user gave: nothing to ask.
+ let numbers = SpeakerLabels.voiceNumbers(s.lines)
+ if numbers.keys.allSatisfy({ s.voiceNames?[String($0)] != nil }) { return }
+ busy.insert(id)
+ askedAt[id] = s.lines.count
+ Task {
+ defer { busy.remove(id) }
+ do {
+ let reply = try await ling.chat(content: content, instruction: SpeakerNameGuess.instruction,
+ priority: .notes, json: true, maxTokens: 300)
+ let found = SpeakerNameGuess.parse(reply, s)
+ store.setVoiceGuesses(id, found)
+ debugLog("speaker names: \(found.count) found for \(id)")
+ } catch {
+ debugLog("speaker names: ling failed \(error)")
+ }
+ }
+ }
+}
+
+// MARK: - Views
+
+/// Colours for 说话人 1, 2, 3…, cycling after four: not the accent ("live", and 你) nor link blue
+/// (times in the records window), distinct in lightness, all ≥ 4.5:1 on white.
+enum SpeakerColor {
+ private static let inks: [Color] = [Color(red: 0.059, green: 0.482, blue: 0.424), Color(red: 0.478, green: 0.298, blue: 0.761),
+ Color(red: 0.690, green: 0.227, blue: 0.478), Color(red: 0.541, green: 0.353, blue: 0)]
+ static func ink(_ n: Int) -> Color { inks[(n - 1) % inks.count] }
+}
+
+/// "说话人 2" above a line.
+/// The names given to voices in the meeting on show, by speaker number (set on the transcript's container).
+private struct SpeakerNamesKey: EnvironmentKey { static let defaultValue: [Int: String] = [:] }
+extension EnvironmentValues {
+ var speakerNames: [Int: String] {
+ get { self[SpeakerNamesKey.self] }
+ set { self[SpeakerNamesKey.self] = newValue }
+ }
+}
+
+struct SpeakerTag: View {
+ let number: Int
+ @Environment(\.speakerNames) private var names
+ var body: some View {
+ HStack(spacing: 5) {
+ Circle().fill(SpeakerColor.ink(number)).frame(width: 6, height: 6)
+ Text(SpeakerLabels.label(number, names)).font(.system(size: 11, weight: .semibold)).foregroundStyle(SpeakerColor.ink(number))
+ }
+ }
+}
+
+/// A line from the other side whose voice isn't one of the people on show.
+struct UnknownSpeakerTag: View {
+ var body: some View {
+ HStack(spacing: 5) {
+ Circle().strokeBorder(Palette.tertiary, lineWidth: 1).frame(width: 6, height: 6)
+ Text("未识别").font(.system(size: 11, weight: .semibold)).foregroundStyle(Palette.tertiary)
+ }
+ .help(L("没认出是谁:太短,或和已知的声音都不像"))
+ }
+}
+
+/// The small orange "实验" mark on experimental features.
+struct ExperimentBadge: View {
+ var body: some View {
+ Text("实验").font(.system(size: 10, weight: .semibold)).foregroundStyle(Palette.accentInk)
+ .padding(.horizontal, 5).padding(.vertical, 1)
+ .background(RoundedRectangle(cornerRadius: 4).fill(Palette.accentPale))
+ }
+}
+
+/// Above the transcript once voices are told apart: who is speaking, that it's an experiment, and a
+/// one-click way out. Each person opens `SpeakerEditor`: in the records window right there; the notes
+/// window never takes focus, so there it opens the records window instead (`edit`).
+struct SpeakerStrip: View {
+ @ObservedObject var model: AppModel
+ let session: Session
+ /// Set in the notes window: a click hands the voice over instead of editing in place.
+ var edit: ((Int) -> Void)? = nil
+ @State private var editing: Int?
+
+ var body: some View {
+ let numbers = SpeakerLabels.voiceNumbers(session.lines)
+ let names = SpeakerLabels.names(session)
+ HStack(alignment: .top, spacing: 8) {
+ FlowLayout(spacing: 6) {
+ ForEach(numbers.sorted { $0.value < $1.value }, id: \.key) { voice, n in
+ Button { if let edit { edit(voice) } else { editing = voice } } label: {
+ HStack(spacing: 5) {
+ Circle().fill(SpeakerColor.ink(n)).frame(width: 6, height: 6)
+ Text(SpeakerLabels.label(n, names)).font(.system(size: 11, weight: .semibold)).foregroundStyle(SpeakerColor.ink(n))
+ }
+ .fixedSize()
+ .padding(.horizontal, 8).frame(height: 22)
+ .background(Capsule().fill(SpeakerColor.ink(n).opacity(0.08)))
+ .contentShape(Capsule())
+ }
+ .buttonStyle(.plain)
+ .help(SpeakerLabels.guessed(session)[n].map { _ in L("Ling 从对话里认出,点一下可以改") } ?? L("改名字,或和别人合并"))
+ .popover(isPresented: Binding(get: { editing == voice }, set: { if !$0 { editing = nil } }), arrowEdge: .bottom) {
+ SpeakerEditor(model: model, namer: model.speakerNamer, sessionID: session.id, voice: voice) { editing = nil }
+ }
+ }
+ ExperimentBadge().frame(height: 22)
+ }
+ Spacer(minLength: 0)
+ Button { model.settings.speakerVoices = false } label: {
+ Text("不准?关掉").font(.system(size: 11)).foregroundStyle(Palette.secondary).underline().fixedSize()
+ }
+ .buttonStyle(.plain)
+ .frame(height: 22)
+ .help(L("关掉说话人识别,记录里的名字一起收起"))
+ }
+ .onAppear {
+ openRequested()
+ model.speakerNamer.guess(session.id)
+ }
+ .onChange(of: model.speakerEdit) { _, _ in openRequested() }
+ }
+
+ /// The notes window asked to edit a voice of this meeting.
+ private func openRequested() {
+ guard edit == nil, let req = model.speakerEdit, req.session == session.id else { return }
+ model.speakerEdit = nil
+ DispatchQueue.main.async { editing = req.voice }
+ }
+}
+
+/// Correct one voice: its name (Ling's guess is already filled in), or merge it into another voice.
+struct SpeakerEditor: View {
+ @ObservedObject var model: AppModel
+ @ObservedObject var namer: SpeakerNamer
+ let sessionID: String
+ let voice: Int
+ let close: () -> Void
+ @State private var draft = ""
+
+ private var session: Session? { model.store.session(sessionID) }
+
+ var body: some View {
+ if let s = session {
+ let numbers = SpeakerLabels.voiceNumbers(s.lines)
+ let names = SpeakerLabels.names(s)
+ let n = numbers[voice] ?? 0
+ let guess = SpeakerLabels.guessed(s)[n]
+ VStack(alignment: .leading, spacing: 12) {
+ HStack(spacing: 6) {
+ Circle().fill(SpeakerColor.ink(n)).frame(width: 8, height: 8)
+ Text(SpeakerLabels.label(n, names)).font(.system(size: 14, weight: .bold))
+ Spacer()
+ Text("说了 \(s.lines.filter { $0.voice == voice }.count) 句").font(.system(size: 11)).foregroundStyle(Palette.tertiary)
+ }
+ VStack(alignment: .leading, spacing: 5) {
+ Text("名字").font(.system(size: 11, weight: .semibold)).foregroundStyle(Palette.secondary)
+ TextField(L("输入名字"), text: $draft).textFieldStyle(.roundedBorder).onSubmit { save(s, guess) }
+ if let guess {
+ HStack(alignment: .top, spacing: 8) {
+ Text(guess.evidence.isEmpty ? L("Ling 从对话里认出") : L("Ling 从对话里认出:\(guess.evidence)"))
+ .font(.system(size: 11)).foregroundStyle(Palette.tertiary).lineLimit(2)
+ Spacer(minLength: 6)
+ Button(L("不是 TA")) {
+ model.store.setVoiceName(s.id, voice: voice, "")
+ close()
+ }
+ .buttonStyle(.plain).font(.system(size: 11)).foregroundStyle(Palette.secondary)
+ }
+ } else if namer.busy.contains(s.id) {
+ Text("Ling 正在从对话里找名字…").font(.system(size: 11)).foregroundStyle(Palette.tertiary)
+ }
+ }
+ let others = numbers.filter { $0.key != voice }.sorted { $0.value < $1.value }
+ if !others.isEmpty {
+ VStack(alignment: .leading, spacing: 6) {
+ Text("其实是同一个人").font(.system(size: 11, weight: .semibold)).foregroundStyle(Palette.secondary)
+ HStack(spacing: 6) {
+ ForEach(others, id: \.key) { other, on in
+ SoftButton(L("并入 \(SpeakerLabels.label(on, names))")) {
+ model.store.mergeVoice(s.id, voice, into: other)
+ if s.id == model.store.liveID { model.speakers.merge(voice, into: other) }
+ close()
+ }
+ }
+ }
+ }
+ }
+ HStack(spacing: 8) {
+ Spacer()
+ SoftButton(L("取消")) { close() }
+ SoftButton(L("完成"), dark: true) { save(s, guess) }
+ }
+ }
+ .padding(16)
+ .frame(width: 320)
+ .onAppear { draft = names[n] ?? "" }
+ }
+ }
+
+ /// Keeping Ling's name stores nothing, so a later, better guess can still replace it.
+ private func save(_ s: Session, _ guess: VoiceGuess?) {
+ let name = draft.trimmingCharacters(in: .whitespacesAndNewlines)
+ if let guess, name == guess.name { model.store.setVoiceName(s.id, voice: voice, nil) }
+ else if s.voiceNames?[String(voice)] != nil || !name.isEmpty { model.store.setVoiceName(s.id, voice: voice, name) }
+ close()
+ }
+}
+
+/// Debug render (`speakersRender`): the people row and the first lines, labelled as the transcript
+/// labels them (a name only where the speaker changes).
+struct SpeakerPreview: View {
+ @ObservedObject var model: AppModel
+ let session: Session
+ var body: some View {
+ let numbers = SpeakerLabels.numbers(session.lines)
+ let starts = SpeakerLabels.runStarts(session.lines, numbers)
+ VStack(alignment: .leading, spacing: 10) {
+ if !numbers.isEmpty { SpeakerStrip(model: model, session: session) }
+ ForEach(session.lines.prefix(12)) { l in
+ VStack(alignment: .leading, spacing: 3) {
+ if !starts.contains(l.id) {
+ } else if l.speaker == "me" { Text("你").font(.system(size: 11, weight: .semibold)).foregroundStyle(Palette.accentInk) }
+ else if let n = numbers[l.id] { SpeakerTag(number: n) }
+ else if !numbers.isEmpty { UnknownSpeakerTag() }
+ Text(l.src).font(.system(size: 13)).foregroundStyle(Palette.ink)
+ }
+ }
+ }
+ .padding(16)
+ }
+}
diff --git a/Sources/LiveSubs/Views.swift b/Sources/LiveSubs/Views.swift
index aa9c7bb..0b0c7b1 100644
--- a/Sources/LiveSubs/Views.swift
+++ b/Sources/LiveSubs/Views.swift
@@ -7,6 +7,13 @@ enum Palette {
static let line = Color(red: 0.894, green: 0.902, blue: 0.918)
static let secondary = Color(red: 0.353, green: 0.373, blue: 0.42)
static let tertiary = Color(red: 0.42, green: 0.44, blue: 0.50)
+ /// Body text in the records window: darker than the greys, lighter than headings.
+ static let body = Color(red: 0.239, green: 0.255, blue: 0.29)
+ /// Times you can click to jump to the original, and the numbers that order notes: the logo's
+ /// orange as ink, so text stays in the brand's family while the bright accent stays "live".
+ static let link = Color(red: 0.70, green: 0.23, blue: 0.08)
+ /// Highlighter behind numbers and dates in the conclusions.
+ static let mark = Color(red: 1.0, green: 0.906, blue: 0.639)
static let accent = Color(red: 0.91, green: 0.33, blue: 0.17)
static let accentInk = Color(red: 0.70, green: 0.23, blue: 0.08)
static let accentPale = Color(red: 0.99, green: 0.93, blue: 0.906)
@@ -92,16 +99,6 @@ struct MenuPanelView: View {
}
}
- @ViewBuilder private var holdKey: some View {
- Text("按住").foregroundStyle(Palette.secondary)
- KeyCap(settings.talkKey.display)
- }
-
- private var speakRoute: some View {
- Text("说\(settings.speakFromLang.name) → \(targetName(model.speak.targetCode))")
- .foregroundStyle(Palette.secondary).lineLimit(1).fixedSize()
- }
-
var body: some View {
VStack(alignment: .leading, spacing: 16) {
HStack(spacing: 12) {
@@ -153,38 +150,7 @@ struct MenuPanelView: View {
Divider()
- HStack(alignment: .top, spacing: 12) {
- VStack(alignment: .leading, spacing: 4) {
- Text("同声传译").font(.system(size: 14, weight: .semibold)).foregroundStyle(Palette.ink)
- // The languages drop to their own line when the row is too narrow (English, "Right ⌥").
- ViewThatFits(in: .horizontal) {
- HStack(spacing: 5) { holdKey; speakRoute }
- VStack(alignment: .leading, spacing: 4) { HStack(spacing: 5) { holdKey }; speakRoute }
- }
- .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)
- }
- } 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()
- HStack(spacing: 8) {
- speakMenu
- Toggle("同声传译", isOn: Binding(get: { settings.speakEnabled }, set: { model.enableSpeaking($0) }))
- .toggleStyle(.switch).labelsHidden().tint(Palette.ink)
- }
- }
+ speakSection
if let strip = systemMicStrip {
HStack(spacing: 10) {
VStack(alignment: .leading, spacing: 2) {
@@ -197,24 +163,6 @@ struct MenuPanelView: View {
.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 {
- 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)
- Spacer()
- SoftButton(L("设置")) { model.openSettings(.speak) }
- }
- .padding(10).frame(maxWidth: .infinity, alignment: .leading)
- .background(RoundedRectangle(cornerRadius: 9).fill(Palette.accentPale))
- }
Divider()
@@ -327,31 +275,6 @@ 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 {
@@ -365,6 +288,180 @@ extension MenuPanelView {
}
}
+// MARK: - 同声传译 in the panel
+
+extension MenuPanelView {
+ private var speakFrom: String { settings.speakFromLang.name }
+ private var speakTarget: String { targetName(model.speak.targetCode) }
+ private var talkKeyName: String { settings.talkKey.display }
+
+ /// What the switch changes, on hover and in the one-time question.
+ private var speakMicLine: String {
+ guard let mic = model.virtualMic?.name else { return L("先装好虚拟麦克风,对方才听得到") }
+ return settings.autoSystemMic ? L("系统麦克风换成 \(mic)") : L("译文送进 \(mic)")
+ }
+
+ private var speakHelp: String {
+ L("打开:\(speakMicLine),按住 \(talkKeyName) 说话\n关掉:全部还原")
+ }
+
+ /// 同声传译: the first time the switch asks in place what it changes; once on, the talk key is
+ /// the section, and whatever stops the room hearing you shows on it.
+ var speakSection: some View {
+ VStack(alignment: .leading, spacing: 12) {
+ HStack(spacing: 12) {
+ VStack(alignment: .leading, spacing: 3) {
+ Text("同声传译").font(.system(size: 14, weight: .semibold)).foregroundStyle(Palette.ink)
+ if !settings.speakEnabled && !model.speakAsking {
+ Text("说\(speakFrom) → \(speakTarget)").font(.system(size: 12))
+ .foregroundStyle(Palette.secondary).lineLimit(1)
+ }
+ }
+ Spacer(minLength: 8)
+ if settings.speakEnabled {
+ Button("设置") { model.openSettings(.speak) }
+ .buttonStyle(.plain).font(.system(size: 12)).foregroundStyle(Palette.tertiary)
+ }
+ Toggle("同声传译", isOn: Binding(get: { settings.speakEnabled || model.speakAsking }, set: setSpeaking))
+ .toggleStyle(.switch).labelsHidden()
+ .tint(model.speakAsking ? Palette.tertiary : Palette.ink)
+ .help(speakHelp)
+ }
+ if model.speakAsking {
+ speakQuestion
+ } else if settings.speakEnabled {
+ talkCard
+ if model.lastSpeakLatency == nil, model.virtualMic != nil, model.speakPhase == .idle {
+ Button("先试一句 →") { model.openSettings(.speak); model.speakTestShown = true }
+ .buttonStyle(.plain).font(.system(size: 12)).foregroundStyle(Palette.secondary)
+ }
+ }
+ }
+ }
+
+ private func setSpeaking(_ on: Bool) {
+ if on && !settings.speakConfirmed { model.speakAsking = true; return }
+ model.speakAsking = false
+ if on != settings.speakEnabled { model.enableSpeaking(on) }
+ }
+
+ /// Asked once: switching the system mic is a change people should hear about before it happens.
+ private var speakQuestion: some View {
+ VStack(alignment: .leading, spacing: 10) {
+ Text("打开后:").font(.system(size: 13, weight: .semibold)).foregroundStyle(Palette.ink)
+ questionLine(1) { Text(speakMicLine) }
+ questionLine(2) {
+ ViewThatFits(in: .horizontal) {
+ HStack(spacing: 4) { Text("按住"); KeyCap(talkKeyName); Text("说话,松开后播出译文") }
+ VStack(alignment: .leading, spacing: 4) {
+ HStack(spacing: 4) { Text("按住"); KeyCap(talkKeyName) }
+ Text("说话,松开后播出译文")
+ }
+ }
+ }
+ questionLine(3) { Text("关掉后全部还原") }
+ HStack(spacing: 8) {
+ Spacer()
+ SoftButton(L("取消"), onGrey: true) { model.speakAsking = false }
+ SoftButton(L("好,打开"), dark: true) { model.speakAsking = false; model.enableSpeaking(true) }
+ }
+ .padding(.top, 2)
+ }
+ .padding(14)
+ .frame(maxWidth: .infinity, alignment: .leading)
+ .background(RoundedRectangle(cornerRadius: 11).fill(Palette.ground))
+ }
+
+ private func questionLine<C: View>(_ n: Int, @ViewBuilder _ content: () -> C) -> some View {
+ HStack(alignment: .firstTextBaseline, spacing: 8) {
+ Text("\(n)").foregroundStyle(Palette.tertiary).frame(width: 12, alignment: .leading)
+ content().foregroundStyle(Palette.ink).fixedSize(horizontal: false, vertical: true)
+ }
+ .font(.system(size: 12))
+ }
+
+ /// The first thing keeping the room from hearing you, with the one action that fixes it.
+ private var talkProblem: (text: String, button: String, action: () -> Void)? {
+ if model.talkNeedsPermission {
+ return (L("按键还需要“输入监控”权限"), L("去允许"), model.allowTalkKey)
+ }
+ if model.virtualMic == nil {
+ return (L("虚拟麦克风还没装好"), L("设置"), { model.openSettings(.speak) })
+ }
+ if let user = model.micUsers.first(where: { $0.state.isOther }) {
+ let text: String
+ if case .otherMic(let mic) = user.state, !mic.isEmpty { text = L("\(user.name)还在用 \(mic)") }
+ else { text = L("\(user.name)没选虚拟麦克风") }
+ return (text, L("怎么改"), { model.showMicGuide(user) })
+ }
+ return nil
+ }
+
+ private var talkCard: some View {
+ let phase = model.speakPhase
+ let live = phase != .idle
+ let problem = live ? nil : talkProblem
+ let title: String = switch phase {
+ case .idle: L("按住说\(speakFrom)")
+ case .listening: L("正在听…")
+ case .translating: L("正在翻译…")
+ case .speaking: L("正在播出…")
+ }
+ let hearer = model.micUsers.first { $0.state == .virtualMic }?.name
+ let detail = phase == .listening ? L("松开后播出\(speakTarget)")
+ : live ? L("说\(speakFrom) → \(speakTarget)")
+ : hearer.map { L("对方听到 \(speakTarget) · \($0)") } ?? L("对方听到 \(speakTarget)")
+ return HStack(spacing: 12) {
+ TalkKeyCap(text: talkKeyName, pressed: phase == .listening, live: live)
+ VStack(alignment: .leading, spacing: 3) {
+ Text(title).font(.system(size: 13, weight: .semibold))
+ .foregroundStyle(live ? Palette.accentInk : Palette.ink).lineLimit(1)
+ if let problem {
+ HStack(alignment: .firstTextBaseline, spacing: 6) {
+ Text(problem.text).foregroundStyle(Palette.accentInk)
+ .fixedSize(horizontal: false, vertical: true)
+ Button(problem.button, action: problem.action)
+ .buttonStyle(.plain).fontWeight(.semibold).foregroundStyle(Palette.accentInk).fixedSize()
+ }
+ .font(.system(size: 11))
+ } else {
+ Text(detail).font(.system(size: 11)).foregroundStyle(Palette.secondary).lineLimit(2)
+ .fixedSize(horizontal: false, vertical: true)
+ }
+ }
+ Spacer(minLength: 4)
+ if !live {
+ Circle().fill(problem == nil ? Palette.ok : Palette.accent).frame(width: 7, height: 7)
+ }
+ }
+ .padding(.horizontal, 14).padding(.vertical, 12)
+ .frame(maxWidth: .infinity, alignment: .leading)
+ .background(RoundedRectangle(cornerRadius: 11).fill(live ? Palette.accentWash : Color.white))
+ .overlay(RoundedRectangle(cornerRadius: 11).stroke(live ? Palette.accent : Palette.line, lineWidth: 1))
+ .animation(.easeOut(duration: 0.15), value: live)
+ }
+}
+
+/// The talk key drawn as a key: raised while it waits, pressed down while you hold it.
+struct TalkKeyCap: View {
+ let text: String
+ let pressed: Bool
+ let live: Bool
+ var body: some View {
+ Text(text)
+ .font(.system(size: 12, weight: .bold))
+ .foregroundStyle(live ? Palette.accentInk : Palette.ink)
+ .lineLimit(1).fixedSize()
+ .padding(.horizontal, 8)
+ .frame(minWidth: 44, minHeight: 32)
+ .background(RoundedRectangle(cornerRadius: 7).fill(Color.white))
+ .overlay(RoundedRectangle(cornerRadius: 7).stroke(live ? Palette.accent : Color(white: 0.82), lineWidth: 1))
+ .background(RoundedRectangle(cornerRadius: 7).fill(live ? Palette.accent : Color(white: 0.82)).offset(y: pressed ? 0 : 2))
+ .offset(y: pressed ? 2 : 0)
+ .padding(.bottom, 2)
+ }
+}
+
/// One of 实时纪要 / 字幕条 / 不显示 in the menu bar panel: a small picture of what shows on screen.
struct DisplayTile: View {
static let modes = ["notes", "bar", "none"]
@@ -809,16 +906,17 @@ struct MainWindowView: View {
HStack(spacing: 8) {
if live { Tag(L("正在记录"), live: true) }
Text([dateText(s.startedAt, "MMMdHHmm"), Self.length(s)].joined(separator: " · "))
- .font(.system(size: 12).monospacedDigit()).foregroundStyle(Palette.secondary).lineLimit(1)
+ .font(.system(size: 12).monospacedDigit()).foregroundStyle(Palette.tertiary).lineLimit(1)
.help(([dateLine(s, live: live)] + more.compactMap { $0 }).joined(separator: " · "))
}
TextField("标题", text: Binding(
- get: { titleDraft.isEmpty ? s.displayTitle : titleDraft },
+ // The date is on the line above; a notes title that starts with it shows without.
+ get: { titleDraft.isEmpty ? Self.listTitle(s) : titleDraft },
set: { titleDraft = $0 }
), axis: .vertical)
.textFieldStyle(.plain)
- .font(.system(size: 30, weight: .bold))
- .padding(.top, 10)
+ .font(.system(size: 26, weight: .semibold))
+ .padding(.top, 8)
.onSubmit {
if !titleDraft.isEmpty { store.rename(s.id, to: titleDraft) }
titleDraft = ""
@@ -840,10 +938,14 @@ struct MainWindowView: View {
.buttonStyle(.plain).font(.system(size: 12)).foregroundStyle(Palette.secondary)
}
.padding(.bottom, 8)
+ let speakers = settings.speakerVoices ? SpeakerLabels.numbers(s.lines) : [:]
+ let starts = SpeakerLabels.runStarts(s.lines, speakers)
ForEach(s.lines) { l in
- quoteRow(l, picked: quoteJump.map { t in l.id == pickedLine(s, t)?.id } ?? false).id(l.id)
+ quoteRow(l, speaker: speakers[l.id], picked: quoteJump.map { t in l.id == pickedLine(s, t)?.id } ?? false,
+ label: starts.contains(l.id), voices: !speakers.isEmpty).id(l.id)
}
}
+ .environment(\.speakerNames, SpeakerLabels.names(s))
.padding(.vertical, 40)
}
.scrollIndicators(.never)
@@ -865,8 +967,16 @@ struct MainWindowView: View {
}
/// Whitespace between lines, no rules; the picked line gets a soft fill.
- private func quoteRow(_ l: TranscriptLine, picked: Bool) -> some View {
+ private func quoteRow(_ l: TranscriptLine, speaker: Int?, picked: Bool, label: Bool = true, voices: Bool = false) -> some View {
VStack(alignment: .leading, spacing: 2) {
+ // Only once voices are told apart (or for your own lines): one speaker needs no label;
+ // and only where the speaker changes.
+ if !label {
+ } else if let speaker { SpeakerTag(number: speaker).padding(.bottom, 2) }
+ else if voices, l.speaker != "me" { UnknownSpeakerTag().padding(.bottom, 2) }
+ else if l.speaker == "me" {
+ Text("你").font(.system(size: 11, weight: .semibold)).foregroundStyle(Palette.accentInk).padding(.bottom, 2)
+ }
Text(l.src).font(.system(size: 12)).foregroundStyle(Palette.secondary).lineSpacing(1)
.textSelection(.enabled)
Text(l.dst ?? L("翻译中…")).font(.system(size: 14)).lineSpacing(2)
@@ -891,8 +1001,14 @@ struct MainWindowView: View {
ScrollView {
LazyVStack(alignment: .leading, spacing: 0) {
header(s).padding(.bottom, 16)
- ForEach(s.lines) { l in lineRow(l).id(l.id) }
+ let speakers = settings.speakerVoices ? SpeakerLabels.numbers(s.lines) : [:]
+ if !speakers.isEmpty { SpeakerStrip(model: model, session: s).padding(.bottom, 8) }
+ let starts = SpeakerLabels.runStarts(s.lines, speakers)
+ ForEach(s.lines) { l in
+ lineRow(l, speaker: speakers[l.id], label: speakers.isEmpty || starts.contains(l.id), voices: !speakers.isEmpty).id(l.id)
+ }
}
+ .environment(\.speakerNames, SpeakerLabels.names(s))
.frame(maxWidth: 680)
.padding(.horizontal, 40).padding(.vertical, 36)
.frame(maxWidth: .infinity)
@@ -909,15 +1025,20 @@ struct MainWindowView: View {
}
}
- private func lineRow(_ l: TranscriptLine) -> some View {
+ private func lineRow(_ l: TranscriptLine, speaker: Int? = nil, label: Bool = true, voices: Bool = false) -> some View {
let me = l.speaker == "me"
return HStack(alignment: .top, spacing: 16) {
Text(TranscriptExport.clock(l.t))
.font(.system(size: 12).monospacedDigit()).foregroundStyle(Palette.tertiary)
.frame(width: 52, alignment: .leading).padding(.top, 1)
VStack(alignment: .leading, spacing: 5) {
- Text(me ? L("你") : L("对方")).font(.system(size: 11, weight: .semibold))
- .foregroundStyle(me ? Palette.accentInk : Palette.secondary)
+ if !label {
+ } else if let speaker { SpeakerTag(number: speaker) }
+ else if voices, !me { UnknownSpeakerTag() }
+ else {
+ Text(me ? L("你") : L("对方")).font(.system(size: 11, weight: .semibold))
+ .foregroundStyle(me ? Palette.accentInk : Palette.secondary)
+ }
if view != "dst" {
Text(l.src)
.font(.system(size: view == "src" ? 15 : 13))
diff --git a/Sources/LiveSubs/VoicePicker.swift b/Sources/LiveSubs/VoicePicker.swift
index d0f36e9..dd3fe04 100644
--- a/Sources/LiveSubs/VoicePicker.swift
+++ b/Sources/LiveSubs/VoicePicker.swift
@@ -22,20 +22,13 @@ struct VoiceSection: View {
var body: some View {
VStack(alignment: .leading, spacing: 0) {
+ // The language is its own row above: this row is only the voice.
HStack(spacing: 12) {
- StepMark(done: true, number: 3)
- VStack(alignment: .leading, spacing: 2) {
- Text("对方听到").font(.system(size: 13, weight: .semibold)).foregroundStyle(Palette.ink)
- // One line of prose with the link inside, so it wraps instead of truncating in English.
- Text(route)
- .font(.system(size: 11)).foregroundStyle(Palette.tertiary).tint(Palette.secondary)
- .fixedSize(horizontal: false, vertical: true)
- .environment(\.openURL, OpenURLAction { _ in model.settingsSection = .language; return .handled })
- }
+ Text("声音").font(.system(size: 13)).foregroundStyle(Palette.ink)
Spacer(minLength: 8)
chip
}
- .padding(.horizontal, 16).padding(.vertical, 12)
+ .padding(.horizontal, 16).padding(.vertical, 8).frame(minHeight: 46)
if !ling.usable { keyNudge }
if model.voicePickerOpen { picker.padding(.horizontal, 16).padding(.bottom, 14) }
}
@@ -50,16 +43,6 @@ struct VoiceSection: View {
}
}
- /// No-break spaces keep "· 改语言" with the language before it when the line wraps.
- private var route: AttributedString {
- var text = AttributedString(L("你说\(settings.speakFromLang.name),对方听到\(targetName(model.speak.targetCode))") + "\u{00A0}·\u{00A0}")
- var link = AttributedString(L("改语言"))
- link.link = URL(string: "cicada-settings:language")
- link.underlineStyle = .single
- text.append(link)
- return text
- }
-
// MARK: Chip
private var roomOption: VoiceOption? {
@@ -111,7 +94,7 @@ struct VoiceSection: View {
}
.padding(.horizontal, 12).padding(.vertical, 9)
.background(RoundedRectangle(cornerRadius: 9).fill(Palette.raised))
- .padding(.leading, 50).padding(.trailing, 16).padding(.bottom, 12)
+ .padding(.horizontal, 16).padding(.bottom, 12)
}
// MARK: Picker
@@ -257,23 +240,6 @@ struct Radio: View {
}
}
-/// The numbered circle of a setup step: a check once done.
-struct StepMark: View {
- let done: Bool
- let number: Int
- var body: some View {
- ZStack {
- Circle().fill(done ? Palette.ink : Palette.accentPale)
- if done {
- Image(systemName: "checkmark").font(.system(size: 10, weight: .bold)).foregroundStyle(.white)
- } else {
- Text("\(number)").font(.system(size: 11, weight: .bold)).foregroundStyle(Palette.accentInk)
- }
- }
- .frame(width: 22, height: 22)
- }
-}
-
// MARK: - Recording sheet
/// Read a passage for 15 s → transcribe it on this Mac → listen to the original and to the clone
diff --git a/Tests/LiveSubsTests/MeetingEndTests.swift b/Tests/LiveSubsTests/MeetingEndTests.swift
index 4a1a6bb..5ef366c 100644
--- a/Tests/LiveSubsTests/MeetingEndTests.swift
+++ b/Tests/LiveSubsTests/MeetingEndTests.swift
@@ -86,10 +86,25 @@ import Testing
#expect(plain.pending?.reason == .silence)
}
+ @Test func nothingSaidStopsQuietlyAfterTheSilence() {
+ var w = watch()
+ #expect(w.tick(at: at(599), calls: [:], said: false) == nil)
+ #expect(w.tick(at: at(600), calls: [:], said: false) == .nobodySpoke)
+ #expect(w.pending == nil)
+ // Even when silence only prompts: there is nothing to keep, so no countdown.
+ var e = watch(.end)
+ #expect(e.tick(at: at(600), calls: [:], said: false) == .nobodySpoke)
+ // Off, or a meeting app in a call (a muted webinar), keeps listening.
+ var off = watch(.off)
+ #expect(off.tick(at: at(5_000), calls: [:], said: false) == nil)
+ var call = watch()
+ #expect(call.tick(at: at(5_000), calls: zoom, said: false) == nil)
+ }
+
@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.tick(at: at(500), 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))
diff --git a/Tests/LiveSubsTests/MicUsersTests.swift b/Tests/LiveSubsTests/MicUsersTests.swift
index 7dbe1cc..9cdf97e 100644
--- a/Tests/LiveSubsTests/MicUsersTests.swift
+++ b/Tests/LiveSubsTests/MicUsersTests.swift
@@ -38,4 +38,13 @@ import Testing
virtualMic: virtual, deviceName: { names[$0] }, ownBundleID: "com.wquguru.cicada")
#expect(users == [MicUser(bundleID: "com.google.Chrome", name: "Google Chrome", state: .virtualMic)])
}
+
+ @Test func applesOwnMicReadersAreNotMeetings() {
+ let users = MicUsers.merge(
+ readers: [.init(bundleID: "com.apple.Sound-Settings.extension", inputs: [builtIn]),
+ .init(bundleID: "com.apple.FaceTime", inputs: [builtIn])],
+ running: ["com.apple.Sound-Settings.extension": "Sound (System Settings)", "com.apple.FaceTime": "FaceTime"],
+ virtualMic: virtual, deviceName: { names[$0] }, ownBundleID: "com.wquguru.cicada")
+ #expect(users.map(\.name) == ["FaceTime"])
+ }
}
diff --git a/Tests/LiveSubsTests/SpeakerTests.swift b/Tests/LiveSubsTests/SpeakerTests.swift
new file mode 100644
index 0000000..6cb93c9
--- /dev/null
+++ b/Tests/LiveSubsTests/SpeakerTests.swift
@@ -0,0 +1,146 @@
+import Foundation
+import Testing
+@testable import LiveSubs
+
+@Suite struct SpeakerTests {
+ /// 1 s of two tones plus a deterministic ripple; reference values from
+ /// torchaudio.compliance.kaldi.fbank(x * 32768, num_mel_bins=80, dither=0).
+ private var signal: [Float] {
+ (0..<16000).map { n in
+ let t = Double(n) / 16000
+ return Float(0.3 * sin(2 * .pi * 220 * t) + 0.1 * sin(2 * .pi * 1234 * t)
+ + 0.05 * (Double((n * 7919) % 1000) / 1000 - 0.5))
+ }
+ }
+
+ @Test func fbankMatchesKaldi() {
+ let f = Fbank.compute(signal)
+ #expect(f.count == 98 * 80)
+ let expected: [(frame: Int, bins: [Float])] = [(0, [14.668, 16.6069, 12.7853, 20.1031]),
+ (97, [13.7549, 16.6393, 14.6429, 20.1246])]
+ for e in expected {
+ for (b, v) in zip([0, 10, 40, 79], e.bins) {
+ #expect(abs(f[e.frame * 80 + b] - v) < 0.01, "frame \(e.frame) bin \(b): \(f[e.frame * 80 + b]) vs \(v)")
+ }
+ }
+ #expect(abs(f.reduce(0, +) / Float(f.count) - 16.1517) < 0.01)
+ }
+
+ private func unit(_ i: Int, noise: Float = 0) -> [Float] {
+ var v = [Float](repeating: noise, count: 256)
+ v[i] = 1
+ let n = v.map { $0 * $0 }.reduce(0, +).squareRoot()
+ return v.map { $0 / n }
+ }
+
+ @Test func clustererJoinsStartsAndAbstains() {
+ var c = VoiceClusterer()
+ #expect(c.label(unit(0), seconds: 3) == 0)
+ #expect(c.label(unit(0, noise: 0.02), seconds: 1) == 0) // similar: joins
+ #expect(c.label(unit(1), seconds: 1) == nil) // new voice, too short to start one
+ #expect(c.label(unit(1), seconds: 2.5) == 1) // long enough: a new voice
+ #expect(c.sums.count == 2)
+ }
+
+ private func line(_ id: Int, _ voice: Int?, me: Bool = false) -> TranscriptLine {
+ TranscriptLine(id: "l\(id)", t: Double(id), speaker: me ? "me" : "them", src: "a full line", dst: nil,
+ srcLang: "en", dstLang: "zh-CN", voice: voice)
+ }
+
+ @Test func oneOtherVoiceStaysUnnamed() {
+ let lines = (0..<12).map { line($0, 7) } + (12..<16).map { line($0, nil, me: true) }
+ #expect(SpeakerLabels.numbers(lines).isEmpty)
+ }
+
+ @Test func voicesNamedOnceTwoHaveEnoughLines() {
+ // Voice 9 speaks first, then 4; voice 2 has only four lines and stays 对方.
+ var lines = (0..<5).map { line($0, 9) } + (5..<10).map { line($0, 4) } + (10..<14).map { line($0, 2) }
+ lines.append(line(14, nil))
+ let n = SpeakerLabels.numbers(lines)
+ #expect(n["l0"] == 1 && n["l4"] == 1)
+ #expect(n["l5"] == 2)
+ #expect(n["l10"] == nil && n["l14"] == nil)
+ #expect(SpeakerLabels.shownCount(lines) == 2)
+ // A voice that spoke first but reached five lines later doesn't take an earlier number.
+ let late = [line(0, 3)] + (1..<6).map { line($0, 9) } + (6..<11).map { line($0, 4) } + (11..<15).map { line($0, 3) }
+ let m = SpeakerLabels.numbers(late)
+ #expect(m["l1"] == 1 && m["l6"] == 2 && m["l0"] == 3)
+ // Four lines of voice 4 are not enough yet.
+ #expect(SpeakerLabels.numbers(Array(lines.prefix(9))).isEmpty)
+ }
+
+ @Test func exportNamesFollowNumbers() {
+ let l = line(3, 1)
+ #expect(TranscriptExport.speakerName(l, ["l3": 2]) == L("说话人 2"))
+ #expect(TranscriptExport.speakerName(l) == L("对方"))
+ #expect(TranscriptExport.speakerName(line(4, nil, me: true), ["l4": 1]) == L("你"))
+ }
+
+ private func named(_ voiceNames: [String: String]?) -> Session {
+ let lines = (0..<5).map { line($0, 9) } + (5..<10).map { line($0, 4) } + [line(10, nil, me: true)]
+ return Session(id: "s", title: "t", startedAt: Date(), endedAt: nil, lines: lines, hasAudio: false,
+ notes: nil, renamed: nil, voiceNames: voiceNames)
+ }
+
+ @Test func namesFollowVoicesNotNumbers() {
+ let s = named(["4": "George", "7": "Nobody"])
+ #expect(SpeakerLabels.names(s) == [2: "George"])
+ #expect(SpeakerLabels.label(2, SpeakerLabels.names(s)) == "George")
+ #expect(SpeakerLabels.label(1, SpeakerLabels.names(s)) == L("说话人 1"))
+ #expect(TranscriptExport.speakerName(s.lines[5], SpeakerLabels.numbers(s.lines), SpeakerLabels.names(s)) == "George")
+ #expect(SpeakerLabels.names(named(nil)).isEmpty)
+ }
+
+ @Test func nameGuessPromptAndParse() {
+ let s = named(nil)
+ let content = SpeakerNameGuess.content(s) ?? ""
+ #expect(content.contains("[L1 00:00 说话人1] a full line"))
+ #expect(content.contains("[L6 00:05 说话人2] a full line"))
+ #expect(content.contains("[L11 00:10 你] a full line"))
+ let reply = #"{"speakers": [{"speaker": 2, "name": " George ", "evidence": "L6"}, {"speaker": 7, "name": "X"}, {"speaker": 1, "name": ""}]}"#
+ let g = SpeakerNameGuess.parse(reply, s)
+ #expect(g == [4: VoiceGuess(name: "George", evidence: "00:05 “a full line”")])
+ // One name for two voices: the one with more lines keeps it.
+ var more = s
+ more.lines += (11..<14).map { line($0, 4) }
+ #expect(SpeakerNameGuess.parse(#"{"speakers": [{"speaker": 1, "name": "Ann"}, {"speaker": 2, "name": "Ann"}]}"#, more).keys.sorted() == [4])
+ #expect(SpeakerNameGuess.parse("not json", s).isEmpty)
+ // One voice on show: nothing to ask.
+ #expect(SpeakerNameGuess.content(Session(id: "s", title: "t", startedAt: Date(), endedAt: nil,
+ lines: (0..<6).map { line($0, 1) }, hasAudio: false, notes: nil, renamed: nil)) == nil)
+ }
+
+ @Test func guessesShowUntilTheUserSaysOtherwise() {
+ var s = named(nil)
+ s.voiceGuesses = ["9": VoiceGuess(name: "Emma", evidence: ""), "4": VoiceGuess(name: "George", evidence: "")]
+ #expect(SpeakerLabels.names(s) == [1: "Emma", 2: "George"])
+ #expect(SpeakerLabels.guessed(s).keys.sorted() == [1, 2])
+ s.voiceNames = ["9": "Emily", "4": ""] // corrected, and turned down
+ #expect(SpeakerLabels.names(s) == [1: "Emily"])
+ #expect(SpeakerLabels.guessed(s).isEmpty)
+ }
+
+ @Test func shortLinesDontEarnAName() {
+ #expect(SpeakerLabels.substantive("I can take it"))
+ #expect(!SpeakerLabels.substantive("Yeah, sure."))
+ #expect(!SpeakerLabels.substantive("."))
+ #expect(SpeakerLabels.substantive("我们周四上线"))
+ #expect(!SpeakerLabels.substantive("好的"))
+ }
+
+ @Test func namesOnlyWhereTheSpeakerChanges() {
+ let lines = [line(0, 9), line(1, 9), line(2, 4), line(3, nil), line(4, nil), line(5, 9), line(6, nil, me: true), line(7, nil, me: true)]
+ let starts = SpeakerLabels.runStarts(lines, ["l0": 1, "l1": 1, "l2": 2, "l5": 1])
+ #expect(starts == ["l0", "l2", "l3", "l5", "l6"])
+ #expect(TranscriptExport.speakerName(lines[3], ["l0": 1]) == L("未识别"))
+ #expect(TranscriptExport.speakerName(lines[3]) == L("对方"))
+ }
+
+ @Test func clustererMergeSendsLaterLinesToTarget() {
+ var c = VoiceClusterer()
+ #expect(c.label(unit(0), seconds: 3) == 0)
+ #expect(c.label(unit(1), seconds: 3) == 1)
+ c.merge(1, into: 0)
+ #expect(c.label(unit(1), seconds: 1) == 0)
+ }
+}
diff --git a/scripts/build.sh b/scripts/build.sh
index e6f887c..4b4df36 100755
--- a/scripts/build.sh
+++ b/scripts/build.sh
@@ -18,6 +18,8 @@ mkdir -p "$APP/Contents/MacOS" "$APP/Contents/Resources"
cp "$BIN/LiveSubs" "$APP/Contents/MacOS/Cicada"
cp Resources/Info.plist "$APP/Contents/Info.plist"
cp Resources/sample/sample.m4a "$APP/Contents/Resources/"
+# The experimental voiceprint model; the app compiles it on first use (no coremlcompiler in the CLT).
+cp -R Resources/models/SpeakerEmbedding.mlpackage "$APP/Contents/Resources/"
cp -R Resources/*.lproj "$APP/Contents/Resources/"
# Traditional Chinese systems get the Chinese UI rather than English (there is no zh-Hant translation).
cp -R Resources/zh-Hans.lproj "$APP/Contents/Resources/zh-Hant.lproj"
diff --git a/scripts/convert-voiceprint.py b/scripts/convert-voiceprint.py
new file mode 100644
index 0000000..4b30069
--- /dev/null
+++ b/scripts/convert-voiceprint.py
@@ -0,0 +1,54 @@
+# Converts the WeSpeaker ResNet34-LM speaker model (VoxCeleb, CC BY 4.0) into
+# Resources/models/SpeakerEmbedding.mlpackage, the voiceprint model behind 实验功能 › 分出对方的每个人.
+# Developer-only, run once; the app needs no Python. Needs Python 3.11 with
+# torch==2.5.1 coremltools==8.3.0 onnx onnx2torch "numpy<2" onnxruntime
+# and the ONNX file from WeSpeaker (docs/pretrained.md, voxceleb_resnet34_LM.onnx,
+# sha256 7bb2f06e9df17cdf1ef14ee8a15ab08ed28e8d0ef5054ee135741560df2ec068).
+# usage: python3 scripts/convert-voiceprint.py voxceleb_resnet34_LM.onnx Resources/models/SpeakerEmbedding.mlpackage
+import sys, numpy as np, torch, onnx, onnxruntime as ort, coremltools as ct
+from onnx import numpy_helper as nh
+from onnx2torch import convert
+src, out = sys.argv[1], sys.argv[2]
+model = onnx.load(src)
+inits = {i.name: nh.to_array(i) for i in model.graph.initializer}
+# Core ML can't convert the pooling's dynamic-shape ops (Shape → ReduceProd), so convert the
+# ResNet trunk up to its last ReLU and redo statistics pooling below.
+import tempfile, os
+trunk_path = os.path.join(tempfile.mkdtemp(), "trunk.onnx")
+onnx.utils.extract_model(src, trunk_path, ["feats"], ["343"])
+trunk = convert(onnx.load(trunk_path)).eval()
+
+class Embed(torch.nn.Module):
+ """ResNet trunk + statistics pooling rewritten without the dynamic-shape ops Core ML lacks."""
+ def __init__(self):
+ super().__init__()
+ self.trunk = trunk
+ self.fc = torch.nn.Linear(5120, 256)
+ self.fc.weight.data = torch.from_numpy(inits["model.seg_1.weight"])
+ self.fc.bias.data = torch.from_numpy(inits["model.seg_1.bias"])
+ self.register_buffer("mean_vec", torch.from_numpy(inits["mean_vec"]))
+ def forward(self, feats):
+ x = self.trunk(feats) # [1, C, F, T']
+ mu = x.mean(-1)
+ n = torch.ones_like(x).sum(-1) # T' without reading the shape
+ var = ((x - mu.unsqueeze(-1)) ** 2).mean(-1) * n / (n - 1)
+ sd = torch.sqrt(var + 1e-8)
+ z = torch.cat([mu.flatten(1), sd.flatten(1)], 1)
+ return self.fc(z) - self.mean_vec
+
+m = Embed().eval()
+sess = ort.InferenceSession(src)
+x = torch.randn(1, 300, 80)
+with torch.no_grad():
+ print("torch vs onnx max diff", np.abs(sess.run(None, {"feats": x.numpy()})[0] - m(x).numpy()).max())
+tr = torch.jit.trace(m, x)
+ml = ct.convert(tr, inputs=[ct.TensorType(name="feats", shape=(1, ct.RangeDim(50, 6000, default=300), 80))],
+ outputs=[ct.TensorType(name="embs")], minimum_deployment_target=ct.target.macOS14,
+ compute_precision=ct.precision.FLOAT16, convert_to="mlprogram")
+ml.short_description = "WeSpeaker ResNet34-LM speaker embedding (VoxCeleb, CC BY 4.0)"
+ml.save(out)
+for T in (80, 150, 300, 801, 2000):
+ x = np.random.randn(1, T, 80).astype(np.float32)
+ a = sess.run(None, {"feats": x})[0][0]
+ b = ml.predict({"feats": x})["embs"][0]
+ print(T, "cos onnx vs coreml", round(float(a @ b / np.linalg.norm(a) / np.linalg.norm(b)), 5))
diff --git a/site/changelog.json b/site/changelog.json
index bf54dbb..1a1dd0c 100644
--- a/site/changelog.json
+++ b/site/changelog.json
@@ -6,6 +6,31 @@
"summary": "打开同声传译时,系统麦克风自动换成虚拟麦克风,Chrome 里的会议网页不用再手动设置;关掉或退出时自动换回。",
"image": null,
"items": [
+ {
+ "kind": "fixed",
+ "title": "一直没人说话的会议不再一直听下去。",
+ "text": "开始听之后,如果过了“结束会议”里设的时间(默认 10 分钟)一句话都没识别到,而且没有会议软件在通话,知了会直接停止收听:没有内容可保存,所以不再倒计时,开关回到“开始听”。选了“一直记录”则照旧一直听。"
+ },
+ {
+ "kind": "changed",
+ "title": "还没人说话时,纪要窗口和诊断页不再空荡。",
+ "text": "纪要页先画出纪要的骨架:一行“有人开口后,约半分钟出第一版”,下面是总结和议题的位置在轻轻闪动,再列出会整理出的结论、待办、人名和术语、鱼骨图。文字记录页显示开始听的时间、两行双语句子的样子,以及等人开口的“此刻”;背景噪声偶尔冒出的一个“.”不再顶掉它。诊断页把四个横杠、空进度条和一串 0 换成一句话经过的几步和各自量什么、翻译通道的颜色、“本场还没调用”和一条淡淡的示例句;有内容之前“复制诊断信息”不可点。"
+ },
+ {
+ "kind": "new",
+ "title": "实验功能:说话人识别。",
+ "text": "在“设置 › 通用 › 实验功能”打开(默认关闭)后,知了在这台 Mac 上按声音把对方的话标成“说话人 1、2…”。一个声音说满五句才出现名字,而且至少听到两个人才会显示,一对一的会议仍写“对方”;拿不准的句子也写“对方”。纪要窗口顶部会列出在说话的人,带“实验”标记和“不准?关掉”;会议记录、Markdown 和 Word 导出、纪要都用同样的名字。接了 Ling key 时名字会自己填上:Ling 从对话里的称呼(比如“Thanks, George”)认出谁是谁,会议中每 20 句再认一次,结束时再认一遍。点一下上方的人可以看名字依据的那句话、改名字、点“不是 TA”退回编号,或把其实是同一个人的两个合并;你改过的名字永远优先。名字只在换人时出现一次,认不出的写“未识别”;纪要里的待办直接写负责人名字。窗口窄时,上方的人会换行显示,不再挤成一个字。关掉后名字一起收起。用的是随 app 附带的 WeSpeaker ResNet34-LM 声纹模型(VoxCeleb,CC BY 4.0)。"
+ },
+ {
+ "kind": "changed",
+ "title": "同声传译设置页短了一半。",
+ "text": "页面顶部只有一张卡,告诉你对方听不听得到你,旁边是上次的延迟和“试一句”;只有出了问题才展开成清单:已经正常的打勾,每个问题(系统麦克风被换走或没换回、会议软件选了别的麦克风、右 ⌥ 缺“输入监控”权限)配一个修复按钮。下面是两组不带说明文字的设置:“说话”(按键、对方听到的语言、声音)和“麦克风”(打开时切换系统麦克风、知了用哪个麦克风听你、译文送到哪里,原来藏在“高级”里)。开关挪到页面标题旁边。装好虚拟麦克风后不再显示编号步骤,单独的系统麦克风状态行、会议软件列表和它的空状态与脚注、“高级”折叠都去掉了。"
+ },
+ {
+ "kind": "changed",
+ "title": "菜单栏面板的同声传译说清楚了它会做什么。",
+ "text": "第一次打开同声传译时,开关先在原地问一句:打开后系统麦克风会换成 BlackHole 2ch,按住右 ⌥ 说话,关掉后全部还原,点“好,打开”才生效;之后开关即开即关,鼠标停在开关上也能看到这几句。打开后,说话键画成一个按键,旁边写对方听到什么语言、在哪个会议软件里,绿点表示一切正常;按住时变成橙色,依次显示正在听、正在翻译、正在播出。会议软件没选虚拟麦克风、虚拟麦克风没装好、右 ⌥ 缺“输入监控”权限,都直接写在这个按键上,带一个修复按钮,不再另起红条。⋯ 菜单去掉了:设置放在开关旁边,“先试一句”在你试过之前一直在。关着时只显示语言,因为那时按键不起作用。系统设置的“声音”页面不再被误报成没选虚拟麦克风的会议软件。"
+ },
{
"kind": "changed",
"title": "菜单栏面板的显示方式更好懂。",
@@ -14,12 +39,12 @@
{
"kind": "changed",
"title": "会议记录窗口变成一张白纸,开关就是知了。",
- "text": "标题栏中间是知了开关:没在听时是白色胶囊里的知了和“开始听”(⌘R);听的时候变成深色胶囊,知了在呼吸,声音条跟着声音跳,旁边是计时和结束;会议快自动结束时,知了外圈变成倒数环,可以点继续记录。左边列表每场会议一行,只有标题和时间;会议页去掉了卡片和工具栏,标题下面就是纪要、文字记录和导出。窗口够宽时,点导出旁边的“原话”可以在纪要右边并排看原话和译文(默认收起,会记住你的选择),点议题的时间就滚到那里;正在记录时,页面底部的“此刻”显示正在说的这句话。列表只留标题,较早的会议收在“更早的会议”里;会议页先看结论,再看总结,议题按编号排开,点开才看要点。还没有任何会议时,窗口里只有知了、一句话、“开始听”和“先听一段示例”。"
+ "text": "标题栏中间是知了开关:没在听时是白色胶囊里的知了和“开始听”(⌘R);听的时候变成深色胶囊,知了在呼吸,声音条跟着声音跳,旁边是计时和结束;会议快自动结束时,知了外圈变成倒数环,可以点继续记录。左边列表每场会议一行,只有标题和时间;会议页去掉了卡片和工具栏,标题下面就是纪要、文字记录和导出。窗口够宽时,点导出旁边的“原话”可以在纪要右边并排看原话和译文(默认收起,会记住你的选择),点议题的时间就滚到那里;正在记录时,页面底部的“此刻”显示正在说的这句话。列表只留标题,较早的会议收在“更早的会议”里;会议页先看结论,再看总结,议题按编号排开,点开才看要点。还没有任何会议时,窗口里只有知了、一句话、“开始听”和“先听一段示例”。文字分成标题、正文、说明三档灰度;能点的时间和编号用知了的暖橙色,结论里的数字和日期加了荧光笔;打开说话人识别后,每个说话人有自己的颜色。"
},
{
"kind": "new",
"title": "Chrome 里开会也不用设置麦克风了。",
- "text": "打开同声传译时,知了把系统麦克风换成 BlackHole 2ch,关掉同声传译或退出知了时换回原来的麦克风,用“默认”麦克风的会议网页和软件直接就能听到译文。知了自己仍然用你的真实麦克风听你说话,也可以在设置里固定一个。上次没来得及换回(比如知了意外退出),或者说话时插上 AirPods 把系统麦克风换走了,菜单栏面板会提示,点一下还原或换回;面板上同声传译旁边的 ⋯ 里也能随时还原。不想自动切换的话,可以在设置的同声传译里关掉。"
+ "text": "打开同声传译时,知了把系统麦克风换成 BlackHole 2ch,关掉同声传译或退出知了时换回原来的麦克风,用“默认”麦克风的会议网页和软件直接就能听到译文。知了自己仍然用你的真实麦克风听你说话,也可以在设置里固定一个。上次没来得及换回(比如知了意外退出),或者说话时插上 AirPods 把系统麦克风换走了,菜单栏面板会提示,点一下还原或换回。不想自动切换的话,可以在设置的同声传译里关掉。"
},
{
"kind": "new",
diff --git a/tools/README.md b/tools/README.md
index 5e7cdab..1aef892 100644
--- a/tools/README.md
+++ b/tools/README.md
@@ -13,15 +13,15 @@
- 快捷键:`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:<设备名片段>` 改输出设备(留空 = 虚拟麦克风)
+ - 说话同传:`speakOn` / `speakOff` 开关,`speakAsk[:off]` 面板里第一次打开时的确认卡,`speakConfirmed:<on|off>` 是否已确认过,`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`
- 导出:`export:<目录>`
- - 新手引导与窗口:`onboarding:<步骤>[,skip|ask|setup]`(1–5,5 是收尾页;skip 是第 3 步点了“先不接”,ask / setup 是第 4 步的二选一 / 清单)、`samplePlay`、`closeWindow:<main|settings|onboarding>`、`settings:<overlay|language|speak|records|ai|diagnostics>`、`about`
+ - 新手引导与窗口:`onboarding:<步骤>[,skip|ask|setup]`(1–5,5 是收尾页;skip 是第 3 步点了“先不接”,ask / setup 是第 4 步的二选一 / 清单)、`samplePlay`、`speakers:<on|off>`(实验功能“说话人识别”)、`speakerGuess:<会议 id>`(马上让 Ling 认一遍名字)、`speakersRender:<会议 id>=<png>`、`voiceprintFile:<音频>=<json>`(用 app 里的声纹模型算整个文件的声纹,和参考模型对比)、`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>`
+ - 渲染(不需要录屏权限):`panelRender:<png>`(菜单栏面板,离屏画)、`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>`
- 诊断:`diagnostics:<on|off>`、`diagReport`