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: your own AI server can be set per job (translation and notes, speaking voice, recognition), on a LAN or Tailscale address over http with no key, and its check says when the model thinks before answering

wquguruc628a841e24a
diff --git a/Resources/en.lproj/Localizable.strings b/Resources/en.lproj/Localizable.strings
index c8e436c..545e0cf 100644
--- a/Resources/en.lproj/Localizable.strings
+++ b/Resources/en.lproj/Localizable.strings
@@ -3,7 +3,7 @@
"key 可以用" = "Key works";
"纪要和翻译" = "Notes and translation";
"这台 Mac 访问不到 %@。" = "This Mac can't reach %@.";
-"地址要用 https,只有 localhost 可以用 http。" = "The address must use https; only localhost can use http.";
+"地址要用 https;这台 Mac 和局域网里的服务可以用 http。" = "The address must use https; services on this Mac or your local network can use http.";
"%@ 说这个 key 无效,可能没复制全,或已删除。" = "%@ says this key is invalid. It may be incomplete or deleted.";
"这是 ZenMux 的管理 key,不能用来调用模型。请粘贴 sk-payg 开头的 key。" = "This is a ZenMux management key, which can't call models. Paste a key that starts with sk-payg.";
"%@ 账户余额不足。" = "Your %@ balance has run out.";
@@ -11,6 +11,10 @@
"这个服务不支持 JSON,纪要写不了;翻译照常。" = "This service doesn't support JSON, so notes can't be written. Translation still works.";
"%@ 现在很忙,key 没问题。开会时会自动重试。" = "%@ is busy right now; the key is fine. Meetings retry automatically.";
"%@ 暂时出错(HTTP %lld),稍后再试。" = "%@ has a temporary error (HTTP %lld). Try again shortly.";
+"这个模型先思考再回答,翻一句要 %@ 秒,超过 6 秒会改用 Google。在服务端关掉思考,或换一个不思考的模型。" = "This model thinks before answering: one sentence takes %@ s, and anything over 6 s falls back to Google. Turn thinking off on the server, or pick a model that doesn't think.";
+"翻一句要 %@ 秒,超过 6 秒会改用 Google。换一个更小的模型会快一些。" = "One sentence takes %@ s, and anything over 6 s falls back to Google. A smaller model will be faster.";
+"这台 Mac 访问不到 %@,开会时先用本机识别。" = "This Mac can't reach %@; meetings use on-device recognition for now.";
+"%@ 没接受音频(HTTP %lld),开会时先用本机识别。" = "%@ didn't accept the audio (HTTP %lld); meetings use on-device recognition for now.";
"开了代理也连不上:换一个节点,或检查代理软件是否放过 %@。" = "A proxy is on but it still can't connect. Try another server, or check that your proxy app routes %@.";
"代理软件在运行(端口 %@),但没开系统代理。在代理软件里打开“系统代理”。" = "A proxy app is running (port %@), but the system proxy is off. Turn on “System Proxy” in the proxy app.";
"这台电脑没开代理。在国内通常要开代理才能用 %@。" = "No proxy is on. In mainland China, %@ usually needs one.";
@@ -84,31 +88,58 @@
"同传念给对方" = "Speaks to the room when interpreting";
"一小时会议约 ¥0.15–1(目前优惠价)。说话的声音分段发给 Ling 识别和翻译;会议录音和文字记录只存在这台 Mac 上。" = "Roughly ¥0.15–1 for an hour-long meeting at current promotional pricing. Speech is sent to Ling in short segments for transcription and translation; recordings and transcripts stay on this Mac.";
"一小时会议约 ¥0.15–1(目前优惠价)。发出去的只有文字(用你自己的声音时还有那段录音),语音识别留在本机。" = "About ¥0.15–1 per hour of meeting (current discount pricing). Only text is sent (plus your voice sample if you use your own voice); speech recognition stays on this Mac.";
+"跑在你自己的机器上,不按量计费。" = "Runs on your own machine, with no usage charges. ";
+"费用以这个服务为准。" = "Charges are set by this service. ";
+"会议的声音会发给你的服务识别。" = "Meeting audio is sent to your service for recognition.";
+"发出去的只有文字,语音识别留在本机。" = "Only text is sent; speech recognition stays on this Mac.";
"按所选模型计费。发出去的只有文字,语音识别留在本机。" = "Billed by chosen model. Only text is sent; speech recognition stays on-device.";
-"在 %@ 创建 key,复制后粘贴到这里。" = "Create a key on %@, then copy and paste it here.";
-"打开 %@ ↗" = "Open %@ ↗";
+"每样可以接不同的机器;这台 Mac 和局域网里的服务可以用 http。" = "Each can use a different machine; services on this Mac or your local network can use http.";
+"填上地址和模型" = "Add an address and a model";
+"正在检查…" = "Checking…";
+"翻译和纪要" = "Translation and notes";
+"没填,用本机声音" = "Not set: the Mac's voice";
+"移除 key" = "Remove key";
+"key 只存在这台 Mac 上(只有你的账户能读),只发给 %@" = "The key is stored only on this Mac (readable only by your account) and sent only to %@";
+"只存在这台 Mac 上(只有你的账户能读),只发给 %@(%@)" = "Stored only on this Mac (readable only by your account) and sent only to %@ (%@)";
"暂时连不上" = "Can't connect right now";
"这个 key 用不了" = "This key doesn't work";
"模型用不了" = "The model doesn't work";
"还没填好" = "Incomplete";
"还没填 API key" = "No API key yet";
-"正在检查…" = "Checking…";
"已连接" = "Connected";
+"翻一句 %@ 秒" = "%@ s a sentence";
+"地址" = "URL";
+"例如 qwen3:14b" = "e.g. qwen3:14b";
+"这是 %@ 的 key。" = "This key is for %@.";
+"更换" = "Change";
+"保存并检查" = "Save and check";
+"本机和局域网服务可不填" = "Optional on this Mac or your local network";
+"能写纪要" = "Can write notes";
+"纪要写不了" = "Can't write notes";
+"会先思考" = "Thinks first";
+"不思考" = "Doesn't think";
+"上次正常" = "Worked last time";
+"上次没出声" = "Silent last time";
+"需支持 /audio/speech;不填则用本机声音。" = "Needs /audio/speech; leave blank to use the on-device voice.";
+"例如 qwen3-tts" = "e.g. qwen3-tts";
+"声音" = "Voice";
+"例如 vivian" = "e.g. vivian";
+"跟上面一样" = "Same as above";
+"自建服务" = "Your service";
+"会议的声音会发到 %@;连不上时用本机" = "Meeting audio goes to %@; this Mac takes over if it can't be reached";
+"更快,不花钱,声音不出这台 Mac" = "Faster, free, and audio never leaves this Mac";
+"需支持 /audio/transcriptions,例如 Qwen3-ASR、Whisper。下一场会议起生效。" = "Needs /audio/transcriptions, e.g. Qwen3-ASR or Whisper. Takes effect from the next meeting.";
+"填上模型才会用它识别。" = "Add a model to recognize with it.";
+"例如 qwen3-asr" = "e.g. qwen3-asr";
+"听一秒音频 %@ 秒" = "One second of audio in %@ s";
+"在 %@ 创建 key,复制后粘贴到这里。" = "Create a key on %@, then copy and paste it here.";
+"打开 %@ ↗" = "Open %@ ↗";
"%@ 现在很忙" = "%@ is busy right now";
"填入 Ling key 后才能识别语音、出字幕和纪要" = "Subtitles and notes need a Ling key";
"不填 key 时,字幕和翻译仍可正常使用" = "Subtitles and translation work without a key";
-"更换" = "Change";
-"保存并检查" = "Save and check";
"取消" = "Cancel";
-"本机服务可不填" = "Optional for local services";
-"这是 %@ 的 key。" = "This key is for %@.";
"改用 %@" = "Switch to %@";
"移除" = "Remove";
-"只存在这台 Mac 上(只有你的账户能读),只发给 %@" = "Stored only on this Mac (readable only by your account) and sent only to %@";
-"只存在这台 Mac 上(只有你的账户能读),只发给 %@(%@)" = "Stored only on this Mac (readable only by your account) and sent only to %@ (%@)";
-"地址需用 https,仅 localhost 可用 http。" = "URL must use https. http is only allowed for localhost.";
-"地址" = "URL";
-"例如 qwen3:14b" = "e.g. qwen3:14b";
"你填的地址" = "the URL you entered";
"%@ · 响应约 %@ 秒" = "%1$@ · responds in about %2$@ s";
"先用本机声音" = "Using this Mac's voice for now";
@@ -118,12 +149,8 @@
"没有 key 时用本机声音" = "Uses the Mac's voice without a key";
"没填声音模型,用本机声音" = "No voice model set; using on-device voice";
"%@ 暂不能出声音,用本机声音" = "%@ doesn't support voice yet; using on-device voice";
-"声音(可选)" = "Voice (optional)";
-"需支持 /audio/speech;不填则用本机声音。" = "Needs /audio/speech; leave blank to use the on-device voice.";
"例如 kokoro" = "e.g. kokoro";
-"声音" = "Voice";
"例如 af_heart" = "e.g. af_heart";
-"跟上面一样" = "Same as above";
"其他(兼容 OpenAI)" = "Other (OpenAI-compatible)";
"(推荐)" = " (Recommended)";
"模型名" = "Model name";
@@ -368,6 +395,7 @@
"识别出错,%lld 秒后重试" = "Recognition error; retrying in %lld s";
"听不出是哪种语言,到菜单栏里选一下" = "Can't tell the language. Pick one from the menu bar";
"正在识别语言…" = "Detecting language…";
+"%@ 暂时连不上,先用本机识别" = "Can't reach %@; recognizing on this Mac for now";
"key 已失效,到设置 › AI 服务里重填" = "The key stopped working. Enter a new one in Settings › AI Service";
"%@ 暂时连不上,正在重试" = "Can't reach %@. Retrying";
"翻译暂不可用" = "Translation unavailable for now";
diff --git a/Resources/ja.lproj/Localizable.strings b/Resources/ja.lproj/Localizable.strings
index 02b74ab..efa13fb 100644
--- a/Resources/ja.lproj/Localizable.strings
+++ b/Resources/ja.lproj/Localizable.strings
@@ -3,7 +3,7 @@
"key 可以用" = "key が使える";
"纪要和翻译" = "メモと翻訳";
"这台 Mac 访问不到 %@。" = "この Mac から %@ にアクセスできません。";
-"地址要用 https,只有 localhost 可以用 http。" = "アドレスは https にしてください。http は localhost のみ使えます。";
+"地址要用 https;这台 Mac 和局域网里的服务可以用 http。" = "アドレスは https にしてください。この Mac やローカルネットワークのサービスは http も使えます。";
"%@ 说这个 key 无效,可能没复制全,或已删除。" = "%@ によるとこの key は無効です。コピーが途中で切れたか、削除された可能性があります。";
"这是 ZenMux 的管理 key,不能用来调用模型。请粘贴 sk-payg 开头的 key。" = "これは ZenMux の管理用 key で、モデルを呼び出せません。sk-payg で始まる key を貼り付けてください。";
"%@ 账户余额不足。" = "%@ の残高が足りません。";
@@ -11,6 +11,10 @@
"这个服务不支持 JSON,纪要写不了;翻译照常。" = "このサービスは JSON に対応していないため、メモを作れません。翻訳はそのまま使えます。";
"%@ 现在很忙,key 没问题。开会时会自动重试。" = "%@ は混み合っています。key は問題ありません。会議中は自動で再試行します。";
"%@ 暂时出错(HTTP %lld),稍后再试。" = "%@ で一時的なエラーです(HTTP %lld)。少し待ってから試してください。";
+"这个模型先思考再回答,翻一句要 %@ 秒,超过 6 秒会改用 Google。在服务端关掉思考,或换一个不思考的模型。" = "このモデルは考えてから答えるため、1 文に %@ 秒かかります。6 秒を超えると Google に切り替わります。サーバー側で思考をオフにするか、思考しないモデルに替えてください。";
+"翻一句要 %@ 秒,超过 6 秒会改用 Google。换一个更小的模型会快一些。" = "1 文に %@ 秒かかります。6 秒を超えると Google に切り替わります。小さいモデルにすると速くなります。";
+"这台 Mac 访问不到 %@,开会时先用本机识别。" = "この Mac から %@ に接続できません。会議ではひとまずこの Mac で認識します。";
+"%@ 没接受音频(HTTP %lld),开会时先用本机识别。" = "%@ が音声を受け付けませんでした(HTTP %lld)。会議ではひとまずこの Mac で認識します。";
"开了代理也连不上:换一个节点,或检查代理软件是否放过 %@。" = "プロキシはオンですが接続できません。別のサーバーに切り替えるか、プロキシアプリが %@ を通しているか確認してください。";
"代理软件在运行(端口 %@),但没开系统代理。在代理软件里打开“系统代理”。" = "プロキシアプリは動いています(ポート %@)が、システムプロキシがオフです。プロキシアプリで「システムプロキシ」をオンにしてください。";
"这台电脑没开代理。在国内通常要开代理才能用 %@。" = "プロキシがオフです。中国本土では %@ を使うのに通常プロキシが必要です。";
@@ -84,31 +88,58 @@
"同传念给对方" = "同時通訳の読み上げ";
"一小时会议约 ¥0.15–1(目前优惠价)。说话的声音分段发给 Ling 识别和翻译;会议录音和文字记录只存在这台 Mac 上。" = "1 時間の会議で約 ¥0.15〜1(現在の割引価格)。発言は短い単位で Ling に送られて認識・翻訳され、録音と文字起こしはこの Mac にのみ保存されます。";
"一小时会议约 ¥0.15–1(目前优惠价)。发出去的只有文字(用你自己的声音时还有那段录音),语音识别留在本机。" = "1時間の会議で約¥0.15〜1(現在は優待価格)。送信されるのはテキストだけです(自分の声を使う場合はその録音も)。音声認識はこのMac内で行われます。";
+"跑在你自己的机器上,不按量计费。" = "自分のマシンで動くので、従量課金はありません。";
+"费用以这个服务为准。" = "料金はこのサービスの規定に従います。";
+"会议的声音会发给你的服务识别。" = "会議の音声はあなたのサービスに送られて認識されます。";
+"发出去的只有文字,语音识别留在本机。" = "送信されるのはテキストだけで、音声認識はこの Mac で行います。";
"按所选模型计费。发出去的只有文字,语音识别留在本机。" = "選択したモデルに応じて課金されます。送信されるのはテキストのみで、音声認識はオンデバイスで行われます。";
-"在 %@ 创建 key,复制后粘贴到这里。" = "%@ でキーを作成し、コピーしてここに貼り付けてください。";
-"打开 %@ ↗" = "%@ を開く ↗";
+"每样可以接不同的机器;这台 Mac 和局域网里的服务可以用 http。" = "それぞれ別のマシンを使えます。この Mac やローカルネットワークのサービスは http も使えます。";
+"填上地址和模型" = "アドレスとモデルを入力";
+"正在检查…" = "確認中…";
+"翻译和纪要" = "翻訳とメモ";
+"没填,用本机声音" = "未設定:この Mac の音声";
+"移除 key" = "キーを削除";
+"key 只存在这台 Mac 上(只有你的账户能读),只发给 %@" = "キーはこの Mac にのみ保存され(あなたのアカウントのみ読み取り可)、%@ にのみ送信されます";
+"只存在这台 Mac 上(只有你的账户能读),只发给 %@(%@)" = "この Mac にのみ保存され(あなたのアカウントのみ読み取り可)、%@(%@)にのみ送信されます";
"暂时连不上" = "現在接続できません";
"这个 key 用不了" = "このキーは使えません";
"模型用不了" = "モデルが使えません";
"还没填好" = "未入力の項目があります";
"还没填 API key" = "API key が未設定";
-"正在检查…" = "確認中…";
"已连接" = "接続済み";
+"翻一句 %@ 秒" = "1 文 %@ 秒";
+"地址" = "URL";
+"例如 qwen3:14b" = "例: qwen3:14b";
+"这是 %@ 的 key。" = "これは %@ の key です。";
+"更换" = "変更";
+"保存并检查" = "保存して確認";
+"本机和局域网服务可不填" = "この Mac やローカルネットワークでは省略可";
+"能写纪要" = "メモを作成できます";
+"纪要写不了" = "メモを作成できません";
+"会先思考" = "先に考えます";
+"不思考" = "思考しません";
+"上次正常" = "前回は正常";
+"上次没出声" = "前回は無音";
+"需支持 /audio/speech;不填则用本机声音。" = "/audio/speech の対応が必要です。未入力の場合はオンデバイス音声を使います。";
+"例如 qwen3-tts" = "例:qwen3-tts";
+"声音" = "声";
+"例如 vivian" = "例:vivian";
+"跟上面一样" = "上と同じ";
+"自建服务" = "自分のサービス";
+"会议的声音会发到 %@;连不上时用本机" = "会議の音声は %@ に送られます。接続できないときはこの Mac で認識";
+"更快,不花钱,声音不出这台 Mac" = "速くて無料、音声はこの Mac から出ません";
+"需支持 /audio/transcriptions,例如 Qwen3-ASR、Whisper。下一场会议起生效。" = "/audio/transcriptions に対応している必要があります(Qwen3-ASR、Whisper など)。次の会議から有効です。";
+"填上模型才会用它识别。" = "モデルを入力すると、そのモデルで認識します。";
+"例如 qwen3-asr" = "例:qwen3-asr";
+"听一秒音频 %@ 秒" = "1 秒の音声を %@ 秒で認識";
+"在 %@ 创建 key,复制后粘贴到这里。" = "%@ でキーを作成し、コピーしてここに貼り付けてください。";
+"打开 %@ ↗" = "%@ を開く ↗";
"%@ 现在很忙" = "%@ は混み合っています";
"填入 Ling key 后才能识别语音、出字幕和纪要" = "字幕とメモには Ling キーが必要です";
"不填 key 时,字幕和翻译仍可正常使用" = "キーがなくても、字幕と翻訳は通常どおり使えます";
-"更换" = "変更";
-"保存并检查" = "保存して確認";
"取消" = "キャンセル";
-"本机服务可不填" = "ローカルサービスでは省略可";
-"这是 %@ 的 key。" = "これは %@ の key です。";
"改用 %@" = "%@ に切り替える";
"移除" = "削除";
-"只存在这台 Mac 上(只有你的账户能读),只发给 %@" = "この Mac にのみ保存され(あなたのアカウントのみ読み取り可)、%@ にのみ送信されます";
-"只存在这台 Mac 上(只有你的账户能读),只发给 %@(%@)" = "この Mac にのみ保存され(あなたのアカウントのみ読み取り可)、%@(%@)にのみ送信されます";
-"地址需用 https,仅 localhost 可用 http。" = "URL には https が必要です(localhost のみ http 可)。";
-"地址" = "URL";
-"例如 qwen3:14b" = "例: qwen3:14b";
"你填的地址" = "入力した URL";
"%@ · 响应约 %@ 秒" = "%1$@ · 応答 約%2$@秒";
"先用本机声音" = "当面はこの Mac の音声";
@@ -118,12 +149,8 @@
"没有 key 时用本机声音" = "キーがない場合は Mac の音声を使用";
"没填声音模型,用本机声音" = "音声モデル未入力のため、オンデバイス音声を使用";
"%@ 暂不能出声音,用本机声音" = "%@ は音声非対応のため、オンデバイス音声を使用";
-"声音(可选)" = "音声(任意)";
-"需支持 /audio/speech;不填则用本机声音。" = "/audio/speech の対応が必要です。未入力の場合はオンデバイス音声を使います。";
"例如 kokoro" = "例: kokoro";
-"声音" = "声";
"例如 af_heart" = "例: af_heart";
-"跟上面一样" = "上と同じ";
"其他(兼容 OpenAI)" = "その他(OpenAI 互換)";
"(推荐)" = "(推奨)";
"模型名" = "モデル名";
@@ -368,6 +395,7 @@
"识别出错,%lld 秒后重试" = "認識エラー。%lld秒後に再試行します";
"听不出是哪种语言,到菜单栏里选一下" = "言語を判別できません。メニューバーで選んでください";
"正在识别语言…" = "言語を検出中…";
+"%@ 暂时连不上,先用本机识别" = "%@ に接続できません。ひとまずこの Mac で認識します";
"key 已失效,到设置 › AI 服务里重填" = "キーが無効になりました。設定 › AI サービスで入力し直してください";
"%@ 暂时连不上,正在重试" = "%@ に接続できません。再試行しています";
"翻译暂不可用" = "現在翻訳を利用できません";
diff --git a/Resources/ko.lproj/Localizable.strings b/Resources/ko.lproj/Localizable.strings
index 6b8a0cf..8eda775 100644
--- a/Resources/ko.lproj/Localizable.strings
+++ b/Resources/ko.lproj/Localizable.strings
@@ -3,7 +3,7 @@
"key 可以用" = "key 사용 가능";
"纪要和翻译" = "노트와 번역";
"这台 Mac 访问不到 %@。" = "이 Mac에서 %@에 접속할 수 없습니다.";
-"地址要用 https,只有 localhost 可以用 http。" = "주소는 https여야 합니다. http는 localhost에서만 쓸 수 있습니다.";
+"地址要用 https;这台 Mac 和局域网里的服务可以用 http。" = "주소는 https여야 합니다. 이 Mac이나 로컬 네트워크의 서비스는 http도 쓸 수 있습니다.";
"%@ 说这个 key 无效,可能没复制全,或已删除。" = "%@에서 이 key가 유효하지 않다고 합니다. 일부만 복사됐거나 삭제됐을 수 있습니다.";
"这是 ZenMux 的管理 key,不能用来调用模型。请粘贴 sk-payg 开头的 key。" = "ZenMux 관리용 key라서 모델을 호출할 수 없습니다. sk-payg로 시작하는 key를 붙여넣으세요.";
"%@ 账户余额不足。" = "%@ 잔액이 부족합니다.";
@@ -11,6 +11,10 @@
"这个服务不支持 JSON,纪要写不了;翻译照常。" = "이 서비스는 JSON을 지원하지 않아 노트를 만들 수 없습니다. 번역은 그대로 됩니다.";
"%@ 现在很忙,key 没问题。开会时会自动重试。" = "%@가 지금 붐빕니다. key는 문제없습니다. 회의 중에는 자동으로 다시 시도합니다.";
"%@ 暂时出错(HTTP %lld),稍后再试。" = "%@에 일시적인 오류가 있습니다(HTTP %lld). 잠시 후 다시 시도하세요.";
+"这个模型先思考再回答,翻一句要 %@ 秒,超过 6 秒会改用 Google。在服务端关掉思考,或换一个不思考的模型。" = "이 모델은 생각한 뒤 답해서 한 문장에 %@초가 걸립니다. 6초를 넘으면 Google로 바뀝니다. 서버에서 생각 기능을 끄거나 생각하지 않는 모델로 바꾸세요.";
+"翻一句要 %@ 秒,超过 6 秒会改用 Google。换一个更小的模型会快一些。" = "한 문장에 %@초가 걸립니다. 6초를 넘으면 Google로 바뀝니다. 더 작은 모델이 더 빠릅니다.";
+"这台 Mac 访问不到 %@,开会时先用本机识别。" = "이 Mac에서 %@에 연결할 수 없습니다. 회의에서는 우선 이 Mac에서 인식합니다.";
+"%@ 没接受音频(HTTP %lld),开会时先用本机识别。" = "%@이(가) 오디오를 받지 않았습니다(HTTP %lld). 회의에서는 우선 이 Mac에서 인식합니다.";
"开了代理也连不上:换一个节点,或检查代理软件是否放过 %@。" = "프록시가 켜져 있는데도 연결되지 않습니다. 다른 서버로 바꾸거나 프록시 앱이 %@를 통과시키는지 확인하세요.";
"代理软件在运行(端口 %@),但没开系统代理。在代理软件里打开“系统代理”。" = "프록시 앱이 실행 중이지만(포트 %@) 시스템 프록시가 꺼져 있습니다. 프록시 앱에서 ‘시스템 프록시’를 켜세요.";
"这台电脑没开代理。在国内通常要开代理才能用 %@。" = "프록시가 꺼져 있습니다. 중국 본토에서는 보통 %@를 쓰려면 프록시가 필요합니다.";
@@ -84,31 +88,58 @@
"同传念给对方" = "동시통역 시 상대방에게 들려줄 음성";
"一小时会议约 ¥0.15–1(目前优惠价)。说话的声音分段发给 Ling 识别和翻译;会议录音和文字记录只存在这台 Mac 上。" = "1시간 회의 기준 약 ¥0.15–1(현재 할인가). 발화 음성은 짧은 구간으로 나뉘어 Ling에서 인식·번역되며, 회의 녹음과 대화 기록은 이 Mac에만 저장됩니다.";
"一小时会议约 ¥0.15–1(目前优惠价)。发出去的只有文字(用你自己的声音时还有那段录音),语音识别留在本机。" = "시간당 회의 비용은 약 ¥0.15–1입니다(현재 할인가). 전송되는 것은 텍스트뿐이며(내 목소리를 쓸 때는 그 녹음도 포함), 음성 인식은 이 Mac에서 처리됩니다.";
+"跑在你自己的机器上,不按量计费。" = "내 컴퓨터에서 실행되어 사용량 요금이 없습니다. ";
+"费用以这个服务为准。" = "요금은 이 서비스 기준을 따릅니다. ";
+"会议的声音会发给你的服务识别。" = "회의 음성은 내 서비스로 보내져 인식됩니다.";
+"发出去的只有文字,语音识别留在本机。" = "보내는 것은 텍스트뿐이며, 음성 인식은 이 Mac에서 합니다.";
"按所选模型计费。发出去的只有文字,语音识别留在本机。" = "선택한 모델 기준으로 과금됩니다. 텍스트만 전송되며 음성 인식은 온디바이스에서 처리됩니다.";
-"在 %@ 创建 key,复制后粘贴到这里。" = "%@에서 key를 생성한 후 복사하여 여기에 붙여넣으세요.";
-"打开 %@ ↗" = "%@ 열기 ↗";
+"每样可以接不同的机器;这台 Mac 和局域网里的服务可以用 http。" = "기능마다 다른 컴퓨터를 쓸 수 있습니다. 이 Mac이나 로컬 네트워크의 서비스는 http도 쓸 수 있습니다.";
+"填上地址和模型" = "주소와 모델을 입력하세요";
+"正在检查…" = "확인 중…";
+"翻译和纪要" = "번역과 노트";
+"没填,用本机声音" = "설정 안 함: 이 Mac의 음성";
+"移除 key" = "키 제거";
+"key 只存在这台 Mac 上(只有你的账户能读),只发给 %@" = "키는 이 Mac에만 저장되고(내 계정만 읽을 수 있음) %@에만 보내집니다";
+"只存在这台 Mac 上(只有你的账户能读),只发给 %@(%@)" = "이 Mac에만 저장되며(내 계정만 읽기 가능) %@(%@)에만 전송됩니다";
"暂时连不上" = "지금은 연결할 수 없음";
"这个 key 用不了" = "이 key는 사용할 수 없음";
"模型用不了" = "모델을 쓸 수 없음";
"还没填好" = "아직 입력되지 않음";
"还没填 API key" = "API key 없음";
-"正在检查…" = "확인 중…";
"已连接" = "연결됨";
+"翻一句 %@ 秒" = "한 문장 %@초";
+"地址" = "주소";
+"例如 qwen3:14b" = "예: qwen3:14b";
+"这是 %@ 的 key。" = "%@ key입니다.";
+"更换" = "변경";
+"保存并检查" = "저장 및 확인";
+"本机和局域网服务可不填" = "이 Mac이나 로컬 네트워크에서는 생략 가능";
+"能写纪要" = "노트 작성 가능";
+"纪要写不了" = "노트 작성 불가";
+"会先思考" = "먼저 생각함";
+"不思考" = "생각하지 않음";
+"上次正常" = "지난번 정상";
+"上次没出声" = "지난번 소리 없음";
+"需支持 /audio/speech;不填则用本机声音。" = "/audio/speech 지원 필요. 비워두면 온디바이스 음성을 사용합니다.";
+"例如 qwen3-tts" = "예: qwen3-tts";
+"声音" = "목소리";
+"例如 vivian" = "예: vivian";
+"跟上面一样" = "위와 동일";
+"自建服务" = "내 서비스";
+"会议的声音会发到 %@;连不上时用本机" = "회의 음성은 %@(으)로 보내집니다. 연결이 안 되면 이 Mac에서 인식";
+"更快,不花钱,声音不出这台 Mac" = "더 빠르고 무료이며, 음성이 이 Mac 밖으로 나가지 않습니다";
+"需支持 /audio/transcriptions,例如 Qwen3-ASR、Whisper。下一场会议起生效。" = "/audio/transcriptions를 지원해야 합니다(예: Qwen3-ASR, Whisper). 다음 회의부터 적용됩니다.";
+"填上模型才会用它识别。" = "모델을 입력해야 그 모델로 인식합니다.";
+"例如 qwen3-asr" = "예: qwen3-asr";
+"听一秒音频 %@ 秒" = "1초 음성을 %@초에 인식";
+"在 %@ 创建 key,复制后粘贴到这里。" = "%@에서 key를 생성한 후 복사하여 여기에 붙여넣으세요.";
+"打开 %@ ↗" = "%@ 열기 ↗";
"%@ 现在很忙" = "%@가 지금 붐빕니다";
"填入 Ling key 后才能识别语音、出字幕和纪要" = "자막과 회의록에는 Ling 키가 필요합니다";
"不填 key 时,字幕和翻译仍可正常使用" = "key 없이도 자막과 번역은 사용할 수 있습니다";
-"更换" = "변경";
-"保存并检查" = "저장 및 확인";
"取消" = "취소";
-"本机服务可不填" = "로컬 서비스는 비워둘 수 있음";
-"这是 %@ 的 key。" = "%@ key입니다.";
"改用 %@" = "%@로 바꾸기";
"移除" = "제거";
-"只存在这台 Mac 上(只有你的账户能读),只发给 %@" = "이 Mac에만 저장되며(내 계정만 읽기 가능) %@에만 전송됩니다";
-"只存在这台 Mac 上(只有你的账户能读),只发给 %@(%@)" = "이 Mac에만 저장되며(내 계정만 읽기 가능) %@(%@)에만 전송됩니다";
-"地址需用 https,仅 localhost 可用 http。" = "주소는 https를 사용해야 하며, localhost만 http를 사용할 수 있습니다.";
-"地址" = "주소";
-"例如 qwen3:14b" = "예: qwen3:14b";
"你填的地址" = "입력한 주소";
"%@ · 响应约 %@ 秒" = "%1$@ · 응답 약 %2$@초";
"先用本机声音" = "당분간 이 Mac의 음성 사용";
@@ -118,12 +149,8 @@
"没有 key 时用本机声音" = "key가 없으면 이 Mac의 음성 사용";
"没填声音模型,用本机声音" = "음성 모델 미입력, 온디바이스 음성 사용";
"%@ 暂不能出声音,用本机声音" = "%@에서 아직 음성을 지원하지 않아 온디바이스 음성 사용";
-"声音(可选)" = "음성 (선택 사항)";
-"需支持 /audio/speech;不填则用本机声音。" = "/audio/speech 지원 필요. 비워두면 온디바이스 음성을 사용합니다.";
"例如 kokoro" = "예: kokoro";
-"声音" = "목소리";
"例如 af_heart" = "예: af_heart";
-"跟上面一样" = "위와 동일";
"其他(兼容 OpenAI)" = "기타 (OpenAI 호환)";
"(推荐)" = " (추천)";
"模型名" = "모델 이름";
@@ -368,6 +395,7 @@
"识别出错,%lld 秒后重试" = "인식 오류, %lld초 후 다시 시도합니다";
"听不出是哪种语言,到菜单栏里选一下" = "언어를 알 수 없어요. 메뉴 막대에서 골라 주세요";
"正在识别语言…" = "언어 감지 중…";
+"%@ 暂时连不上,先用本机识别" = "%@에 연결할 수 없어 우선 이 Mac에서 인식합니다";
"key 已失效,到设置 › AI 服务里重填" = "키가 더 이상 작동하지 않습니다. 설정 › AI 서비스에서 다시 입력하세요";
"%@ 暂时连不上,正在重试" = "%@에 연결할 수 없습니다. 다시 시도하는 중";
"翻译暂不可用" = "번역을 일시적으로 사용할 수 없음";
diff --git a/Resources/zh-Hans.lproj/Localizable.strings b/Resources/zh-Hans.lproj/Localizable.strings
index d410f90..b90af94 100644
--- a/Resources/zh-Hans.lproj/Localizable.strings
+++ b/Resources/zh-Hans.lproj/Localizable.strings
@@ -3,7 +3,7 @@
"key 可以用" = "key 可以用";
"纪要和翻译" = "纪要和翻译";
"这台 Mac 访问不到 %@。" = "这台 Mac 访问不到 %@。";
-"地址要用 https,只有 localhost 可以用 http。" = "地址要用 https,只有 localhost 可以用 http。";
+"地址要用 https;这台 Mac 和局域网里的服务可以用 http。" = "地址要用 https;这台 Mac 和局域网里的服务可以用 http。";
"%@ 说这个 key 无效,可能没复制全,或已删除。" = "%@ 说这个 key 无效,可能没复制全,或已删除。";
"这是 ZenMux 的管理 key,不能用来调用模型。请粘贴 sk-payg 开头的 key。" = "这是 ZenMux 的管理 key,不能用来调用模型。请粘贴 sk-payg 开头的 key。";
"%@ 账户余额不足。" = "%@ 账户余额不足。";
@@ -11,6 +11,10 @@
"这个服务不支持 JSON,纪要写不了;翻译照常。" = "这个服务不支持 JSON,纪要写不了;翻译照常。";
"%@ 现在很忙,key 没问题。开会时会自动重试。" = "%@ 现在很忙,key 没问题。开会时会自动重试。";
"%@ 暂时出错(HTTP %lld),稍后再试。" = "%@ 暂时出错(HTTP %lld),稍后再试。";
+"这个模型先思考再回答,翻一句要 %@ 秒,超过 6 秒会改用 Google。在服务端关掉思考,或换一个不思考的模型。" = "这个模型先思考再回答,翻一句要 %@ 秒,超过 6 秒会改用 Google。在服务端关掉思考,或换一个不思考的模型。";
+"翻一句要 %@ 秒,超过 6 秒会改用 Google。换一个更小的模型会快一些。" = "翻一句要 %@ 秒,超过 6 秒会改用 Google。换一个更小的模型会快一些。";
+"这台 Mac 访问不到 %@,开会时先用本机识别。" = "这台 Mac 访问不到 %@,开会时先用本机识别。";
+"%@ 没接受音频(HTTP %lld),开会时先用本机识别。" = "%@ 没接受音频(HTTP %lld),开会时先用本机识别。";
"开了代理也连不上:换一个节点,或检查代理软件是否放过 %@。" = "开了代理也连不上:换一个节点,或检查代理软件是否放过 %@。";
"代理软件在运行(端口 %@),但没开系统代理。在代理软件里打开“系统代理”。" = "代理软件在运行(端口 %@),但没开系统代理。在代理软件里打开“系统代理”。";
"这台电脑没开代理。在国内通常要开代理才能用 %@。" = "这台电脑没开代理。在国内通常要开代理才能用 %@。";
@@ -84,31 +88,58 @@
"同传念给对方" = "同传念给对方";
"一小时会议约 ¥0.15–1(目前优惠价)。说话的声音分段发给 Ling 识别和翻译;会议录音和文字记录只存在这台 Mac 上。" = "一小时会议约 ¥0.15–1(目前优惠价)。说话的声音分段发给 Ling 识别和翻译;会议录音和文字记录只存在这台 Mac 上。";
"一小时会议约 ¥0.15–1(目前优惠价)。发出去的只有文字(用你自己的声音时还有那段录音),语音识别留在本机。" = "一小时会议约 ¥0.15–1(目前优惠价)。发出去的只有文字(用你自己的声音时还有那段录音),语音识别留在本机。";
+"跑在你自己的机器上,不按量计费。" = "跑在你自己的机器上,不按量计费。";
+"费用以这个服务为准。" = "费用以这个服务为准。";
+"会议的声音会发给你的服务识别。" = "会议的声音会发给你的服务识别。";
+"发出去的只有文字,语音识别留在本机。" = "发出去的只有文字,语音识别留在本机。";
"按所选模型计费。发出去的只有文字,语音识别留在本机。" = "按所选模型计费。发出去的只有文字,语音识别留在本机。";
-"在 %@ 创建 key,复制后粘贴到这里。" = "在 %@ 创建 key,复制后粘贴到这里。";
-"打开 %@ ↗" = "打开 %@ ↗";
+"每样可以接不同的机器;这台 Mac 和局域网里的服务可以用 http。" = "每样可以接不同的机器;这台 Mac 和局域网里的服务可以用 http。";
+"填上地址和模型" = "填上地址和模型";
+"正在检查…" = "正在检查…";
+"翻译和纪要" = "翻译和纪要";
+"没填,用本机声音" = "没填,用本机声音";
+"移除 key" = "移除 key";
+"key 只存在这台 Mac 上(只有你的账户能读),只发给 %@" = "key 只存在这台 Mac 上(只有你的账户能读),只发给 %@";
+"只存在这台 Mac 上(只有你的账户能读),只发给 %@(%@)" = "只存在这台 Mac 上(只有你的账户能读),只发给 %@(%@)";
"暂时连不上" = "暂时连不上";
"这个 key 用不了" = "这个 key 用不了";
"模型用不了" = "模型用不了";
"还没填好" = "还没填好";
"还没填 API key" = "还没填 API key";
-"正在检查…" = "正在检查…";
"已连接" = "已连接";
+"翻一句 %@ 秒" = "翻一句 %@ 秒";
+"地址" = "地址";
+"例如 qwen3:14b" = "例如 qwen3:14b";
+"这是 %@ 的 key。" = "这是 %@ 的 key。";
+"更换" = "更换";
+"保存并检查" = "保存并检查";
+"本机和局域网服务可不填" = "本机和局域网服务可不填";
+"能写纪要" = "能写纪要";
+"纪要写不了" = "纪要写不了";
+"会先思考" = "会先思考";
+"不思考" = "不思考";
+"上次正常" = "上次正常";
+"上次没出声" = "上次没出声";
+"需支持 /audio/speech;不填则用本机声音。" = "需支持 /audio/speech;不填则用本机声音。";
+"例如 qwen3-tts" = "例如 qwen3-tts";
+"声音" = "声音";
+"例如 vivian" = "例如 vivian";
+"跟上面一样" = "跟上面一样";
+"自建服务" = "自建服务";
+"会议的声音会发到 %@;连不上时用本机" = "会议的声音会发到 %@;连不上时用本机";
+"更快,不花钱,声音不出这台 Mac" = "更快,不花钱,声音不出这台 Mac";
+"需支持 /audio/transcriptions,例如 Qwen3-ASR、Whisper。下一场会议起生效。" = "需支持 /audio/transcriptions,例如 Qwen3-ASR、Whisper。下一场会议起生效。";
+"填上模型才会用它识别。" = "填上模型才会用它识别。";
+"例如 qwen3-asr" = "例如 qwen3-asr";
+"听一秒音频 %@ 秒" = "听一秒音频 %@ 秒";
+"在 %@ 创建 key,复制后粘贴到这里。" = "在 %@ 创建 key,复制后粘贴到这里。";
+"打开 %@ ↗" = "打开 %@ ↗";
"%@ 现在很忙" = "%@ 现在很忙";
"填入 Ling key 后才能识别语音、出字幕和纪要" = "填入 Ling key 后才能识别语音、出字幕和纪要";
"不填 key 时,字幕和翻译仍可正常使用" = "不填 key 时,字幕和翻译仍可正常使用";
-"更换" = "更换";
-"保存并检查" = "保存并检查";
"取消" = "取消";
-"本机服务可不填" = "本机服务可不填";
-"这是 %@ 的 key。" = "这是 %@ 的 key。";
"改用 %@" = "改用 %@";
"移除" = "移除";
-"只存在这台 Mac 上(只有你的账户能读),只发给 %@" = "只存在这台 Mac 上(只有你的账户能读),只发给 %@";
-"只存在这台 Mac 上(只有你的账户能读),只发给 %@(%@)" = "只存在这台 Mac 上(只有你的账户能读),只发给 %@(%@)";
-"地址需用 https,仅 localhost 可用 http。" = "地址需用 https,仅 localhost 可用 http。";
-"地址" = "地址";
-"例如 qwen3:14b" = "例如 qwen3:14b";
"你填的地址" = "你填的地址";
"%@ · 响应约 %@ 秒" = "%@ · 响应约 %@ 秒";
"先用本机声音" = "先用本机声音";
@@ -118,12 +149,8 @@
"没有 key 时用本机声音" = "没有 key 时用本机声音";
"没填声音模型,用本机声音" = "没填声音模型,用本机声音";
"%@ 暂不能出声音,用本机声音" = "%@ 暂不能出声音,用本机声音";
-"声音(可选)" = "声音(可选)";
-"需支持 /audio/speech;不填则用本机声音。" = "需支持 /audio/speech;不填则用本机声音。";
"例如 kokoro" = "例如 kokoro";
-"声音" = "声音";
"例如 af_heart" = "例如 af_heart";
-"跟上面一样" = "跟上面一样";
"其他(兼容 OpenAI)" = "其他(兼容 OpenAI)";
"(推荐)" = "(推荐)";
"模型名" = "模型名";
@@ -368,6 +395,7 @@
"识别出错,%lld 秒后重试" = "识别出错,%lld 秒后重试";
"听不出是哪种语言,到菜单栏里选一下" = "听不出是哪种语言,到菜单栏里选一下";
"正在识别语言…" = "正在识别语言…";
+"%@ 暂时连不上,先用本机识别" = "%@ 暂时连不上,先用本机识别";
"key 已失效,到设置 › AI 服务里重填" = "key 已失效,到设置 › AI 服务里重填";
"%@ 暂时连不上,正在重试" = "%@ 暂时连不上,正在重试";
"翻译暂不可用" = "翻译暂不可用";
diff --git a/Sources/Cicada/AICheck.swift b/Sources/Cicada/AICheck.swift
index 6d14f87..f4167aa 100644
--- a/Sources/Cicada/AICheck.swift
+++ b/Sources/Cicada/AICheck.swift
@@ -49,6 +49,29 @@ struct AICheck: Equatable {
var proxy: ProxyHint?
/// OpenRouter only: dollars left (the smaller of the key's limit and the account's credits).
var balance: Double?
+ /// A custom service: how long one real sentence took, and whether the model thought first.
+ var translate: Speed?
+ /// A custom service that recognizes the meeting: whether its speech model took audio.
+ var hear: Hearing?
+
+ struct Speed: Equatable {
+ let seconds: Double
+ let thinks: Bool
+ /// A sentence that takes this long often misses the 6 s a translation is given and falls
+ /// back to Google.
+ static let slowAfter = 3.0
+ var slow: Bool { thinks || seconds >= Self.slowAfter }
+ }
+
+ enum Hearing: Equatable {
+ case ok(seconds: Double)
+ case unreachable
+ case fail(code: Int?)
+ var ok: Bool { if case .ok = self { true } else { false } }
+ }
+
+ /// Text works but every sentence is slow (a thinking model): translations will fall back.
+ var slow: Bool { failure == nil && translate?.slow == true }
static let lowBalance = 0.5
@@ -175,7 +198,7 @@ struct AICheck: Equatable {
guard let f = failure else { return busy ? L("\(service) 现在很忙,key 没问题。开会时会自动重试。") : nil }
switch f.reason {
case .unreachable: return L("这台 Mac 访问不到 \(host)。")
- case .badAddress: return L("地址要用 https,只有 localhost 可以用 http。")
+ case .badAddress: return L("地址要用 https;这台 Mac 和局域网里的服务可以用 http。")
case .invalidKey: return L("\(service) 说这个 key 无效,可能没复制全,或已删除。")
case .mgmtKey: return L("这是 ZenMux 的管理 key,不能用来调用模型。请粘贴 sk-payg 开头的 key。")
case .noCredit: return L("\(service) 账户余额不足。")
@@ -186,6 +209,23 @@ struct AICheck: Equatable {
}
}
+ /// Why translations are slow, and what to do (a custom service).
+ func slowLine() -> String? {
+ guard slow, let t = translate else { return nil }
+ let secs = String(format: "%.1f", t.seconds)
+ return t.thinks ? L("这个模型先思考再回答,翻一句要 \(secs) 秒,超过 6 秒会改用 Google。在服务端关掉思考,或换一个不思考的模型。")
+ : L("翻一句要 \(secs) 秒,超过 6 秒会改用 Google。换一个更小的模型会快一些。")
+ }
+
+ /// The speech model's problem, in one sentence.
+ func hearLine(host: String, model: String) -> String? {
+ switch hear {
+ case .unreachable?: return L("这台 Mac 访问不到 \(host),开会时先用本机识别。")
+ case .fail(let code)?: return L("\(model) 没接受音频(HTTP \(code ?? 0)),开会时先用本机识别。")
+ default: return nil
+ }
+ }
+
/// The proxy line under "can't reach": what this Mac's proxy looks like, and what to do.
func proxyLine(service: String, host: String) -> String? {
guard failure?.reason == .unreachable, let proxy else { return nil }
@@ -218,5 +258,7 @@ struct AICheck: Equatable {
return "\(s.id.rawValue)=\(v)"
}.joined(separator: " ") + (proxy.map { " proxy=\($0)" } ?? "") + (balance.map { " balance=\(String(format: "%.2f", $0))" } ?? "")
+ (passive ? " passive" : "")
+ + (translate.map { " translate=\(String(format: "%.1f", $0.seconds))s\($0.thinks ? " thinks" : "")" } ?? "")
+ + (hear.map { " hear=\($0)" } ?? "")
}
}
diff --git a/Sources/Cicada/AIProviders.swift b/Sources/Cicada/AIProviders.swift
index f02b116..a67ee93 100644
--- a/Sources/Cicada/AIProviders.swift
+++ b/Sources/Cicada/AIProviders.swift
@@ -85,20 +85,45 @@ struct AIProvider: Identifiable, Equatable {
static func named(_ raw: String) -> AIProvider { all.first { $0.id.rawValue == raw } ?? .ling }
- /// http only on this Mac (Ollama, LM Studio); anything else must be https.
+ /// http only on this Mac or the local network (Ollama, LM Studio, a GPU box at home or work, a
+ /// Tailscale address); anything else must be https.
static func customBase(_ raw: String) -> URL? {
var s = raw.trimmingCharacters(in: .whitespacesAndNewlines)
guard !s.isEmpty else { return nil }
- if !s.contains("://") { s = (isLocal(s) ? "http://" : "https://") + s }
+ if !s.contains("://") { s = (isNearby(s) ? "http://" : "https://") + s }
if !s.hasSuffix("/") { s += "/" }
guard let url = URL(string: s), let host = url.host, !host.isEmpty else { return nil }
if url.scheme == "https" { return url }
- return url.scheme == "http" && isLocal(host) ? url : nil
+ return url.scheme == "http" && isNearby(host) ? url : nil
}
+ /// This Mac: a key isn't needed.
static func isLocal(_ hostOrURL: String) -> Bool {
- let host = URL(string: hostOrURL.contains("://") ? hostOrURL : "http://" + hostOrURL)?.host ?? hostOrURL
- return ["localhost", "127.0.0.1", "::1"].contains(host)
+ ["localhost", "127.0.0.1", "::1"].contains(host(of: hostOrURL))
+ }
+
+ /// This Mac or the local network: plain http is allowed and a key isn't needed. Private IPv4
+ /// (10/8, 172.16/12, 192.168/16), link-local, Tailscale's 100.64/10, IPv6 unique and link-local
+ /// addresses, and `.local` names.
+ static func isNearby(_ hostOrURL: String) -> Bool {
+ let h = host(of: hostOrURL).lowercased()
+ if isLocal(h) || h.hasSuffix(".local") { return true }
+ let parts = h.split(separator: ".").compactMap { Int($0) }
+ if parts.count == 4, h.split(separator: ".").count == 4, parts.allSatisfy({ (0...255).contains($0) }) {
+ switch (parts[0], parts[1]) {
+ case (10, _), (192, 168), (169, 254): return true
+ case (172, 16...31), (100, 64...127): return true
+ default: return false
+ }
+ }
+ if h.contains(":") { return h.hasPrefix("fc") || h.hasPrefix("fd") || h.hasPrefix("fe80") }
+ return false
+ }
+
+ private static func host(of hostOrURL: String) -> String {
+ let s = hostOrURL.trimmingCharacters(in: .whitespaces)
+ let url = URL(string: s.contains("://") ? s : "http://" + s)
+ return (url?.host ?? s).trimmingCharacters(in: CharacterSet(charactersIn: "[]"))
}
}
@@ -120,8 +145,14 @@ struct AIConfig: Equatable {
var voiceBase: URL?
/// The voice a custom speech model speaks with (others pick per language).
var customVoice: String?
+ /// A custom service's speech recognition model (`/audio/transcriptions`) and its address; nil
+ /// when recognition stays on this Mac.
+ var hearModel: String? = nil
+ var hearBase: URL? = nil
var hasVoices: Bool { voiceModel != nil && voiceBase != nil }
+ /// The meeting is recognized by the custom service instead of on this Mac.
+ var transcribes: Bool { provider.id == .custom && hearModel != nil && hearBase != nil }
/// The voices the room can pick from with this service.
var voices: [CloudVoice] {
@@ -131,8 +162,11 @@ struct AIConfig: Equatable {
}
/// The request body, shaped for the service: each one turns thinking off its own way, and
- /// OpenAI's current models take neither `max_tokens` nor a temperature.
- func shape(_ body: inout [String: Any], maxTokens: Int) {
+ /// OpenAI's current models take neither `max_tokens` nor a temperature. A custom service gets
+ /// `chat_template_kwargs` (vLLM, SGLang and llama.cpp pass it to the chat template, which is
+ /// how Qwen3 turns thinking off); `templateKwargs` false leaves it out for a server that
+ /// refused it.
+ func shape(_ body: inout [String: Any], maxTokens: Int, templateKwargs: Bool = true) {
switch provider.id {
case .ling:
body["max_tokens"] = maxTokens
@@ -148,7 +182,20 @@ struct AIConfig: Equatable {
case .custom:
body["max_tokens"] = maxTokens
body["temperature"] = 0.2
+ if templateKwargs { body["chat_template_kwargs"] = ["enable_thinking": false] }
+ }
+ }
+
+ /// The model thought before answering, which makes every translation slow: a `reasoning_content`
+ /// (or `reasoning`) field, reasoning tokens in the usage, or a `<think>` block in the answer.
+ static func thought(_ root: [String: Any]) -> Bool {
+ let message = ((root["choices"] as? [[String: Any]])?.first?["message"]) as? [String: Any]
+ for k in ["reasoning_content", "reasoning"] {
+ if let r = message?[k] as? String, !r.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty { return true }
}
+ let details = (root["usage"] as? [String: Any])?["completion_tokens_details"] as? [String: Any]
+ if let n = details?["reasoning_tokens"] as? Int, n > 0 { return true }
+ return (message?["content"] as? String)?.contains("<think>") ?? false
}
/// Text models from a `/models` reply, recommended ones first. Leaves out what cannot chat
@@ -162,7 +209,7 @@ struct AIConfig: Equatable {
let arch = m["architecture"] as? [String: Any]
let out = (m["output_modalities"] ?? arch?["output_modalities"]) as? [String]
if let out, out != ["text"], !out.contains("text") { continue }
- if out == nil, id.range(of: #"(embed|whisper|tts|transcribe|dall-e|image|moderation|realtime|audio|sora|search)"#,
+ if out == nil, id.range(of: #"(embed|whisper|tts|asr|transcribe|dall-e|image|moderation|realtime|audio|sora|search)"#,
options: .regularExpression) != nil { continue }
ids.append(id)
}
diff --git a/Sources/Cicada/AISettings.swift b/Sources/Cicada/AISettings.swift
index 12faba3..8e5cf1f 100644
--- a/Sources/Cicada/AISettings.swift
+++ b/Sources/Cicada/AISettings.swift
@@ -18,7 +18,13 @@ struct AISettingsView: View {
private var provider: AIProvider { settings.provider }
private var name: String { provider.name }
+ @State private var open: Set<String> = []
+
var body: some View {
+ if provider.id == .custom { customPage } else { servicePage }
+ }
+
+ private var servicePage: some View {
VStack(alignment: .leading, spacing: 14) {
keyCard
Text("现在能用的").font(.system(size: 13, weight: .semibold)).foregroundStyle(Palette.secondary)
@@ -41,6 +47,234 @@ struct AISettingsView: View {
.onChange(of: settings.aiProvider) { _, _ in syncDrafts(); editing = false; draft = ""; keyHint = nil }
}
+ // MARK: Own service
+
+ /// 其他(兼容 OpenAI): one row per use, each at its own address if need be (a text model, a
+ /// speech model and a recognition model often run as separate servers), each saying whether it
+ /// works and how fast. Recognition stays on this Mac unless the user picks their service.
+ private var customPage: some View {
+ VStack(alignment: .leading, spacing: 14) {
+ Text("每样可以接不同的机器;这台 Mac 和局域网里的服务可以用 http。")
+ .font(.system(size: 12)).foregroundStyle(Palette.tertiary).fixedSize(horizontal: false, vertical: true)
+ SettingsCard {
+ textSection
+ Divider()
+ voiceSection
+ Divider()
+ hearSection
+ }
+ HStack(spacing: 6) {
+ Image(systemName: "lock").font(.system(size: 11)).foregroundStyle(Palette.tertiary)
+ Text(lockLine).font(.system(size: 11)).foregroundStyle(Palette.tertiary).fixedSize(horizontal: false, vertical: true)
+ Spacer()
+ if let key = ling.key, !key.isEmpty {
+ Button("移除 key") { ling.removeKey() }
+ .buttonStyle(.plain).font(.system(size: 11)).foregroundStyle(Palette.secondary)
+ }
+ }
+ Text(footnote).font(.system(size: 12)).foregroundStyle(Palette.tertiary)
+ .fixedSize(horizontal: false, vertical: true)
+ }
+ .onAppear {
+ syncDrafts()
+ // A service that isn't set up yet, or doesn't work, opens where it needs filling in.
+ if open.isEmpty, !ling.aiCheck.passed || ling.aiCheck.slow { open = ["text"] }
+ }
+ .onChange(of: settings.aiProvider) { _, _ in syncDrafts(); editing = false; draft = ""; keyHint = nil }
+ }
+
+ /// A row that opens to its fields: a state dot, the use, what it runs on, and how it's doing.
+ private func sectionHeader(_ id: String, title: String, detail: String, dot: Color, trailing: String?,
+ trailingColor: Color = Palette.tertiary) -> some View {
+ Button {
+ withAnimation(.easeOut(duration: 0.15)) { if open.contains(id) { open.remove(id) } else { open.insert(id) } }
+ } label: {
+ HStack(spacing: 10) {
+ Circle().fill(dot).frame(width: 8, height: 8)
+ VStack(alignment: .leading, spacing: 2) {
+ Text(title).font(.system(size: 13)).foregroundStyle(Palette.ink)
+ Text(detail).font(.system(size: 11)).foregroundStyle(Palette.tertiary).lineLimit(1).truncationMode(.middle)
+ }
+ Spacer(minLength: 8)
+ if let trailing {
+ Text(trailing).font(.system(size: 12).monospacedDigit()).foregroundStyle(trailingColor).lineLimit(1).fixedSize()
+ }
+ Image(systemName: "chevron.right").font(.system(size: 9, weight: .semibold)).foregroundStyle(Palette.secondary)
+ .rotationEffect(.degrees(open.contains(id) ? 90 : 0))
+ }
+ .padding(.horizontal, 16).frame(minHeight: 52).contentShape(Rectangle())
+ }
+ .buttonStyle(.plain)
+ }
+
+ private var textHost: String { AIProvider.customBase(baseDraft)?.host ?? settings.aiConfig.base?.host ?? "" }
+
+ @ViewBuilder private var textSection: some View {
+ let check = ling.aiCheck
+ let model = settings.aiModels["custom"] ?? ""
+ let detail = textHost.isEmpty || model.isEmpty ? L("填上地址和模型") : "\(textHost) · \(model)"
+ let trailing: String? = check.running ? L("正在检查…") : check.failure != nil && ling.hasKey ? statusTitle
+ : check.translate.map { L("翻一句 \(String(format: "%.1f", $0.seconds)) 秒") }
+ sectionHeader("text", title: L("翻译和纪要"), detail: detail, dot: customTextDot, trailing: trailing,
+ trailingColor: check.slow ? Palette.warn : check.failure != nil ? Palette.error : Palette.tertiary)
+ if open.contains("text") {
+ VStack(alignment: .leading, spacing: 8) {
+ field(L("地址"), "http://192.168.1.20:8000/v1", $baseDraft)
+ if !baseDraft.isEmpty, AIProvider.customBase(baseDraft) == nil {
+ Text("地址要用 https;这台 Mac 和局域网里的服务可以用 http。").font(.system(size: 11)).foregroundStyle(Palette.error)
+ .padding(.leading, 42)
+ }
+ HStack(spacing: 8) {
+ Text("模型").font(.system(size: 12)).foregroundStyle(Palette.secondary).frame(minWidth: 34, alignment: .leading).fixedSize()
+ if ling.catalog.isEmpty {
+ TextField(L("例如 qwen3:14b"), text: $textDraft)
+ .textFieldStyle(.plain).font(.system(size: 13, design: .monospaced))
+ .padding(.horizontal, 12).frame(height: 32)
+ .background(RoundedRectangle(cornerRadius: 9).fill(Color.white))
+ .overlay(RoundedRectangle(cornerRadius: 9).stroke(Palette.line, lineWidth: 1))
+ .onSubmit(save)
+ } else {
+ // The models the service lists: picking one saves and checks it.
+ ModelMenu(value: textDraft, recommended: [], catalog: ling.catalog) {
+ textDraft = $0
+ save()
+ }
+ Spacer()
+ }
+ }
+ HStack(spacing: 8) {
+ Text("key").font(.system(size: 12)).foregroundStyle(Palette.secondary).frame(minWidth: 34, alignment: .leading).fixedSize()
+ if let key = ling.key, !key.isEmpty, !editing {
+ Text(AIKey.masked(key)).font(.system(size: 13, design: .monospaced)).foregroundStyle(Palette.ink)
+ .padding(.horizontal, 12).frame(maxWidth: .infinity, minHeight: 32, alignment: .leading)
+ .background(RoundedRectangle(cornerRadius: 9).fill(Color.white))
+ .overlay(RoundedRectangle(cornerRadius: 9).stroke(Palette.line, lineWidth: 1))
+ SoftButton(L("更换")) { draft = ""; editing = true }
+ } else {
+ SecureField(keyPlaceholder, text: $draft)
+ .textFieldStyle(.plain).font(.system(size: 13, design: .monospaced))
+ .padding(.horizontal, 12).frame(height: 32)
+ .background(RoundedRectangle(cornerRadius: 9).fill(Color.white))
+ .overlay(RoundedRectangle(cornerRadius: 9).stroke(Palette.line, lineWidth: 1))
+ .onSubmit(save)
+ }
+ SoftButton(check.running ? L("正在检查…") : L("保存并检查"), dark: true, action: save)
+ .disabled(check.running)
+ }
+ if let hint = keyHint {
+ Text(hint.text).font(.system(size: 12)).foregroundStyle(Palette.error).fixedSize(horizontal: false, vertical: true)
+ }
+ if let slow = check.slowLine() {
+ Text(slow).font(.system(size: 12)).foregroundStyle(Palette.warn).fixedSize(horizontal: false, vertical: true)
+ }
+ if showSteps {
+ AICheckSteps(model: model_, ling: ling, recheckInStep: false) { draft = ""; editing = true }
+ .padding(.horizontal, 12).padding(.vertical, 2)
+ .background(RoundedRectangle(cornerRadius: 10).fill(Color.white))
+ .overlay(RoundedRectangle(cornerRadius: 10).stroke(Palette.line, lineWidth: 1))
+ } else if check.passed {
+ Text(textFacts).font(.system(size: 11)).foregroundStyle(Palette.tertiary)
+ }
+ }
+ .padding(.leading, 34).padding(.trailing, 16).padding(.bottom, 14)
+ }
+ }
+
+ private var model_: AppModel { model }
+
+ /// "能写纪要 · 不思考": what the check proved beyond the speed.
+ private var textFacts: String {
+ var parts = [ling.aiCheck.failure == nil ? L("能写纪要") : L("纪要写不了")]
+ if let t = ling.aiCheck.translate { parts.append(t.thinks ? L("会先思考") : L("不思考")) }
+ return parts.joined(separator: " · ")
+ }
+
+ private var customTextDot: Color {
+ let check = ling.aiCheck
+ if !ling.hasKey { return Color(white: 0.75) }
+ if check.running { return Palette.accent }
+ if check.failure != nil { return Palette.error }
+ if check.slow || check.busy { return Palette.warn }
+ return check.passed ? Palette.ok : Color(white: 0.75)
+ }
+
+ @ViewBuilder private var voiceSection: some View {
+ let c = settings.aiConfig
+ let voiceModel = settings.aiVoiceModels["custom"] ?? ""
+ let host = c.voiceBase?.host ?? textHost
+ let detail = voiceModel.isEmpty ? L("没填,用本机声音")
+ : [host, voiceModel, settings.aiCustomVoice].filter { !$0.isEmpty }.joined(separator: " · ")
+ let last = ling.lastVoice
+ sectionHeader("voice", title: L("同传声音"), detail: detail,
+ dot: voiceModel.isEmpty ? Color(white: 0.75) : last.map { $0.ok ? Palette.ok : Palette.error } ?? Color(white: 0.75),
+ trailing: voiceModel.isEmpty ? L("本机") : last.map { $0.ok ? L("上次正常") : L("上次没出声") },
+ trailingColor: last?.ok == false ? Palette.error : Palette.tertiary)
+ if open.contains("voice") {
+ VStack(alignment: .leading, spacing: 8) {
+ Text("需支持 /audio/speech;不填则用本机声音。").font(.system(size: 11)).foregroundStyle(Palette.tertiary)
+ CommitField(label: L("模型"), placeholder: L("例如 qwen3-tts"), value: voiceModel) {
+ settings.aiVoiceModels["custom"] = $0
+ model.applyAIService()
+ }
+ CommitField(label: L("声音"), placeholder: L("例如 vivian"), value: settings.aiCustomVoice) {
+ settings.aiCustomVoice = $0
+ model.applyAIService()
+ }
+ CommitField(label: L("地址"), placeholder: L("跟上面一样"), value: settings.aiCustomVoiceBase) {
+ settings.aiCustomVoiceBase = $0
+ model.applyAIService()
+ }
+ }
+ .padding(.leading, 34).padding(.trailing, 16).padding(.bottom, 14)
+ }
+ }
+
+ @ViewBuilder private var hearSection: some View {
+ let c = settings.aiConfig
+ let own = settings.aiCustomRecognize
+ let hearModel = settings.aiCustomHearModel
+ let host = (settings.aiCustomHearBase.isEmpty ? c.base : AIProvider.customBase(settings.aiCustomHearBase))?.host ?? textHost
+ let hear = ling.aiCheck.hear
+ HStack(spacing: 10) {
+ Circle().fill(!own ? Palette.ok : hear?.ok == true ? Palette.ok : hear == nil ? Color(white: 0.75) : Palette.error)
+ .frame(width: 8, height: 8)
+ VStack(alignment: .leading, spacing: 2) {
+ Text("语音识别").font(.system(size: 13)).foregroundStyle(Palette.ink)
+ Text(own ? L("会议的声音会发到 \(host);连不上时用本机") : L("更快,不花钱,声音不出这台 Mac"))
+ .font(.system(size: 11)).foregroundStyle(Palette.tertiary).lineLimit(2).fixedSize(horizontal: false, vertical: true)
+ }
+ Spacer(minLength: 8)
+ Segments(options: [("mac", L("本机")), ("own", L("自建服务"))], value: own ? "own" : "mac") {
+ settings.aiCustomRecognize = $0 == "own"
+ if $0 == "own" { open.insert("hear") }
+ model.applyAIService()
+ }
+ }
+ .padding(.horizontal, 16).frame(minHeight: 52)
+ if own {
+ VStack(alignment: .leading, spacing: 8) {
+ Text("需支持 /audio/transcriptions,例如 Qwen3-ASR、Whisper。下一场会议起生效。")
+ .font(.system(size: 11)).foregroundStyle(Palette.tertiary).fixedSize(horizontal: false, vertical: true)
+ CommitField(label: L("模型"), placeholder: L("例如 qwen3-asr"), value: hearModel) {
+ settings.aiCustomHearModel = $0
+ model.applyAIService()
+ }
+ CommitField(label: L("地址"), placeholder: L("跟上面一样"), value: settings.aiCustomHearBase) {
+ settings.aiCustomHearBase = $0
+ model.applyAIService()
+ }
+ if hearModel.isEmpty {
+ Text("填上模型才会用它识别。").font(.system(size: 12)).foregroundStyle(Palette.warn)
+ } else if let line = ling.aiCheck.hearLine(host: host, model: hearModel) {
+ Text(line).font(.system(size: 12)).foregroundStyle(Palette.error).fixedSize(horizontal: false, vertical: true)
+ } else if case .ok(let s)? = hear {
+ Text(L("听一秒音频 \(String(format: "%.1f", s)) 秒")).font(.system(size: 11)).foregroundStyle(Palette.tertiary)
+ }
+ }
+ .padding(.leading, 34).padding(.trailing, 16).padding(.bottom, 14)
+ }
+ }
+
// MARK: Key
private var keyCard: some View {
@@ -53,7 +287,6 @@ struct AISettingsView: View {
}
Spacer()
}
- if provider.id == .custom { customFields }
if let key = ling.key, !key.isEmpty, !editing {
HStack(spacing: 8) {
Text(AIKey.masked(key)).font(.system(size: 13, design: .monospaced)).foregroundStyle(Palette.ink)
@@ -127,17 +360,6 @@ struct AISettingsView: View {
.background(RoundedRectangle(cornerRadius: 14).fill(Palette.raised))
}
- /// A custom service needs its address and a model before a key can be checked.
- private var customFields: some View {
- VStack(alignment: .leading, spacing: 8) {
- field(L("地址"), "https://api.example.com/v1", $baseDraft)
- field(L("模型"), L("例如 qwen3:14b"), $textDraft)
- if !baseDraft.isEmpty, AIProvider.customBase(baseDraft) == nil {
- Text("地址需用 https,仅 localhost 可用 http。").font(.system(size: 11)).foregroundStyle(Palette.error)
- }
- }
- }
-
private func field(_ label: String, _ placeholder: String, _ text: Binding<String>) -> some View {
HStack(spacing: 8) {
Text(label).font(.system(size: 12)).foregroundStyle(Palette.secondary).frame(minWidth: 34, alignment: .leading).fixedSize()
@@ -153,14 +375,14 @@ struct AISettingsView: View {
private var keyPlaceholder: String {
switch provider.id {
case .openrouter: "sk-or-…"
- case .custom: AIProvider.isLocal(baseDraft) ? L("本机服务可不填") : "sk-…"
+ case .custom: AIProvider.isNearby(baseDraft) ? L("本机和局域网服务可不填") : "sk-…"
default: "sk-…"
}
}
private var lockLine: String {
let host = provider.id == .custom ? (settings.aiConfig.base?.host ?? L("你填的地址")) : (provider.base?.host ?? "")
- return provider.id == .custom ? L("只存在这台 Mac 上(只有你的账户能读),只发给 \(host)")
+ return provider.id == .custom ? L("key 只存在这台 Mac 上(只有你的账户能读),只发给 \(host)")
: L("只存在这台 Mac 上(只有你的账户能读),只发给 \(name)(\(host))")
}
@@ -323,8 +545,6 @@ struct AISettingsView: View {
model.applyAIService()
}
}
- case .custom:
- customVoiceFields
default:
SettingsRow(title: L("文字模型"), detail: L("纪要和整句翻译"), divider: provider.hasVoices) {
ModelMenu(value: settings.textModel, recommended: provider.textModels, catalog: ling.catalog) {
@@ -343,34 +563,17 @@ struct AISettingsView: View {
}
}
- /// A custom service speaks only when given a speech model (`/audio/speech`), maybe at another address.
- private var customVoiceFields: some View {
- VStack(alignment: .leading, spacing: 8) {
- Text("声音(可选)").font(.system(size: 13)).foregroundStyle(Palette.ink)
- Text("需支持 /audio/speech;不填则用本机声音。").font(.system(size: 11)).foregroundStyle(Palette.tertiary)
- CommitField(label: L("模型"), placeholder: L("例如 kokoro"), value: settings.aiVoiceModels["custom"] ?? "") {
- settings.aiVoiceModels["custom"] = $0
- model.applyAIService()
- }
- CommitField(label: L("声音"), placeholder: L("例如 af_heart"), value: settings.aiCustomVoice) {
- settings.aiCustomVoice = $0
- model.applyAIService()
- }
- CommitField(label: L("地址"), placeholder: L("跟上面一样"), value: settings.aiCustomVoiceBase) {
- settings.aiCustomVoiceBase = $0
- model.applyAIService()
- }
- }
- .padding(.horizontal, 16).padding(.vertical, 12)
- }
-
private var footnote: String {
- if Recognition.cloudOnly {
+ if Recognition.cloudOnly, provider.id != .custom {
return L("一小时会议约 ¥0.15–1(目前优惠价)。说话的声音分段发给 Ling 识别和翻译;会议录音和文字记录只存在这台 Mac 上。")
}
- return switch provider.id {
- case .ling: L("一小时会议约 ¥0.15–1(目前优惠价)。发出去的只有文字(用你自己的声音时还有那段录音),语音识别留在本机。")
- default: L("按所选模型计费。发出去的只有文字,语音识别留在本机。")
+ switch provider.id {
+ case .ling: return L("一小时会议约 ¥0.15–1(目前优惠价)。发出去的只有文字(用你自己的声音时还有那段录音),语音识别留在本机。")
+ case .custom:
+ let nearby = settings.aiConfig.base.map { AIProvider.isNearby($0.absoluteString) } ?? false
+ let cost = nearby ? L("跑在你自己的机器上,不按量计费。") : L("费用以这个服务为准。")
+ return cost + (settings.aiConfig.transcribes ? L("会议的声音会发给你的服务识别。") : L("发出去的只有文字,语音识别留在本机。"))
+ default: return L("按所选模型计费。发出去的只有文字,语音识别留在本机。")
}
}
}
@@ -416,9 +619,11 @@ struct ModelMenu: View {
}
} else {
Menu {
- Section(L("推荐")) {
- ForEach(recommended, id: \.id) { m in
- Button(m.note.isEmpty ? m.id : "\(m.id) · \(m.note)") { onPick(m.id) }
+ if !recommended.isEmpty {
+ Section(L("推荐")) {
+ ForEach(recommended, id: \.id) { m in
+ Button(m.note.isEmpty ? m.id : "\(m.id) · \(m.note)") { onPick(m.id) }
+ }
}
}
let rest = catalog.filter { id in !recommended.contains { $0.id == id } }
diff --git a/Sources/Cicada/AppModel.swift b/Sources/Cicada/AppModel.swift
index 413749c..db024d4 100644
--- a/Sources/Cicada/AppModel.swift
+++ b/Sources/Cicada/AppModel.swift
@@ -1119,6 +1119,8 @@ final class AppModel: ObservableObject {
guard let id = self?.settings.provider.id, id != .ling else { return "ming" }
return id.rawValue
}
+ // Takes effect from the next meeting: one already running keeps how it listens.
+ Recognition.serverPreferred = c.transcribes
ling.reconfigure()
applyVoice()
}
@@ -1894,7 +1896,8 @@ final class AppModel: ObservableObject {
ling.simulateBalance = arg == "lowBalance" ? 0.4 : nil
Task { await ling.check() }
// AI service: aiProvider:<ling|openrouter|zenmux|openai|custom>, aiTextModel:<id>, aiVoiceModel:<id|"">,
- // aiCustomBase:<url>, aiCustomVoiceBase:<url|"">, aiCustomVoice:<name>.
+ // aiCustomBase:<url>, aiCustomVoiceBase:<url|"">, aiCustomVoice:<name>, aiCustomHearModel:<name>,
+ // aiCustomHearBase:<url|"">, aiCustomRecognize:on|off.
case "aiProvider": settings.aiProvider = AIProvider.named(arg).id.rawValue; applyAIService()
case "aiTextModel":
if settings.provider.id == .ling { settings.aiModel = arg } else { settings.aiModels[settings.aiProvider] = arg }
@@ -1903,6 +1906,9 @@ final class AppModel: ObservableObject {
case "aiCustomBase": settings.aiCustomBase = arg; applyAIService()
case "aiCustomVoiceBase": settings.aiCustomVoiceBase = arg; applyAIService()
case "aiCustomVoice": settings.aiCustomVoice = arg; applyAIService()
+ case "aiCustomHearModel": settings.aiCustomHearModel = arg; applyAIService()
+ case "aiCustomHearBase": settings.aiCustomHearBase = arg; applyAIService()
+ case "aiCustomRecognize": settings.aiCustomRecognize = arg == "on"; applyAIService()
case "subtitles": setSubtitles(arg)
case "meetingSubtitles": setSubtitles(arg, meetingOnly: true)
case "notesLang": setNotesLanguage(arg)
diff --git a/Sources/Cicada/Ling.swift b/Sources/Cicada/Ling.swift
index e35cd0a..3fa7eaf 100644
--- a/Sources/Cicada/Ling.swift
+++ b/Sources/Cicada/Ling.swift
@@ -188,13 +188,13 @@ final class LingClient: ObservableObject {
var session: URLSession = .shared
var hasKey: Bool { key != nil }
- /// The key for the service in use. A custom service on this Mac may need none: "".
+ /// The key for the service in use. A custom service on this Mac or the local network may need none: "".
var key: String? {
if hideKey { return nil }
let c = config()
if c.provider.id == .custom {
guard let base = c.base else { return nil }
- return AIKey.read(c.provider.id.rawValue) ?? (AIProvider.isLocal(base.absoluteString) ? "" : nil)
+ return AIKey.read(c.provider.id.rawValue) ?? (AIProvider.isNearby(base.absoluteString) ? "" : nil)
}
return AIKey.read(c.provider.id.rawValue)
}
@@ -206,6 +206,10 @@ final class LingClient: ObservableObject {
var clones: Bool { usable && provider.clones }
/// Speak-back heard by the service's audio model (Ming) instead of on this Mac.
var hearsAudio: Bool { usable && provider.hearsAudio }
+ /// The meeting recognized by the custom service's speech model instead of on this Mac.
+ var transcribes: Bool { usable && config().transcribes }
+ /// The custom service refused `chat_template_kwargs` once: leave it out until settings change.
+ private var noTemplateKwargs = false
init() {
keyState = AIKey.read() == nil ? .none : .unchecked
@@ -213,13 +217,25 @@ final class LingClient: ObservableObject {
/// Settings switched service, address or model: forget the old state and check again.
func reconfigure() {
+ noTemplateKwargs = false
+ recheck?.cancel()
catalog = []
listed = nil
aiCheck = AICheck()
lastVoice = nil
keyState = hasKey ? .unchecked : .none
- if hasKey { Task { await check() } }
+ // A custom service's check is two real requests (and a hear one): fields saved one after
+ // another check once, not once each.
+ if hasKey {
+ let wait = config().provider.id == .custom ? 0.8 : 0
+ recheck = Task { [weak self] in
+ if wait > 0 { try? await Task.sleep(for: .seconds(wait)) }
+ guard !Task.isCancelled else { return }
+ await self?.check()
+ }
+ }
}
+ private var recheck: Task<Void, Never>?
// MARK: Key
@@ -249,10 +265,12 @@ final class LingClient: ObservableObject {
/// custom service must also return JSON (the notes need it). The model list then tells whether
/// the chosen text model still exists.
func check() async {
- guard let key else { keyState = .none; aiCheck = AICheck(); return }
- keyState = .checking
+ // Counted before anything else: a slower check still running (a custom service that thinks
+ // for seconds) must not land on top of what this one finds, even "no key".
checkGeneration += 1
let generation = checkGeneration
+ guard let key else { keyState = .none; aiCheck = AICheck(); return }
+ keyState = .checking
let c = config()
var r = AICheck()
r[.reach] = .running
@@ -286,20 +304,31 @@ final class LingClient: ObservableObject {
case .openai:
_ = try await get("models", key: key)
r.pass(upTo: .key, seconds: Date().timeIntervalSince(started))
- case .zenmux, .custom:
+ case .zenmux:
var body: [String: Any] = ["model": c.textModel, "messages": [["role": "user", "content": "hi"]]]
c.shape(&body, maxTokens: 1)
_ = try await post("chat/completions", body: body, key: key, timeout: 20)
r.pass(upTo: .text, seconds: Date().timeIntervalSince(started))
- if c.provider.id == .custom {
- var json: [String: Any] = ["model": c.textModel, "response_format": ["type": "json_object"],
- "messages": [["role": "system", "content": "Reply with the JSON object {\"ok\": true}."],
- ["role": "user", "content": "Reply."]]]
- c.shape(&json, maxTokens: 20)
- do { _ = try await post("chat/completions", body: json, key: key, timeout: 20) } catch Failure.http(let code) {
- r.fail(.text, .noJSON, code: code)
- }
+ case .custom:
+ // A real sentence, the way a meeting translates: one token says nothing about a
+ // model that thinks for six seconds before every answer.
+ var body: [String: Any] = ["model": c.textModel, "messages": [
+ ["role": "system", "content": "Translate the text into Simplified Chinese. Reply with the translation only.\n\nWe will ship the new version on Friday after the design review."],
+ ["role": "user", "content": "Translate."]]]
+ c.shape(&body, maxTokens: 120, templateKwargs: !noTemplateKwargs)
+ let asked = Date()
+ let root = try await postChat(body, key: key, timeout: 30)
+ let seconds = Date().timeIntervalSince(asked)
+ r.pass(upTo: .text, seconds: Date().timeIntervalSince(started))
+ r.translate = AICheck.Speed(seconds: seconds, thinks: AIConfig.thought(root))
+ var json: [String: Any] = ["model": c.textModel, "response_format": ["type": "json_object"],
+ "messages": [["role": "system", "content": "Reply with the JSON object {\"ok\": true}."],
+ ["role": "user", "content": "Reply."]]]
+ c.shape(&json, maxTokens: 20, templateKwargs: !noTemplateKwargs)
+ do { _ = try await postChat(json, key: key, timeout: 30) } catch Failure.http(let code) {
+ r.fail(.text, .noJSON, code: code)
}
+ if r.failure == nil, c.transcribes { r.hear = await checkHearing(c, key: key) }
}
} catch let failure as Failure {
if let (step, reason, code) = AICheck.classify(failure, at: AICheck.firstStep(c.provider.id)) {
@@ -437,7 +466,7 @@ final class LingClient: ObservableObject {
],
"stream": false,
]
- c.shape(&body, maxTokens: maxTokens)
+ c.shape(&body, maxTokens: maxTokens, templateKwargs: !noTemplateKwargs)
if json { body["response_format"] = ["type": "json_object"] }
let waits = Self.retryWaits(priority, patient: patient)
for attempt in 1...(waits.count + 1) {
@@ -447,7 +476,7 @@ final class LingClient: ObservableObject {
onQueued?(queued)
let started = Date()
do {
- let root = try await post("chat/completions", body: body, key: key, timeout: timeout)
+ let root = try await postChat(body, key: key, timeout: timeout)
guard let choice = (root["choices"] as? [[String: Any]])?.first,
let message = choice["message"] as? [String: Any],
let text = message["content"] as? String else { throw Failure.parse }
@@ -623,8 +652,94 @@ final class LingClient: ObservableObject {
return wav
}
+ // MARK: Recognition
+
+ /// What the custom service's speech model heard in `wav` (a 16 kHz mono WAV): standard
+ /// `/audio/transcriptions` (Qwen3-ASR, Whisper servers, Fun-ASR). `language` (a BCP-47 code) is
+ /// the hint, for servers that take one. Throws like a chat call, so listening can tell a
+ /// service that is down from a quiet meeting.
+ func transcribe(_ wav: Data, language: String?, timeout: TimeInterval = 12) async throws -> (text: String, language: String?) {
+ guard let key else { throw Failure.noKey }
+ let c = config()
+ guard let base = c.hearBase, let model = c.hearModel else { throw Failure.noKey }
+ let asked = Date()
+ await acquire(.translate)
+ let queued = Date().timeIntervalSince(asked)
+ let started = Date()
+ let call = CallLabel(provider: c.provider.id.rawValue, model: model, role: "heard-them")
+ var req = URLRequest(url: base.appendingPathComponent("audio/transcriptions"))
+ req.httpMethod = "POST"
+ req.timeoutInterval = timeout
+ let boundary = "cicada-" + UUID().uuidString
+ req.setValue("multipart/form-data; boundary=\(boundary)", forHTTPHeaderField: "Content-Type")
+ var fields = [("model", model), ("temperature", "0")]
+ if let language { fields.append(("language", String(language.prefix { $0 != "-" }))) }
+ req.httpBody = Self.multipart(fields: fields, file: wav, boundary: boundary)
+ do {
+ let data = try await send(req, key: key, contentType: nil)
+ guard let root = try JSONSerialization.jsonObject(with: data) as? [String: Any],
+ let text = root["text"] as? String else { throw Failure.parse }
+ report(call, .translate, at: started, queued: queued, outcome: "ok", chars: text.count)
+ return (text.trimmingCharacters(in: .whitespacesAndNewlines), root["language"] as? String)
+ } catch let failure as Failure {
+ report(call, .translate, at: started, queued: queued, outcome: Self.name(failure))
+ throw failure
+ } catch {
+ report(call, .translate, at: started, queued: queued, outcome: "parse")
+ throw Failure.parse
+ }
+ }
+
+ /// One second of silence through the speech model: does the address answer, and does the
+ /// model take audio. The time is the request's.
+ private func checkHearing(_ c: AIConfig, key: String) async -> AICheck.Hearing {
+ let started = Date()
+ do {
+ _ = try await transcribe(CloudHearing.wav(Array(repeating: 0, count: 16000)), language: nil, timeout: 20)
+ return .ok(seconds: Date().timeIntervalSince(started))
+ } catch let failure as Failure {
+ if case .http(let code) = failure { return .fail(code: code) }
+ return failure == .network || failure == .timeout ? .unreachable : .fail(code: nil)
+ } catch {
+ return .fail(code: nil)
+ }
+ }
+
+ nonisolated static func multipart(fields: [(String, String)], file: Data, boundary: String) -> Data {
+ var d = Data()
+ for (name, value) in fields {
+ d.append(Data("--\(boundary)\r\nContent-Disposition: form-data; name=\"\(name)\"\r\n\r\n\(value)\r\n".utf8))
+ }
+ d.append(Data("--\(boundary)\r\nContent-Disposition: form-data; name=\"file\"; filename=\"audio.wav\"\r\nContent-Type: audio/wav\r\n\r\n".utf8))
+ d.append(file)
+ d.append(Data("\r\n--\(boundary)--\r\n".utf8))
+ return d
+ }
+
// MARK: Transport
+ /// A chat completion. A custom server that refuses `chat_template_kwargs` (a strict gateway
+ /// answers 400 or 422 to fields it doesn't know) is asked again without it, and isn't sent it
+ /// again until settings change.
+ private func postChat(_ body: [String: Any], key: String, timeout: TimeInterval) async throws -> [String: Any] {
+ do {
+ return try await post("chat/completions", body: body, key: key, timeout: timeout)
+ } catch Failure.http(let code) where (code == 400 || code == 422) && body["chat_template_kwargs"] != nil {
+ // Only when the same request goes through without it: a 400 for something else (no
+ // JSON mode) must not turn thinking back on for every translation.
+ var plain = body
+ plain["chat_template_kwargs"] = nil
+ do {
+ let root = try await post("chat/completions", body: plain, key: key, timeout: timeout)
+ debugLog("ai custom: chat_template_kwargs refused (HTTP \(code)), sent without it from now on")
+ noTemplateKwargs = true
+ return root
+ } catch {
+ throw Failure.http(code)
+ }
+ }
+ }
+
private func post(_ path: String, body: [String: Any], key: String, timeout: TimeInterval) async throws -> [String: Any] {
guard let base = config().base else { throw Failure.noKey }
var req = URLRequest(url: base.appendingPathComponent(path))
@@ -648,10 +763,10 @@ final class LingClient: ObservableObject {
return try await send(req, key: key)
}
- private func send(_ request: URLRequest, key: String) async throws -> Data {
+ private func send(_ request: URLRequest, key: String, contentType: String? = "application/json") async throws -> Data {
var req = request
if !key.isEmpty { req.setValue("Bearer \(key)", forHTTPHeaderField: "Authorization") }
- req.setValue("application/json", forHTTPHeaderField: "Content-Type")
+ if let contentType { req.setValue(contentType, forHTTPHeaderField: "Content-Type") }
let data: Data
let response: URLResponse
do {
diff --git a/Sources/Cicada/Settings.swift b/Sources/Cicada/Settings.swift
index 86a764b..eaa88f7 100644
--- a/Sources/Cicada/Settings.swift
+++ b/Sources/Cicada/Settings.swift
@@ -124,6 +124,18 @@ final class AppSettings: ObservableObject {
@Published var aiCustomVoice: String {
didSet { save() }
}
+ /// The custom service's speech recognition model (`/audio/transcriptions`, e.g. Qwen3-ASR) and
+ /// its address (empty: the same one), and whether the meeting is recognized there instead of on
+ /// this Mac (off by default: the audio then leaves the Mac).
+ @Published var aiCustomHearModel: String {
+ didSet { save() }
+ }
+ @Published var aiCustomHearBase: String {
+ didSet { save() }
+ }
+ @Published var aiCustomRecognize: Bool {
+ didSet { save() }
+ }
var provider: AIProvider { AIProvider.named(aiProvider) }
@@ -138,8 +150,12 @@ final class AppSettings: ObservableObject {
let voice = (aiVoiceModels["custom"] ?? "").trimmingCharacters(in: .whitespaces)
let voiceBase = aiCustomVoiceBase.isEmpty ? base : AIProvider.customBase(aiCustomVoiceBase)
let name = aiCustomVoice.trimmingCharacters(in: .whitespaces)
+ let hear = aiCustomHearModel.trimmingCharacters(in: .whitespaces)
+ let hearBase = aiCustomHearBase.isEmpty ? base : AIProvider.customBase(aiCustomHearBase)
+ let recognizes = aiCustomRecognize && !hear.isEmpty
return AIConfig(provider: p, base: base, textModel: aiModels["custom"] ?? "", voiceModel: voice.isEmpty ? nil : voice,
- voiceBase: voiceBase, customVoice: name.isEmpty ? nil : name)
+ voiceBase: voiceBase, customVoice: name.isEmpty ? nil : name,
+ hearModel: recognizes ? hear : nil, hearBase: recognizes ? hearBase : nil)
default:
return AIConfig(provider: p, base: p.base, textModel: aiModels[p.id.rawValue] ?? p.textModels.first?.id ?? "",
voiceModel: p.hasVoices ? aiVoiceModels[p.id.rawValue] ?? p.voiceModels.first?.id : nil, voiceBase: p.base)
@@ -225,6 +241,9 @@ final class AppSettings: ObservableObject {
aiCustomBase = defaults.string(forKey: "aiCustomBase") ?? ""
aiCustomVoiceBase = defaults.string(forKey: "aiCustomVoiceBase") ?? ""
aiCustomVoice = defaults.string(forKey: "aiCustomVoice") ?? ""
+ aiCustomHearModel = defaults.string(forKey: "aiCustomHearModel") ?? ""
+ aiCustomHearBase = defaults.string(forKey: "aiCustomHearBase") ?? ""
+ aiCustomRecognize = defaults.bool(forKey: "aiCustomRecognize")
displayMode = defaults.string(forKey: "displayMode") ?? "notes"
speakVoices = defaults.dictionary(forKey: "speakVoices") as? [String: String] ?? [:]
endWithApp = defaults.object(forKey: "endWithApp") as? Bool ?? true
@@ -274,6 +293,9 @@ final class AppSettings: ObservableObject {
defaults.set(aiCustomBase, forKey: "aiCustomBase")
defaults.set(aiCustomVoiceBase, forKey: "aiCustomVoiceBase")
defaults.set(aiCustomVoice, forKey: "aiCustomVoice")
+ defaults.set(aiCustomHearModel, forKey: "aiCustomHearModel")
+ defaults.set(aiCustomHearBase, forKey: "aiCustomHearBase")
+ defaults.set(aiCustomRecognize, forKey: "aiCustomRecognize")
defaults.set(displayMode, forKey: "displayMode")
defaults.set(speakVoices, forKey: "speakVoices")
defaults.set(endWithApp, forKey: "endWithApp")
diff --git a/Sources/Cicada/Translator.swift b/Sources/Cicada/Translator.swift
index 75e083e..f563979 100644
--- a/Sources/Cicada/Translator.swift
+++ b/Sources/Cicada/Translator.swift
@@ -194,6 +194,13 @@ final class TranslationService {
/// call failed, so listening can tell a service that is down from a quiet meeting.
func hear(wav: Data, seconds: Double, target: String, hint: String?,
priority: LingClient.Priority = .translate) async throws -> CloudHeard? {
+ // A custom service's speech model only transcribes: the text is translated as the Mac's own is.
+ if ling.transcribes {
+ // No language sent: a speech model takes it as an order, and an English line in a
+ // Chinese meeting would come back as Chinese. The server tells the language itself.
+ let heard = try await ling.transcribe(wav, language: nil)
+ return CloudHearing.transcript(heard.text, reported: heard.language, hint: hint, target: target, seconds: seconds)
+ }
guard ling.hearsAudio else { throw LingClient.Failure.noKey }
let reply = try await ling.chat(content: CloudHearing.prompt(target: target, hint: hint, names: glossary()),
instruction: CloudHearing.instruction(target: target), priority: priority,
diff --git a/Tests/CicadaTests/AIProviderTests.swift b/Tests/CicadaTests/AIProviderTests.swift
index e99d6dd..5990039 100644
--- a/Tests/CicadaTests/AIProviderTests.swift
+++ b/Tests/CicadaTests/AIProviderTests.swift
@@ -19,6 +19,32 @@ struct AIProviderTests {
#expect(openai["max_tokens"] == nil && openai["temperature"] == nil)
let custom = shaped(.custom)
#expect(custom["max_tokens"] as? Int == 50 && custom["thinking"] == nil && custom["reasoning"] == nil)
+ // Qwen3 on vLLM / SGLang / llama.cpp: thinking off through the chat template.
+ #expect((custom["chat_template_kwargs"] as? [String: Bool])?["enable_thinking"] == false)
+ var plain: [String: Any] = [:]
+ AIConfig(provider: .custom, base: nil, textModel: "m").shape(&plain, maxTokens: 50, templateKwargs: false)
+ #expect(plain["chat_template_kwargs"] == nil)
+ }
+
+ @Test func aThinkingModelIsSeenFromItsReply() {
+ func reply(_ message: [String: Any], usage: [String: Any]? = nil) -> [String: Any] {
+ var r: [String: Any] = ["choices": [["message": message]]]
+ if let usage { r["usage"] = usage }
+ return r
+ }
+ #expect(!AIConfig.thought(reply(["content": "周五发布。"])))
+ #expect(AIConfig.thought(reply(["content": "周五发布。", "reasoning_content": "The user wants…"])))
+ // A reasoning parser on the server: the answer itself sits in reasoning_content.
+ #expect(AIConfig.thought(reply(["content": "", "reasoning_content": "周五发布。"])))
+ #expect(AIConfig.thought(reply(["content": "<think>hmm</think>周五发布。"])))
+ #expect(AIConfig.thought(reply(["content": "周五发布。"], usage: ["completion_tokens_details": ["reasoning_tokens": 212]])))
+ #expect(!AIConfig.thought(reply(["content": "周五发布。", "reasoning_content": " "], usage: ["completion_tokens_details": ["reasoning_tokens": 0]])))
+ }
+
+ @Test func aSlowSentenceIsFlagged() {
+ #expect(!AICheck.Speed(seconds: 0.4, thinks: false).slow)
+ #expect(AICheck.Speed(seconds: 0.4, thinks: true).slow)
+ #expect(AICheck.Speed(seconds: 6.4, thinks: false).slow)
}
@Test func customAddressNeedsHTTPSExceptOnThisMac() {
@@ -30,6 +56,27 @@ struct AIProviderTests {
#expect(AIProvider.customBase(" ") == nil)
}
+ @Test func theLocalNetworkMayUsePlainHTTP() {
+ for ok in ["http://192.168.1.20:8000/v1", "10.0.0.5:8000/v1", "http://172.20.1.1/v1", "http://100.101.102.103:8000/v1",
+ "http://169.254.3.4/v1", "http://gpu.local:30000/v1", "http://[fd12:3456::1]:8000/v1", "http://[::1]:8000/v1"] {
+ #expect(AIProvider.customBase(ok)?.scheme == "http", "\(ok)")
+ }
+ for no in ["http://172.32.0.1/v1", "http://100.128.0.1/v1", "http://8.8.8.8/v1", "http://192.169.1.1/v1",
+ "http://gpu.example.com/v1", "http://10.0.0.5.evil.com/v1"] {
+ #expect(AIProvider.customBase(no) == nil, "\(no)")
+ }
+ #expect(AIProvider.customBase("192.168.1.20:8000/v1")?.scheme == "http")
+ #expect(AIProvider.isNearby("http://192.168.1.20:8000/v1/") && !AIProvider.isLocal("http://192.168.1.20:8000/v1/"))
+ }
+
+ @Test func recognitionOnTheServiceNeedsAModel() {
+ let c = AIConfig(provider: .custom, base: URL(string: "http://localhost:8000/v1/"), textModel: "m",
+ hearModel: "qwen3-asr", hearBase: URL(string: "http://localhost:8002/v1/"))
+ #expect(c.transcribes)
+ #expect(!AIConfig(provider: .custom, base: c.base, textModel: "m").transcribes)
+ #expect(!AIConfig(provider: .ling, base: c.base, textModel: "m", hearModel: "x", hearBase: c.base).transcribes)
+ }
+
@Test func onlyLingClonesAndHearsAudio() {
for p in AIProvider.all { #expect(p.clones == (p.id == .ling) && p.hearsAudio == (p.id == .ling)) }
#expect(!AIProvider.openai.hasVoices && AIProvider.zenmux.hasVoices && AIProvider.openrouter.hasVoices)
diff --git a/Tests/CicadaTests/LingTests.swift b/Tests/CicadaTests/LingTests.swift
index b00d055..af2eb23 100644
--- a/Tests/CicadaTests/LingTests.swift
+++ b/Tests/CicadaTests/LingTests.swift
@@ -7,10 +7,12 @@ import Testing
final class LingStub: URLProtocol, @unchecked Sendable {
nonisolated(unsafe) static var reply: (Int, String) = (200, "")
nonisolated(unsafe) static var seen: [(at: Date, body: [String: Any])] = []
+ /// Answers each request by what it asked, instead of `reply`.
+ nonisolated(unsafe) static var respond: (([String: Any]) -> (Int, String))?
private static let lock = NSLock()
static func reset(_ status: Int = 200, _ body: String) {
- lock.withLock { reply = (status, body); seen = [] }
+ lock.withLock { reply = (status, body); seen = []; respond = nil }
}
static func chatReply(_ text: String, finish: String? = "stop") -> String {
@@ -32,7 +34,7 @@ final class LingStub: URLProtocol, @unchecked Sendable {
stream.close()
}
let body = (try? JSONSerialization.jsonObject(with: data) as? [String: Any]) ?? [:]
- let (status, text) = Self.lock.withLock { Self.seen.append((Date(), body)); return Self.reply }
+ let (status, text) = Self.lock.withLock { Self.seen.append((Date(), body)); return Self.respond?(body) ?? Self.reply }
let response = HTTPURLResponse(url: request.url!, statusCode: status, httpVersion: nil, headerFields: nil)!
client?.urlProtocol(self, didReceive: response, cacheStoragePolicy: .notAllowed)
client?.urlProtocol(self, didLoad: Data(text.utf8))
@@ -58,6 +60,38 @@ final class LingStub: URLProtocol, @unchecked Sendable {
return ling
}
+ // MARK: Custom service
+
+ private func customClient() -> LingClient {
+ let ling = client()
+ ling.config = { AIConfig(provider: .custom, base: URL(string: "http://localhost:9/v1/"), textModel: "m") }
+ return ling
+ }
+
+ @Test func aServerThatRefusesTemplateKwargsIsAskedWithoutThem() async throws {
+ LingStub.reset(200, "")
+ LingStub.respond = { body in body["chat_template_kwargs"] != nil ? (400, "{}") : (200, LingStub.chatReply("好")) }
+ let ling = customClient()
+ #expect(try await ling.chat(content: "x", instruction: "Translate.", priority: .translate) == "好")
+ _ = try await ling.chat(content: "y", instruction: "Translate.", priority: .translate)
+ let bodies = LingStub.seen.map(\.body)
+ #expect(bodies.count == 3 && bodies[0]["chat_template_kwargs"] != nil && bodies[1]["chat_template_kwargs"] == nil)
+ // Not sent again once refused.
+ #expect(bodies[2]["chat_template_kwargs"] == nil)
+ }
+
+ @Test func aRefusalForSomethingElseKeepsThinkingOff() async throws {
+ LingStub.reset(200, "")
+ // No JSON mode on this server: 400 with or without the kwargs.
+ LingStub.respond = { body in body["response_format"] != nil ? (400, "{}") : (200, LingStub.chatReply("好")) }
+ let ling = customClient()
+ await #expect(throws: LingClient.Failure.http(400)) {
+ try await ling.chat(content: "x", instruction: "Notes.", priority: .translate, json: true)
+ }
+ _ = try await ling.chat(content: "y", instruction: "Translate.", priority: .translate)
+ #expect(LingStub.seen.last?.body["chat_template_kwargs"] != nil)
+ }
+
// MARK: Retries
@Test func finalNotesKeepRetryingForAboutAMinute() {