知了 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(linux): the notes window no longer says notes stopped at 00:00 when only another request lost the network, or while you look at an earlier meeting
wqugurue1dc39e5a749
diff --git a/linux/cicada/app/notes_window.py b/linux/cicada/app/notes_window.pyindex 0a43d1f..7217fe7 100644--- a/linux/cicada/app/notes_window.py+++ b/linux/cicada/app/notes_window.py@@ -861,8 +861,15 @@ class NotesWindow(Gtk.Window):covered = engine.notes.coveredlast = s.lines[covered - 1].t if s is not None and 0 < covered <= len(s.lines) else 0.0reason = self._reason()+ ling = self.app.ling+ # Who the banners name: a custom service by its address, which says more than 这个服务.+ name = ling.service_host if ling.provider.id == "custom" and ling.service_host else ling.service_name+ # All but the key are about a round of the meeting going on now: a record opened later has none.+ live = self.app.listen.listeningif engine.status == notesmod.INVALID_KEY:- text, tone = LF("key 已失效(令牌被删或免费额度用尽),纪要停留在 %@。", clock(last)), "error"+ text = (LF("key 已失效(被删或额度用完),纪要暂停在 %@。", clock(last)) if last > 0+ else L("key 已失效(被删或额度用完),换个 key 就能开始写纪要。"))+ tone = "error"elif problem.blocking(reason) and (reason in problem.NOTES_ONLY or not self.live_box.get_visible()):# Only the user can fix it (the live card says it too, when it shows): what, and 打开设置.from .aicheck_view import blocking@@ -875,19 +882,23 @@ class NotesWindow(Gtk.Window):row.pack_end(b, False, False, 0)body.pack_start(ui.pad(ui.panel(ui.pad(row, 12), "notice", "error"), 0, 0, 10, 0), False, False, 0)return- elif engine.status == notesmod.RATE_LIMITED:- text, tone = LF("%@ 很忙,纪要稍后补上。字幕照常。", self.app.ling.service_name), "busy"- elif engine.status == notesmod.FAILED and self.app.ling.check_result.reason == "unreachable":- # The network or the proxy, not the notes: say which, and that it picks up by itself.- text, tone = LF("连不上 %@,这段时间的纪要先停在 %@。网络恢复后自动继续。", self.app.ling.service_name, clock(last)), "error"- elif engine.status == notesmod.FAILED:+ elif engine.status == notesmod.RATE_LIMITED and live:+ text, tone = LF("%@ 很忙,纪要稍后补上。字幕照常。", name), "busy"+ elif engine.status == notesmod.UNREACHABLE and live and ling.check_result.reason == "unreachable":+ # The network or the proxy, not the notes: say which, and that it picks up by itself. Both:+ # the notes' own request failed and the service answers nothing; notes that only timed out+ # while translations still came back retry on the next round.+ text = (LF("连不上 %@,纪要暂停在 %@,连上后自动继续。", name, clock(last)) if last > 0+ else LF("连不上 %@,连上后开始写纪要。", name))+ tone = "error"+ elif engine.status == notesmod.FAILED and live:text, tone = L("这轮没整理好,下一轮会自动重试。"), ""else:returnrow = ui.hbox(10)row.pack_start(ui.text(text, 12, "ink", width_chars=24), True, True, 0)if tone == "error":- unreachable = engine.status == notesmod.FAILED+ unreachable = engine.status == notesmod.UNREACHABLEb = ui.button(L("设置") if unreachable else L("更换 key"), lambda: self.app.show_settings(ai=True),"outline" if unreachable else "darkbtn")b.set_can_focus(False)@@ -961,7 +972,10 @@ class NotesWindow(Gtk.Window):body.show_all()returnif n.is_empty:- hint = {notesmod.NO_KEY: L("生成纪要需要 API key"), notesmod.UPDATING: L("正在整理纪要…")}.get(engine.status, "")+ hint = {notesmod.NO_KEY: L("生成纪要需要 API key"),+ notesmod.UPDATING: L("正在整理纪要…")}.get(engine.status, "")+ if engine.status in (notesmod.INVALID_KEY, notesmod.RATE_LIMITED, notesmod.FAILED, notesmod.UNREACHABLE):+ hint = "" # the banner says itif hint:body.pack_start(ui.helper(hint), False, False, 0)body.show_all()diff --git a/linux/cicada/core/notes.py b/linux/cicada/core/notes.pyindex 882fcfd..2cbe7e1 100644--- a/linux/cicada/core/notes.py+++ b/linux/cicada/core/notes.py@@ -21,6 +21,9 @@ from .support import Log, clock, written_inINTERVAL = 45.0IDLE, UPDATING, NO_KEY, INVALID_KEY, RATE_LIMITED, FAILED = "idle", "updating", "noKey", "invalidKey", "rateLimited", "failed"+# The notes' own request couldn't reach the service (network, proxy, timeout); another request+# failing, such as naming speakers, never sets it.+UNREACHABLE = "unreachable"class NotesEngine:@@ -95,6 +98,9 @@ class NotesEngine:self.shown_id = sids = self.store.get(sid)self.notes = (s.notes if s else None) or MeetingNotes()+ # A round that failed belongs to the meeting it ran for, not to the record opened now.+ if self._session_id is None and self.status in (FAILED, UNREACHABLE, RATE_LIMITED):+ self.status = IDLEself._changed()def rewrite(self) -> None:@@ -121,6 +127,14 @@ class NotesEngine:self.status = INVALID_KEYdef _tick(self) -> None:+ with self._gate:+ # The service answers again (the check after a network change, or any other request): the+ # banner goes now, not after the next round, which runs on its usual 45 s.+ recovered = self.status == UNREACHABLE and self.ling.check_result.reason != "unreachable"+ if recovered:+ self.status = IDLE+ if recovered:+ self._changed()with self._gate:self._sync_key()sid = self._session_id@@ -202,7 +216,8 @@ class NotesEngine:"final" if final else "live", len(lines) - frm, len(nxt.topics), len(nxt.terms)))except LingError as e:self.status = {LingError.INVALID_KEY: INVALID_KEY, LingError.RATE_LIMITED: RATE_LIMITED,- LingError.NO_KEY: NO_KEY}.get(e.kind, FAILED)+ LingError.NO_KEY: NO_KEY, LingError.NETWORK: UNREACHABLE,+ LingError.TIMEOUT: UNREACHABLE}.get(e.kind, FAILED)Log.d("notes: update failed %s" % e)except Exception as e: # noqa: BLE001self.status = FAILEDdiff --git a/linux/tests/test_core.py b/linux/tests/test_core.pyindex f08f8c9..5fd1c6b 100644--- a/linux/tests/test_core.py+++ b/linux/tests/test_core.py@@ -500,6 +500,32 @@ class Notes(Base):notes._sync_key()self.assertEqual(notesmod.IDLE, notes.status)+ def test_unreachable_is_the_notes_own_and_clears_when_the_service_answers(self):+ # NotesWindow.swift › banner: only the notes' own network failure says "can't reach", it ends+ # when anything reaches the service again, and a record opened later doesn't inherit it.+ store = SessionStore()+ down = [True]++ def respond(body):+ if down[0]:+ raise OSError("no route")+ return reply("ok")+ ling = client(Fake(respond))+ notes = NotesEngine(ling, store)+ s = store.begin()+ for i in range(3):+ store.append(s.id, TranscriptLine(id="h%d-%d" % (i + 1, i + 1), t=i, src="x", srcLang="en", dstLang="zh-CN"))+ notes._update(s.id, False)+ self.assertEqual(notesmod.UNREACHABLE, notes.status)+ self.assertEqual("unreachable", ling.check_result.reason)+ down[0] = False+ ling.chat("hello", "Translate.", TRANSLATE)+ notes._tick()+ self.assertEqual(notesmod.IDLE, notes.status, "the service answered: the banner goes now")+ notes.status = notesmod.FAILED+ notes.show(s.id)+ self.assertEqual(notesmod.IDLE, notes.status, "no meeting going on: a failed round isn't the record's")+def test_notes_language_as_on_the_mac(self):# "mine" or "source"; one meeting's choice over the setting; a change while live rewrites.store = SessionStore()