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.

fix(linux): switching to Listen to › Computer + Room mid-meeting times the room's lines in the meeting instead of at 00:00

wqugurucc5ca3b334d2
diff --git a/linux/cicada/core/listen.py b/linux/cicada/core/listen.py
index 37ff20b..f4a2c5c 100644
--- a/linux/cicada/core/listen.py
+++ b/linux/cicada/core/listen.py
@@ -200,8 +200,10 @@ class ListenEngine:
Log.d("listen: started %s source=%s target=%s" % (session.id, kind, self.target))
self._changed()
- def _run(self, lane) -> None:
+ def _run(self, lane, at: float = 0.0) -> None:
+ """`at`: where in the meeting this lane begins (seconds), so its lines' times are the meeting's."""
segmenter = Segmenter()
+ segmenter.consumed = int(at * RATE)
segmenter.on_segment = lambda seg: self._send(lane, seg)
q: queue.Queue = queue.Queue()
lane.audio = q
@@ -279,7 +281,9 @@ class ListenEngine:
lane.gate = VoiceGate(adaptive=True)
lane.muted = any(l.muted for l in self._lanes())
self.gated = gated
- self._run(lane)
+ # Started mid-meeting (听哪里 changed to 电脑和会议室): its clock starts where the meeting is,
+ # not at 00:00, or its lines would sort before everything said so far.
+ self._run(lane, self._main.heard_seconds)
with self._gate:
self._room = lane
self.store.mark_room(self.session_id)
diff --git a/linux/tests/test_hybrid.py b/linux/tests/test_hybrid.py
index 5d8db50..e956aa7 100644
--- a/linux/tests/test_hybrid.py
+++ b/linux/tests/test_hybrid.py
@@ -298,6 +298,25 @@ class Both(Base):
s = store.get(e.session_id)
self.assertEqual([(None, ONLINE)], [(l.via, l.src) for l in s.lines])
+ def test_a_room_side_started_mid_meeting_keeps_the_meetings_clock(self):
+ # 听哪里 changed to 电脑和会议室 two seconds in: the room's line is timed after them, not at 00:00.
+ store = SessionStore()
+ e = both_engine(store, "I think we should check the numbers for Europe first.")
+ main = PcmAudioSource(lambda: concat(tone(1.0), silence(1.0)), speed=0)
+ room = PcmAudioSource(lambda: concat(silence(0.5), tone(1.6, amp=0.2), silence(1.0)), speed=0)
+ done = [threading.Event(), threading.Event()]
+ main.on_ended = lambda why: done[0].set()
+ room.on_ended = lambda why: done[1].set()
+ e.start(main, "both")
+ done[0].wait(10)
+ time.sleep(0.3)
+ e.start_room(room, gated=False)
+ done[1].wait(10)
+ time.sleep(0.6)
+ e.stop()
+ line = next(l for l in store.get(e.session_id).lines if l.via == "room")
+ self.assertGreaterEqual(line.t, 2.0)
+
def test_stopping_the_room_side_keeps_the_meeting(self):
store = SessionStore()
e = both_engine(store, "x")