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): 同声传译 no longer says "Hmm." when a hush or an echo's tail is heard as only 嗯

wquguru4de05e2d785f
diff --git a/linux/cicada/core/speak.py b/linux/cicada/core/speak.py
index cd0fc61..4d0d4c3 100644
--- a/linux/cicada/core/speak.py
+++ b/linux/cicada/core/speak.py
@@ -13,6 +13,7 @@ back. UI-free like ListenEngine: on_change is called on worker threads."""
from __future__ import annotations
import queue
+import re
import threading
import time
from collections import deque
@@ -202,6 +203,10 @@ class SpeakEngine:
Log.d("speak: segment %d %.1fs not interpreted, not spoken" % (seg.index, seg.seconds))
return None
original, translation = heard
+ if filler(original):
+ # The room's hush or an echo's tail cut as a segment: Ming hears 嗯, the room would hear "Hmm."
+ Log.d("speak: segment %d only a filler, not spoken" % seg.index)
+ return None
# The voice starts now, on its own thread: ready the moment the sentence before stops playing,
# instead of each sentence waiting out Ming's first chunk after the last one's playback.
return original, translation, source, target, end, self._fetch(translation, target)
@@ -274,3 +279,13 @@ class SpeakEngine:
t = round(max(0.0, (datetime.now(timezone.utc) - s.startedAt).total_seconds() - ago), 3)
self.store.append(sid, TranscriptLine(id="m%d" % self._me, t=t, speaker="me", src=original, dst=translation,
srcLang=source, dstLang=target))
+
+
+FILLERS = {"嗯", "啊", "呃", "哦", "唔", "额", "噢", "哎", "um", "uh", "hmm", "hm", "mm", "mhm", "ah", "oh", "er", "えー", "あの", "음", "어"}
+
+
+def filler(text: str) -> bool:
+ """Nothing but fillers (嗯, 啊, um, hmm…), whatever the punctuation (the Mac's PressSpeech.filler)."""
+ words = [w for w in re.split(r"[^\w]+|[\d_]+", text.lower()) if w]
+ return not words or all(w in FILLERS or (len(w) > 1 and len(set(w)) == 1 and w[0] in FILLERS) for w in words)
+
diff --git a/linux/tests/test_core.py b/linux/tests/test_core.py
index 10d4668..e06c51d 100644
--- a/linux/tests/test_core.py
+++ b/linux/tests/test_core.py
@@ -1186,6 +1186,15 @@ class Speaking(Base):
self.assertEqual(b"", player.data)
self.assertIsNotNone(eng.problem)
+ def test_a_filler_alone_is_not_spoken(self):
+ # A hush or an echo's tail cut as a segment: Ming hears 嗯 and the room would hear "Hmm."
+ eng, fake, player = self._engine("ORIGINAL: 嗯。\nTRANSLATION: Hmm.")
+ self._say(eng, concat(tone(1.2), silence(1.0)))
+ self.assertEqual(0, eng.spoken)
+ self.assertEqual([], fake.spoken, "nothing sent to the voice")
+ from cicada.core.speak import filler
+ self.assertTrue(filler("嗯嗯。") and filler("Um, uh...") and not filler("嗯,好的。") and not filler("OK."))
+
def test_fetches_the_next_voice_while_the_last_one_plays(self):
eng, fake, player = self._engine("ORIGINAL: 你好\nTRANSLATION: Hello")
fetched = []