知了 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): subtitles no longer show a lone "Translate" when Ling translates its own instruction instead of the line
wquguru4208271d3de8
diff --git a/linux/cicada/core/translator.py b/linux/cicada/core/translator.pyindex 31420de..e9ada69 100644--- a/linux/cicada/core/translator.py+++ b/linux/cicada/core/translator.py@@ -261,6 +261,12 @@ _ABOUT = ("translat", "subtitle", "garbled", "transcri", "asr", "speech recognit_ZH_ABOUT = ("字幕", "翻译")_ZH_REMARK = ("请提供", "似乎", "看起来", "无法", "乱码", "没有附上", "您只发送")+# "Translate." in each target language, letters only and lowercased.+_INSTRUCTION_ECHOES = frozenset((+ "翻译", "翻譯", "translate", "翻訳", "翻訳して", "翻訳する", "翻訳してください", "번역", "번역해", "번역하세요", "번역해주세요",+ "traducir", "traduce", "traduzca", "traduire", "traduisez", "traduis", "übersetzen", "übersetze", "traduzir", "traduza",+))+def clean_translation(reply: str, target: str) -> str | None:"""Ling sometimes comments on a garbled subtitle instead of translating it ("The subtitle appears@@ -290,4 +296,9 @@ def clean_translation(reply: str, target: str) -> str | None:output = output.strip()if not output:return None+ # Ling translated the fixed "Translate." instruction instead of the subtitle ("翻译。" for an empty+ # subtitle, or for "Translate this into Chinese please."); the next provider translates it. Port of+ # instructionEchoes.+ if "".join(c for c in output.lower() if c.isalpha()) in _INSTRUCTION_ECHOES:+ return Nonereturn output if in_script(output, target) else Nonediff --git a/linux/tests/test_core.py b/linux/tests/test_core.pyindex d41558e..d2cfdc1 100644--- a/linux/tests/test_core.py+++ b/linux/tests/test_core.py@@ -356,6 +356,10 @@ class Hearing(Base):self.assertEqual("Hello", clean_translation("Here is the translation:\nHello", "en"))self.assertIsNone(clean_translation("请提供需要翻译的字幕内容", "en"))self.assertIsNone(clean_translation("Hello", "zh-CN"))+ # Ling translated the fixed "Translate." instruction instead of the subtitle.+ self.assertIsNone(clean_translation("翻译。", "zh-CN"))+ self.assertIsNone(clean_translation("Translate.", "en"))+ self.assertEqual("好的,翻译。", clean_translation("好的,翻译。", "zh-CN"))self.assertEqual("Done.", clean_translation("<think>x</think>Done.", "en"))def test_joins_cut_sentences(self):