知了 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): imported records that tell speakers apart show who said each line
wquguru83379f6771e3
diff --git a/linux/cicada/app/records_window.py b/linux/cicada/app/records_window.pyindex 8307668..a9e2d79 100644--- a/linux/cicada/app/records_window.py+++ b/linux/cicada/app/records_window.py@@ -1288,9 +1288,12 @@ class RecordsWindow(Gtk.Window):def _speakers(self, s):"""(line id → number, voice → number, number → name) for the voices on show; empty when off."""- if not self.app.settings.speakerVoices or s.sourceFile is not None:+ if not self.app.settings.speakerVoices:return {}, {}, {}vnums = speakers.voice_numbers(s.lines)+ # An imported file without voices on show has no "other side" to label.+ if not speakers.says_who(s, vnums):+ return {}, {}, {}return speakers.numbers(s.lines), vnums, (speakers.names(s) if vnums else {})def _speaker_state_key(self, s):diff --git a/linux/cicada/core/session_store.py b/linux/cicada/core/session_store.pyindex af7b41d..d0e841e 100644--- a/linux/cicada/core/session_store.py+++ b/linux/cicada/core/session_store.py@@ -444,8 +444,7 @@ def markdown(s: Session, voices: bool = False) -> str:if notes:out.append(notes + "## %s\n\n" % strings.L("文字记录"))for l in s.lines:- # An imported file has no "other side" to name.- who = (" " + speakers.speaker_name(l, nums, shown)) if s.sourceFile is None else ""+ who = (" " + speakers.speaker_name(l, nums, shown)) if speakers.says_who(s, nums) else ""out.append("**[%s]%s** \n%s\n" % (clock(l.t), who, l.shown))if l.dst and l.dst != l.shown:out.append("> %s\n" % l.dst)diff --git a/linux/cicada/core/speakers.py b/linux/cicada/core/speakers.pyindex b78a505..ac6aa0b 100644--- a/linux/cicada/core/speakers.py+++ b/linux/cicada/core/speakers.py@@ -244,6 +244,12 @@ def label(number: int, shown: dict) -> str:return shown.get(number) or strings.LF("说话人 %lld", number)+def says_who(s, nums: dict) -> bool:+ """Whether lines say who spoke. An imported file has no "other side" to call 对方: its lines are+ named only once its voices are told apart (TranscriptExport.named)."""+ return s.sourceFile is None or bool(nums)++def speaker_name(line, nums: dict, shown: dict) -> str:"""你 · 同传 (said through 同声传译), a speaker, 对方 (no voices told apart) or 未识别 (a voice not onshow) (TranscriptExport.speakerName)."""diff --git a/linux/tests/test_core.py b/linux/tests/test_core.pyindex bd3f631..69d6a2f 100644--- a/linux/tests/test_core.py+++ b/linux/tests/test_core.py@@ -1439,6 +1439,8 @@ class Speakers(Base):md = session_store.markdown(got, voices=True)self.assertIn("**[00:00] 说话人 1**", md)self.assertIn("**[00:30] 未识别**", md)+ got.sourceFile = "call.m4a"+ self.assertIn("**[00:00] 说话人 1**", session_store.markdown(got, voices=True), "an imported file with voices names them")notes = MeetingNotes(summary="说话人 2 会发说明", topics=[NoteTopic(title="说话人2 的计划")])named = speakers.named(notes, {2: "George"})self.assertEqual(("George 会发说明", "George 的计划"), (named.summary, named.topics[0].title))