知了 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
fix: when the AI service hearing an Intel Mac's meeting keeps answering with a server error, the status says it is having trouble instead of that it can't be reached
wquguru59d161b6aec1
diff --git a/Sources/Cicada/CloudHearing.swift b/Sources/Cicada/CloudHearing.swiftindex cb25490..cc61102 100644--- a/Sources/Cicada/CloudHearing.swift+++ b/Sources/Cicada/CloudHearing.swift@@ -24,6 +24,18 @@ enum CloudHearing {return p}+ /// Why listening is quiet when the service failed to hear three stretches in a row and there is+ /// nothing on this Mac to go back to. A 5xx (a gateway in front of the server) answered: the+ /// service is erring, not out of reach (AICheck's serverError words).+ static func trouble(_ error: Error, service: String) -> String {+ switch error as? LingClient.Failure {+ case .invalidKey?: L("key 已失效,到设置 › AI 服务里重填")+ case .noKey?: L("请先在设置 › AI 服务里填入 Ling key")+ case .http(let code)? where code >= 500: L("\(service) 暂时出错(HTTP \(code)),稍后再试。")+ default: L("\(service) 暂时连不上,正在重试")+ }+ }+/// Tested wording (Windows M0): adding "NONE if there is no speech" or "the same text if already/// in it" gets the gateway's canned "作为一个人工智能语言模型…" refusal instead.static func instruction(target: String) -> String {diff --git a/Sources/Cicada/ListenEngine.swift b/Sources/Cicada/ListenEngine.swiftindex 175d4da..40b333c 100644--- a/Sources/Cicada/ListenEngine.swift+++ b/Sources/Cicada/ListenEngine.swift@@ -1150,9 +1150,7 @@ final class ListenEngine {self.setStatus(L("\(self.cloudService ?? "AI") 暂时连不上,先用本机识别"))} else if !Recognition.cloudOnly { self.stopCloud() }// Nothing to go back to on an Intel Mac: say why it's quiet, and keep trying.- else if case LingClient.Failure.invalidKey = error { self.setStatus(L("key 已失效,到设置 › AI 服务里重填")) }- else if case LingClient.Failure.noKey = error { self.setStatus(L("请先在设置 › AI 服务里填入 Ling key")) }- else { self.setStatus(L("\(self.cloudService ?? "AI") 暂时连不上,正在重试")) }+ else { self.setStatus(CloudHearing.trouble(error, service: self.cloudService ?? "AI")) }}return nil}diff --git a/Tests/CicadaTests/CloudHearingTests.swift b/Tests/CicadaTests/CloudHearingTests.swiftindex 07a8f1b..131c322 100644--- a/Tests/CicadaTests/CloudHearingTests.swift+++ b/Tests/CicadaTests/CloudHearingTests.swift@@ -16,6 +16,18 @@ struct CloudHearingTests {#expect(CloudHearing.parse("lang: ja-JP\noriginal: はい\ntranslation: 是", target: "zh-CN", hint: nil, seconds: 0)?.lang == "ja")}+ /// A gateway answering 502 to every stretch is the service erring, said with its code, not+ /// "can't reach"; the network and the key keep their own words.+ @Test func saysWhyHearingStopped() {+ let erring = CloudHearing.trouble(LingClient.Failure.http(502), service: "ZenMux")+ let away = CloudHearing.trouble(LingClient.Failure.network, service: "ZenMux")+ #expect(erring.contains("ZenMux") && erring.contains("HTTP 502"))+ #expect(away.contains("ZenMux") && !away.contains("HTTP"))+ #expect(CloudHearing.trouble(LingClient.Failure.http(429), service: "ZenMux") == away)+ #expect(CloudHearing.trouble(LingClient.Failure.timeout, service: "ZenMux") == away)+ #expect(CloudHearing.trouble(LingClient.Failure.invalidKey, service: "ZenMux") == L("key 已失效,到设置 › AI 服务里重填"))+ }+@Test func dropsNoise() {for o in ["嗯。", "Mm.", "uh, um", "呃呃呃呃呃", "嗯,嗯,嗯,嗯,嗯,嗯,嗯,嗯,嗯,嗯,嗯,嗯。", String(repeating: "滴答", count: 50),"hmmmm", "うーん", "음…", "喂?", "No no no no no no",