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(android): imported recordings and videos show who said each line

wquguruc6ece7cdc8dd
diff --git a/android/app/src/main/kotlin/com/wquguru/cicada/RecordsActivity.kt b/android/app/src/main/kotlin/com/wquguru/cicada/RecordsActivity.kt
index 0f2b612..434cecd 100644
--- a/android/app/src/main/kotlin/com/wquguru/cicada/RecordsActivity.kt
+++ b/android/app/src/main/kotlin/com/wquguru/cicada/RecordsActivity.kt
@@ -320,7 +320,8 @@ class RecordActivity : Activity() {
// The last lines end above the floating player, but scroll under it.
list.setPadding(0, 0, 0, ui.dp(if (playable) 124 else 40))
val lines = if (tab == 1) app.store.lines(id) else emptyList()
- adapter.show(lines, SpeakerLabels.numbers(lines), SpeakerLabels.names(s), s.sourceFile == null, playable)
+ val numbers = SpeakerLabels.numbers(lines)
+ adapter.show(lines, numbers, SpeakerLabels.names(s), SpeakerLabels.saysWho(s, numbers), playable)
updatePlayer()
}
diff --git a/android/core/src/main/kotlin/cicada/Export.kt b/android/core/src/main/kotlin/cicada/Export.kt
index ad69df0..6980a77 100644
--- a/android/core/src/main/kotlin/cicada/Export.kt
+++ b/android/core/src/main/kotlin/cicada/Export.kt
@@ -84,6 +84,10 @@ object SpeakerLabels {
return n
}
+ /// Whether lines say who spoke. An imported file has no "other side" to call 对方: its lines
+ /// are named only once its voices are told apart.
+ fun saysWho(s: Session, numbers: Map<String, Int>): Boolean = s.sourceFile == null || numbers.isNotEmpty()
+
/// 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 {
@@ -128,8 +132,7 @@ object TranscriptExport {
if (notes.isNotEmpty()) b.append(notes).append("## ${Strings.L("文字记录")}\n\n")
val numbers = SpeakerLabels.numbers(s.lines); val names = SpeakerLabels.names(s)
for (l in s.lines) {
- // An imported file has no "other side" to name.
- val who = if (s.sourceFile == null) " ${SpeakerLabels.speakerName(l, numbers, names)}" else ""
+ val who = if (SpeakerLabels.saysWho(s, numbers)) " ${SpeakerLabels.speakerName(l, numbers, names)}" else ""
b.append("**[${Languages.clock(l.t)}]$who** \n${l.shown}\n")
l.dst?.takeIf { it != l.shown && it.isNotEmpty() }?.let { b.append("> $it\n") }
b.append("\n")
@@ -187,7 +190,7 @@ object TranscriptExport {
}
val numbers = SpeakerLabels.numbers(s.lines); val names = SpeakerLabels.names(s)
for (l in s.lines) {
- add("[${Languages.clock(l.t)}]" + if (s.sourceFile == null) " ${SpeakerLabels.speakerName(l, numbers, names)}" else "", 9.0, bold = true, color = "555555", after = 2.0)
+ add("[${Languages.clock(l.t)}]" + if (SpeakerLabels.saysWho(s, numbers)) " ${SpeakerLabels.speakerName(l, numbers, names)}" else "", 9.0, bold = true, color = "555555", after = 2.0)
add(l.shown, 11.0, after = 2.0)
l.dst?.takeIf { it != l.shown && it.isNotEmpty() }?.let { add(it, 11.0, color = "4D4D4D", after = 10.0) }
}