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.

feat(android): what you say with Me speaking is marked Interpreted in Face to face, live subtitles, records and exports

wquguruaf66480fe6b6
diff --git a/android/app/src/main/kotlin/com/wquguru/cicada/FaceActivity.kt b/android/app/src/main/kotlin/com/wquguru/cicada/FaceActivity.kt
index af49e08..1f50e33 100644
--- a/android/app/src/main/kotlin/com/wquguru/cicada/FaceActivity.kt
+++ b/android/app/src/main/kotlin/com/wquguru/cicada/FaceActivity.kt
@@ -121,7 +121,8 @@ class FaceActivity : Activity() {
val translated = line?.dst?.takeIf { it.isNotEmpty() && it != line.src }
theirLabel.text = NotesViews.languageName(their)
theirText.text = when { line == null -> "…"; mine -> translated ?: "…"; else -> line.src }
- myLabel.text = (if (line == null || mine) L("你") else L("对方")) + " · " + NotesViews.languageName(mineLang)
+ // My line was said with 我说: the other side heard its translation (同传, as on the Mac).
+ myLabel.text = (if (mine) L("你 · 同传") else if (line == null) L("你") else L("对方")) + " · " + NotesViews.languageName(mineLang)
myText.text = when { line == null -> L("按住下面的按钮说话,松开后对方会听到译文"); mine -> line.src; else -> translated ?: line.src }
myText.setTextColor(if (line == null) Palette.secondary else Palette.ink)
val live = l.holding || app.voice.speaking
diff --git a/android/app/src/main/kotlin/com/wquguru/cicada/NotesViews.kt b/android/app/src/main/kotlin/com/wquguru/cicada/NotesViews.kt
index 72dd2d3..426b1b2 100644
--- a/android/app/src/main/kotlin/com/wquguru/cicada/NotesViews.kt
+++ b/android/app/src/main/kotlin/com/wquguru/cicada/NotesViews.kt
@@ -265,7 +265,7 @@ object NotesViews {
/// The newest line as a card, with the "still listening" dots under it.
/// The original as shown above its translation: mine is marked, so it's clear who said it.
- fun said(l: TranscriptLine) = if (l.speaker == "me") L("你") + " · " + l.src else l.src
+ fun said(l: TranscriptLine) = if (l.speaker == "me") L("你 · 同传") + " · " + l.src else l.src
fun liveCard(ui: Ui, app: CicadaApp, line: TranscriptLine, big: Float, bg: Int = Palette.card, lines: Int = 0, dots: Boolean = true): LinearLayout {
val card = ui.stack(0)
@@ -273,7 +273,7 @@ object NotesViews {
card.setPadding(ui.dp(18), ui.dp(16), ui.dp(18), ui.dp(16))
card.accessibilityLiveRegion = View.ACCESSIBILITY_LIVE_REGION_POLITE
val translated = !line.dst.isNullOrEmpty() && line.dst != line.src
- if (!translated && line.speaker == "me") card.addView(ui.text(L("你"), 14f, Palette.secondary))
+ if (!translated && line.speaker == "me") card.addView(ui.text(L("你 · 同传"), 14f, Palette.secondary))
if (translated) card.addView(ui.text(said(line), 14f, Palette.secondary, lines = if (lines > 0) lines - 1 else 0))
card.addView(ui.text(line.dst ?: line.src, big, Palette.ink, bold = true, lines = lines).apply { leading(1.25f) }, ui.lp(top = if (translated || line.speaker == "me") 8 else 0))
if (dots && app.listen.listening) card.addView(LinearLayout(ui.context).apply {
diff --git a/android/cli/src/main/kotlin/cicada/cli/Tests.kt b/android/cli/src/main/kotlin/cicada/cli/Tests.kt
index 63d944f..0ead0dd 100644
--- a/android/cli/src/main/kotlin/cicada/cli/Tests.kt
+++ b/android/cli/src/main/kotlin/cicada/cli/Tests.kt
@@ -313,15 +313,16 @@ object Tests {
val md = TranscriptExport.markdown(s)
check(md.contains("**[00:10] 说话人 1** \nwe should ship it now\n> 我们现在就该发布\n"), "markdown speaker number")
check(md.contains("**[00:15] Ken**"), "markdown speaker name")
- check(md.contains("**[01:01] 你** \n好的\n> OK\n"), "markdown me")
+ check(md.contains("**[01:01] 你 · 同传** \n好的\n> OK\n"), "markdown me: 同传")
val srt = TranscriptExport.srt(s)
check(srt.startsWith("1\n00:00:10,000 --> 00:00:15,000\nwe should ship it now\n我们现在就该发布\n\n2\n"), "srt cue")
- check(srt.contains("11\n00:01:01,000 --> 00:01:05,000\n好的\nOK\n"), "srt last cue ends 4 s on")
+ check(srt.contains("11\n00:01:01,000 --> 00:01:05,000\n[同传] 好的\nOK\n"), "srt last cue ends 4 s on, my line marked 同传")
val docx = TranscriptExport.docx(s)
val names = java.util.zip.ZipInputStream(docx.inputStream()).use { z -> generateSequence { z.nextEntry?.name }.toList() }
equal(listOf("[Content_Types].xml", "_rels/.rels", "word/document.xml"), names, "docx parts")
val doc = java.util.zip.ZipInputStream(docx.inputStream()).use { z -> while (z.nextEntry?.name != "word/document.xml") {}; z.readBytes().toString(Charsets.UTF_8) }
check(doc.contains(">[00:15] Ken<") && doc.contains(">我们现在就该发布<"), "docx text")
+ check(doc.contains(">[01:01] 你 · 同传<"), "docx me: 同传")
SpeakerLabels.voices = false
check(TranscriptExport.markdown(s).contains("**[00:15] 对方**"), "说话人识别 off: no numbers")
SpeakerLabels.voices = true
diff --git a/android/core/src/main/kotlin/cicada/Export.kt b/android/core/src/main/kotlin/cicada/Export.kt
index ed4b04e..f6b8bd1 100644
--- a/android/core/src/main/kotlin/cicada/Export.kt
+++ b/android/core/src/main/kotlin/cicada/Export.kt
@@ -66,9 +66,10 @@ object SpeakerLabels {
fun label(number: Int, names: Map<Int, String>): String = names[number] ?: Strings.LF("说话人 %lld", number)
- /// Who said a line: 你, a speaker's name or number, else 对方 (未识别 once others have numbers).
+ /// Who said a line: 你 · 同传 (said with 我说, so the other side heard its translation), a
+ /// speaker's name or number, else 对方 (未识别 once others have numbers).
fun speakerName(l: TranscriptLine, numbers: Map<String, Int>, names: Map<Int, String>): String {
- if (l.speaker == "me") return Strings.L("你")
+ if (l.speaker == "me") return Strings.L("你 · 同传")
numbers[l.id]?.let { return label(it, names) }
return if (numbers.isEmpty()) Strings.L("对方") else Strings.L("未识别")
}
@@ -127,7 +128,9 @@ object TranscriptExport {
s.lines.forEachIndexed { i, l ->
val next = if (i + 1 < s.lines.size) s.lines[i + 1].t else l.t + 4
val end = maxOf(l.t + 1, minOf(next, l.t + 8))
- b.append("${i + 1}\n${ts(l.t)} --> ${ts(end)}\n${l.src}\n")
+ // Your own lines (我说) say so, as the record does.
+ val tag = if (l.speaker == "me") "[${Strings.L("同传")}] " else ""
+ b.append("${i + 1}\n${ts(l.t)} --> ${ts(end)}\n$tag${l.src}\n")
l.dst?.takeIf { it != l.src && it.isNotEmpty() }?.let { b.append("$it\n") }
b.append("\n")
}