知了 Cicada · 任何会议和直播的实时字幕、同声传译、AI 会议纪要,Mac、Windows、Linux、Android 免费开源。Live subtitles, interpreting and meeting notes for any call or stream, on Mac, Windows, Linux and Android.
Swift androidlinuxlive-captionsmacosmeeting-notesmenubar-appsimultaneous-interpretationspeech-recognitionsubtitlesswiftswiftuitranslationwindows
feat: ask for a Ling key in the first-run guide
wquguru0c46847c40f1
diff --git a/Resources/en.lproj/Localizable.strings b/Resources/en.lproj/Localizable.stringsindex 34f4d65..d0a0419 100644--- a/Resources/en.lproj/Localizable.strings+++ b/Resources/en.lproj/Localizable.strings@@ -343,6 +343,27 @@"右侧 option" = "Right option";"按住说话" = "Hold to talk";+/* OnboardingKey */+"接上 Ling,用上完整的知了" = "Connect Ling to get all of Cicada";+"纪要、更准的翻译和自然的同传语音都靠它,约 1 分钟。" = "Notes, sharper translation and natural interpreting voices all run on it. Takes about a minute.";+"Ling 每月赠送 ¥10 额度" = "Ling gives ¥10 of credit every month";+"约够 10–50 小时会议 · 不填也能用实时字幕和会议记录" = "About 10–50 hours of meetings · subtitles and records work without it";+"在 Ling 开放平台创建令牌" = "Create a token on the Ling platform";+"注册或登录后点“创建令牌”" = "Sign up or log in, then click “Create Credential”";+"打开 Ling 开放平台" = "Open Ling platform";+"复制 sk- 开头的 key,回来粘贴" = "Copy the key that starts with sk-, then paste it here";+"粘贴并检查" = "Paste and Check";+"剪贴板里没有 sk- 开头的 key,先在 Ling 开放平台复制。" = "No key starting with sk- on the clipboard. Copy it from the Ling platform first.";+"只保存在这台 Mac 上,只发给 Ling" = "Stored only on this Mac, sent only to Ling";+"现在可以用了" = "Now available";+"下一步放示例视频,字幕和纪要会一起出现。" = "Next, play the sample video: subtitles and notes appear together.";+"更准的翻译" = "Sharper translation";+"人名、术语前后一致" = "Names and terms stay consistent";+"自然人声" = "Natural voices";+"同传约 2 秒出声" = "Interpreting speaks in ~2 s";+"先连接 Ling" = "Connect Ling first";+"稍后在设置里填" = "Later, in Settings";+/* Overlay */"你在说… " = "You're speaking… ";"翻译中… " = "Translating… ";diff --git a/Resources/ja.lproj/Localizable.strings b/Resources/ja.lproj/Localizable.stringsindex c1725e4..982fd03 100644--- a/Resources/ja.lproj/Localizable.strings+++ b/Resources/ja.lproj/Localizable.strings@@ -343,6 +343,27 @@"右侧 option" = "右の option";"按住说话" = "押して話す";+/* OnboardingKey */+"接上 Ling,用上完整的知了" = "Ling をつないで、Cicada をフルに使う";+"纪要、更准的翻译和自然的同传语音都靠它,约 1 分钟。" = "議事メモ、より正確な翻訳、自然な通訳音声はすべて Ling で動きます。約 1 分です。";+"Ling 每月赠送 ¥10 额度" = "Ling から毎月 ¥10 分の無料枠";+"约够 10–50 小时会议 · 不填也能用实时字幕和会议记录" = "会議 約 10〜50 時間分 · なくても字幕と会議の記録は使えます";+"在 Ling 开放平台创建令牌" = "Ling プラットフォームでトークンを作成";+"注册或登录后点“创建令牌”" = "登録またはログインして「Create Credential」をクリック";+"打开 Ling 开放平台" = "Ling プラットフォームを開く";+"复制 sk- 开头的 key,回来粘贴" = "sk- で始まるキーをコピーして、ここに貼り付け";+"粘贴并检查" = "貼り付けて確認";+"剪贴板里没有 sk- 开头的 key,先在 Ling 开放平台复制。" = "クリップボードに sk- で始まるキーがありません。先に Ling プラットフォームでコピーしてください。";+"只保存在这台 Mac 上,只发给 Ling" = "この Mac にのみ保存され、Ling にのみ送信されます";+"现在可以用了" = "使えるようになったもの";+"下一步放示例视频,字幕和纪要会一起出现。" = "次はサンプル動画を再生。字幕と議事メモが一緒に表示されます。";+"更准的翻译" = "より正確な翻訳";+"人名、术语前后一致" = "人名や用語が一貫";+"自然人声" = "自然な音声";+"同传约 2 秒出声" = "通訳は約 2 秒で発話";+"先连接 Ling" = "先に Ling をつないでください";+"稍后在设置里填" = "あとで設定から";+/* Overlay */"你在说… " = "話しています… ";"翻译中… " = "翻訳中… ";diff --git a/Resources/ko.lproj/Localizable.strings b/Resources/ko.lproj/Localizable.stringsindex ccce470..3c64412 100644--- a/Resources/ko.lproj/Localizable.strings+++ b/Resources/ko.lproj/Localizable.strings@@ -343,6 +343,27 @@"右侧 option" = "오른쪽 option";"按住说话" = "누르고 말하기";+/* OnboardingKey */+"接上 Ling,用上完整的知了" = "Ling을 연결하고 Cicada를 온전히 쓰세요";+"纪要、更准的翻译和自然的同传语音都靠它,约 1 分钟。" = "회의록, 더 정확한 번역, 자연스러운 통역 음성이 모두 Ling으로 동작합니다. 약 1분이면 됩니다.";+"Ling 每月赠送 ¥10 额度" = "Ling이 매달 ¥10 크레딧 제공";+"约够 10–50 小时会议 · 不填也能用实时字幕和会议记录" = "회의 약 10–50시간 분량 · 없어도 자막과 회의 기록은 사용 가능";+"在 Ling 开放平台创建令牌" = "Ling 플랫폼에서 토큰 만들기";+"注册或登录后点“创建令牌”" = "가입 또는 로그인 후 “Create Credential” 클릭";+"打开 Ling 开放平台" = "Ling 플랫폼 열기";+"复制 sk- 开头的 key,回来粘贴" = "sk-로 시작하는 키를 복사해 여기에 붙여넣기";+"粘贴并检查" = "붙여넣고 확인";+"剪贴板里没有 sk- 开头的 key,先在 Ling 开放平台复制。" = "클립보드에 sk-로 시작하는 키가 없습니다. 먼저 Ling 플랫폼에서 복사하세요.";+"只保存在这台 Mac 上,只发给 Ling" = "이 Mac에만 저장되고 Ling에만 전송됩니다";+"现在可以用了" = "이제 사용 가능";+"下一步放示例视频,字幕和纪要会一起出现。" = "다음 단계에서 샘플 영상을 재생하면 자막과 회의록이 함께 나타납니다.";+"更准的翻译" = "더 정확한 번역";+"人名、术语前后一致" = "이름과 용어가 일관됨";+"自然人声" = "자연스러운 음성";+"同传约 2 秒出声" = "통역 약 2초 만에 음성 출력";+"先连接 Ling" = "먼저 Ling을 연결하세요";+"稍后在设置里填" = "나중에 설정에서";+/* Overlay */"你在说… " = "말하는 중… ";"翻译中… " = "번역 중… ";diff --git a/Resources/zh-Hans.lproj/Localizable.strings b/Resources/zh-Hans.lproj/Localizable.stringsindex 0c398c4..7dbc329 100644--- a/Resources/zh-Hans.lproj/Localizable.strings+++ b/Resources/zh-Hans.lproj/Localizable.strings@@ -343,6 +343,27 @@"右侧 option" = "右侧 option";"按住说话" = "按住说话";+/* OnboardingKey */+"接上 Ling,用上完整的知了" = "接上 Ling,用上完整的知了";+"纪要、更准的翻译和自然的同传语音都靠它,约 1 分钟。" = "纪要、更准的翻译和自然的同传语音都靠它,约 1 分钟。";+"Ling 每月赠送 ¥10 额度" = "Ling 每月赠送 ¥10 额度";+"约够 10–50 小时会议 · 不填也能用实时字幕和会议记录" = "约够 10–50 小时会议 · 不填也能用实时字幕和会议记录";+"在 Ling 开放平台创建令牌" = "在 Ling 开放平台创建令牌";+"注册或登录后点“创建令牌”" = "注册或登录后点“创建令牌”";+"打开 Ling 开放平台" = "打开 Ling 开放平台";+"复制 sk- 开头的 key,回来粘贴" = "复制 sk- 开头的 key,回来粘贴";+"粘贴并检查" = "粘贴并检查";+"剪贴板里没有 sk- 开头的 key,先在 Ling 开放平台复制。" = "剪贴板里没有 sk- 开头的 key,先在 Ling 开放平台复制。";+"只保存在这台 Mac 上,只发给 Ling" = "只保存在这台 Mac 上,只发给 Ling";+"现在可以用了" = "现在可以用了";+"下一步放示例视频,字幕和纪要会一起出现。" = "下一步放示例视频,字幕和纪要会一起出现。";+"更准的翻译" = "更准的翻译";+"人名、术语前后一致" = "人名、术语前后一致";+"自然人声" = "自然人声";+"同传约 2 秒出声" = "同传约 2 秒出声";+"先连接 Ling" = "先连接 Ling";+"稍后在设置里填" = "稍后在设置里填";+/* Overlay */"你在说… " = "你在说… ";"翻译中… " = "翻译中… ";diff --git a/Sources/LiveSubs/AppModel.swift b/Sources/LiveSubs/AppModel.swiftindex b607bcd..38dabdb 100644--- a/Sources/LiveSubs/AppModel.swift+++ b/Sources/LiveSubs/AppModel.swift@@ -827,6 +827,10 @@ final class AppModel: ObservableObject {ling.simulate = ["429": .rateLimited, "hijack": .hijacked, "timeout": .timeout][arg]debugLog("ling simulate=\(String(describing: ling.simulate))")case "aiRemove": ling.removeKey()+ case "aiHide":+ // aiHide:<on|off>: the key file stays; the app behaves as if there were none (for screenshots).+ ling.hideKey = arg != "off"+ Task { await ling.check() }case "aiState": debugLog("ai state=\(ling.keyState) hasKey=\(ling.hasKey) model=\(settings.aiModel)")case "subtitles": setSubtitles(arg)case "meetingSubtitles": setSubtitles(arg, meetingOnly: true)diff --git a/Sources/LiveSubs/Ling.swift b/Sources/LiveSubs/Ling.swiftindex 1f21ff8..2935bc3 100644--- a/Sources/LiveSubs/Ling.swift+++ b/Sources/LiveSubs/Ling.swift@@ -148,8 +148,11 @@ final class LingClient: ObservableObject {/// Debug control only: make every chat call fail this way.var simulate: Failure?+ /// Debug control only: act as if there were no key, without touching the key file.+ var hideKey = false+var hasKey: Bool { key != nil }- var key: String? { AIKey.read() }+ var key: String? { hideKey ? nil : AIKey.read() }/// The key is known to work (or at least not known to be bad).var usable: Bool { hasKey && keyState != .invalid }@@ -163,6 +166,7 @@ final class LingClient: ObservableObject {func setKey(_ raw: String) async {let k = raw.trimmingCharacters(in: .whitespacesAndNewlines)guard !k.isEmpty else { return }+ if hideKey { debugLog("ai key: not saved while hidden (debug)"); keyState = .invalid; return }AIKey.save(k)await check()}diff --git a/Sources/LiveSubs/Onboarding.swift b/Sources/LiveSubs/Onboarding.swiftindex ebf52fd..4d146b3 100644--- a/Sources/LiveSubs/Onboarding.swift+++ b/Sources/LiveSubs/Onboarding.swift@@ -244,6 +244,9 @@ struct OnboardingView: View {nonmutating set { model.onboardingStep = newValue }}var onFinish: () -> Void+ /// Permissions, Ling key, sample video, speaking.+ static let steps = 4+var body: some View {VStack(alignment: .leading, spacing: 0) {@@ -252,7 +255,8 @@ struct OnboardingView: View {Group {switch step {case 1: permissions- case 2: tryIt+ case 2: OnboardingKeyStep(ling: model.ling, settings: settings)+ case 3: tryItdefault: speaking}}@@ -273,11 +277,11 @@ struct OnboardingView: View {HStack(spacing: 14) {BrandMark(size: 34)HStack(spacing: 6) {- ForEach(1...3, id: \.self) { i in+ ForEach(1...Self.steps, id: \.self) { i inCapsule().fill(i <= step ? Palette.ink : Color(white: 0.87)).frame(height: 4)}}- Text("\(step) / 3").font(.system(size: 12)).foregroundStyle(Palette.secondary)+ Text("\(step) / \(Self.steps)").font(.system(size: 12)).foregroundStyle(Palette.secondary)}}@@ -289,18 +293,20 @@ struct OnboardingView: View {Button("上一步") { step -= 1 }.buttonStyle(.plain).foregroundStyle(Palette.secondary)}Spacer()- if step == 1 && !model.systemAudioOK {+ if step == 2 {+ OnboardingKeyFooter(ling: model.ling, skip: { step = 3 }, next: { step = 3 })+ } else if step == 1 && !model.systemAudioOK {Text("先打开“听电脑里的声音”").font(.system(size: 14, weight: .semibold)).foregroundStyle(Palette.secondary).padding(.horizontal, 24).frame(height: 44).background(RoundedRectangle(cornerRadius: 12).fill(Color(white: 0.87)))} else {Button {- if step < 3 { step += 1 } else { onFinish() }+ if step < Self.steps { step += 1 } else { onFinish() }} label: {HStack(spacing: 8) {- Text(step < 3 ? L("继续") : L("开始使用"))- if step < 3 { Image(systemName: "arrow.right") }+ Text(step < Self.steps ? L("继续") : L("开始使用"))+ if step < Self.steps { Image(systemName: "arrow.right") }}.font(.system(size: 14, weight: .semibold)).foregroundStyle(.white).padding(.horizontal, 28).frame(height: 44)@@ -397,7 +403,7 @@ struct OnboardingView: View {}}- // MARK: Step 2+ // MARK: Step 3private var tryIt: some View {VStack(alignment: .leading, spacing: 22) {@@ -468,7 +474,7 @@ struct OnboardingView: View {[("system", L("跟随系统"))] + targetLanguages.map { ($0.code, $0.name) }}- // MARK: Step 3+ // MARK: Step 4private var speaking: some View {VStack(alignment: .leading, spacing: 22) {diff --git a/Sources/LiveSubs/OnboardingKey.swift b/Sources/LiveSubs/OnboardingKey.swiftnew file mode 100644index 0000000..4fea6ec--- /dev/null+++ b/Sources/LiveSubs/OnboardingKey.swift@@ -0,0 +1,210 @@+import AppKit+import SwiftUI++/// Onboarding step 2: connect a Ling key. Notes, Ling translation and Ming voices all need it, so it+/// sits right after the permissions; "稍后在设置里填" skips it (the notes window asks again later).+struct OnboardingKeyStep: View {+ @ObservedObject var ling: LingClient+ @ObservedObject var settings: AppSettings+ @State private var draft = ""+ @State private var clipboardEmpty = false++ static let platform = URL(string: "https://chat.ant-ling.com/platform/api")!++ var body: some View {+ VStack(alignment: .leading, spacing: 18) {+ VStack(alignment: .leading, spacing: 8) {+ Text("接上 Ling,用上完整的知了").font(.system(size: 26, weight: .bold)).foregroundStyle(Palette.ink)+ Text("纪要、更准的翻译和自然的同传语音都靠它,约 1 分钟。")+ .font(.system(size: 14)).foregroundStyle(Palette.secondary)+ }+ if case .ok = ling.keyState { connected } else { entry }+ HStack(spacing: 10) {+ Text("Ling 每月赠送 ¥10 额度").font(.system(size: 12, weight: .semibold)).foregroundStyle(Palette.accentInk)+ .padding(.horizontal, 9).padding(.vertical, 3)+ .background(Capsule().fill(Palette.accentPale))+ Text("约够 10–50 小时会议 · 不填也能用实时字幕和会议记录")+ .font(.system(size: 12)).foregroundStyle(Palette.secondary)+ }+ }+ }++ // MARK: Not connected yet++ private var entry: some View {+ VStack(alignment: .leading, spacing: 0) {+ HStack(spacing: 14) {+ number(1)+ VStack(alignment: .leading, spacing: 2) {+ Text("在 Ling 开放平台创建令牌").font(.system(size: 15, weight: .semibold)).foregroundStyle(Palette.ink)+ Text("注册或登录后点“创建令牌”").font(.system(size: 12)).foregroundStyle(Palette.tertiary)+ }+ Spacer()+ Button { NSWorkspace.shared.open(Self.platform) } label: {+ HStack(spacing: 5) {+ Text("打开 Ling 开放平台")+ Image(systemName: "arrow.up.right").font(.system(size: 10, weight: .semibold))+ }+ .font(.system(size: 13, weight: .semibold)).foregroundStyle(Palette.ink)+ .padding(.horizontal, 14).frame(height: 34)+ .background(RoundedRectangle(cornerRadius: 9).fill(Palette.fill))+ .contentShape(Rectangle())+ }+ .buttonStyle(.plain)+ }+ .padding(.bottom, 18)+ Divider()+ HStack(alignment: .top, spacing: 14) {+ number(2)+ VStack(alignment: .leading, spacing: 10) {+ Text("复制 sk- 开头的 key,回来粘贴").font(.system(size: 15, weight: .semibold)).foregroundStyle(Palette.ink)+ HStack(spacing: 8) {+ SecureField("sk-…", text: $draft)+ .textFieldStyle(.plain).font(.system(size: 13, design: .monospaced))+ .padding(.horizontal, 12).frame(height: 36)+ .background(RoundedRectangle(cornerRadius: 10).fill(Color.white))+ .overlay(RoundedRectangle(cornerRadius: 10).stroke(Palette.ink.opacity(0.35), lineWidth: 1))+ .onSubmit { save(draft) }+ Button(action: pasteAndCheck) {+ HStack(spacing: 6) {+ Image(systemName: "doc.on.clipboard").font(.system(size: 12))+ Text(draft.isEmpty ? L("粘贴并检查") : L("保存并检查"))+ }+ .font(.system(size: 13, weight: .semibold)).foregroundStyle(.white)+ .padding(.horizontal, 14).frame(height: 36)+ .background(RoundedRectangle(cornerRadius: 10).fill(Palette.ink))+ .contentShape(Rectangle())+ }+ .buttonStyle(.plain)+ }+ status+ }+ }+ .padding(.top, 18)+ }+ .padding(22)+ .background(RoundedRectangle(cornerRadius: 16).fill(Color.white))+ .overlay(RoundedRectangle(cornerRadius: 16).stroke(Palette.line, lineWidth: 1))+ }++ @ViewBuilder private var status: some View {+ switch ling.keyState {+ case .checking, .unchecked:+ line(Palette.accent, L("正在检查…"), Palette.secondary)+ case .invalid:+ line(Palette.error, L("Ling 提示此令牌无效,请检查是否复制完整,或重新创建一个"), Palette.accentInk)+ case .unreachable(let why):+ line(Palette.error, why, Palette.accentInk)+ default:+ if clipboardEmpty {+ line(Palette.error, L("剪贴板里没有 sk- 开头的 key,先在 Ling 开放平台复制。"), Palette.accentInk)+ } else {+ Label("只保存在这台 Mac 上,只发给 Ling", systemImage: "lock")+ .font(.system(size: 12)).foregroundStyle(Palette.tertiary)+ }+ }+ }++ // MARK: Connected++ private var connected: some View {+ VStack(alignment: .leading, spacing: 16) {+ HStack(spacing: 10) {+ Image(systemName: "checkmark").font(.system(size: 11, weight: .bold)).foregroundStyle(Palette.ok)+ .frame(width: 24, height: 24).background(Circle().fill(Palette.okPale))+ Text("已连接").font(.system(size: 16, weight: .semibold)).foregroundStyle(Palette.ink)+ if case .ok(let s) = ling.keyState {+ Text(L("\(settings.aiModel) · 响应约 \(String(format: "%.1f", s)) 秒"))+ .font(.system(size: 12)).foregroundStyle(Palette.secondary)+ }+ Spacer()+ if let key = ling.key {+ Text(AIKey.masked(key)).font(.system(size: 12, design: .monospaced)).foregroundStyle(Palette.secondary)+ }+ }+ Divider()+ Text("现在可以用了").font(.system(size: 12, weight: .semibold)).foregroundStyle(Palette.secondary)+ HStack(spacing: 10) {+ benefit(L("实时纪要"), L("会中每 45 秒更新"))+ benefit(L("更准的翻译"), L("人名、术语前后一致"))+ benefit(L("自然人声"), L("同传约 2 秒出声"))+ }+ Text("下一步放示例视频,字幕和纪要会一起出现。").font(.system(size: 12)).foregroundStyle(Palette.secondary)+ }+ .padding(22)+ .background(RoundedRectangle(cornerRadius: 16).fill(Color.white))+ .overlay(RoundedRectangle(cornerRadius: 16).stroke(Palette.line, lineWidth: 1))+ }++ // MARK: Pieces++ private func number(_ n: Int) -> some View {+ Text("\(n)").font(.system(size: 13, weight: .bold)).foregroundStyle(Palette.ink)+ .frame(width: 26, height: 26).background(Circle().fill(Palette.fill))+ }++ private func line(_ dot: Color, _ text: String, _ color: Color) -> some View {+ HStack(spacing: 8) {+ Circle().fill(dot).frame(width: 7, height: 7)+ Text(text).font(.system(size: 12)).foregroundStyle(color).fixedSize(horizontal: false, vertical: true)+ }+ }++ private func benefit(_ title: String, _ detail: String) -> some View {+ VStack(alignment: .leading, spacing: 4) {+ Text(title).font(.system(size: 14, weight: .semibold)).foregroundStyle(Palette.ink)+ Text(detail).font(.system(size: 12)).foregroundStyle(Palette.secondary)+ }+ .frame(maxWidth: .infinity, alignment: .leading)+ .padding(14)+ .background(RoundedRectangle(cornerRadius: 12).fill(Palette.ground))+ }++ /// Reads the clipboard only when the button is clicked (a deliberate paste, so macOS's paste+ /// privacy prompt, if any, makes sense to the user); a typed key is checked as typed.+ private func pasteAndCheck() {+ if !draft.isEmpty { save(draft); return }+ let text = NSPasteboard.general.string(forType: .string)?.trimmingCharacters(in: .whitespacesAndNewlines) ?? ""+ guard text.hasPrefix("sk-"), !text.contains(where: \.isWhitespace) else { clipboardEmpty = true; return }+ save(text)+ }++ private func save(_ raw: String) {+ let k = raw.trimmingCharacters(in: .whitespacesAndNewlines)+ guard !k.isEmpty else { return }+ clipboardEmpty = false+ draft = ""+ Task { await ling.setKey(k) }+ }+}++/// Step 2's 继续: it waits for a working key (the full experience needs one); skipping is the quieter choice.+struct OnboardingKeyFooter: View {+ @ObservedObject var ling: LingClient+ var skip: () -> Void+ var next: () -> Void++ var body: some View {+ HStack(spacing: 16) {+ if case .ok = ling.keyState {+ Button(action: next) {+ HStack(spacing: 8) { Text("继续"); Image(systemName: "arrow.right") }+ .font(.system(size: 14, weight: .semibold)).foregroundStyle(.white)+ .padding(.horizontal, 28).frame(height: 44)+ .background(RoundedRectangle(cornerRadius: 12).fill(Palette.ink))+ .contentShape(Rectangle())+ }+ .buttonStyle(.plain)+ .keyboardShortcut(.defaultAction)+ } else {+ Button("稍后在设置里填", action: skip).buttonStyle(.plain).foregroundStyle(Palette.secondary)+ HStack(spacing: 8) { Text("继续"); Image(systemName: "arrow.right") }+ .font(.system(size: 14, weight: .semibold)).foregroundStyle(.white)+ .padding(.horizontal, 28).frame(height: 44)+ .background(RoundedRectangle(cornerRadius: 12).fill(Color(white: 0.8)))+ .accessibilityElement(children: .combine)+ .accessibilityHint(Text("先连接 Ling"))+ }+ }+ }+}