知了 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(android): subtitles no longer show a lone "Translate" when Ling translates its own instruction instead of the line
wqugurude9c06c1b250
diff --git a/android/cli/src/main/kotlin/cicada/cli/Tests.kt b/android/cli/src/main/kotlin/cicada/cli/Tests.ktindex 7a1b5f4..e0bf378 100644--- a/android/cli/src/main/kotlin/cicada/cli/Tests.kt+++ b/android/cli/src/main/kotlin/cicada/cli/Tests.kt@@ -383,6 +383,9 @@ object Tests {equal("Hello", Translator.cleanTranslation("Here is the translation:\nHello", "en"), "remark line dropped")equal(null, Translator.cleanTranslation("请提供需要翻译的字幕内容", "en"), "a request for input is not a translation")equal(null, Translator.cleanTranslation("Hello", "zh-CN"), "wrong script")+ equal(null, Translator.cleanTranslation("翻译。", "zh-CN"), "the instruction translated, not the subtitle")+ equal(null, Translator.cleanTranslation("Translate.", "en"), "the instruction translated, in English")+ equal("好的,翻译。", Translator.cleanTranslation("好的,翻译。", "zh-CN"), "a sentence about translating is kept")equal("Done.", Translator.cleanTranslation("<think>x</think>Done.", "en"), "leaked reasoning")}diff --git a/android/core/src/main/kotlin/cicada/Translator.kt b/android/core/src/main/kotlin/cicada/Translator.ktindex 5c0c7f6..9c69c33 100644--- a/android/core/src/main/kotlin/cicada/Translator.kt+++ b/android/core/src/main/kotlin/cicada/Translator.kt@@ -163,6 +163,12 @@ class Translator(private val ling: LingClient, private val transport: Transportprivate fun take(line: String, label: String) =if (line.startsWith(label, ignoreCase = true)) line.substring(label.length).trim() else null+ /// "Translate." in each target language, letters only and lowercased. Port of instructionEchoes.+ private val instructionEchoes = setOf(+ "翻译", "翻譯", "translate", "翻訳", "翻訳して", "翻訳する", "翻訳してください", "번역", "번역해", "번역하세요", "번역해주세요",+ "traducir", "traduce", "traduzca", "traduire", "traduisez", "traduis", "übersetzen", "übersetze", "traduzir", "traduza",+ )+/// Ling sometimes comments on a garbled subtitle instead of translating it ("The subtitle/// appears to be…"). Remark lines go, a "Translation:" label is stripped, and what is left must/// be in the target's script; null lets the next provider try. Port of cleanTranslation.@@ -193,6 +199,9 @@ class Translator(private val ling: LingClient, private val transport: Transport}output = output.trim()if (output.isEmpty()) return null+ // 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.+ if (output.lowercase().filter { it.isLetter() } in instructionEchoes) return nullreturn if (Languages.inScript(output, target)) output else null}}