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): quiet speech in a meeting is no longer mistaken for a fan or hum and left without subtitles

wquguru0a14926ec6ab
diff --git a/android/cli/src/main/kotlin/cicada/cli/Tests.kt b/android/cli/src/main/kotlin/cicada/cli/Tests.kt
index d6ab2e4..42d5bc6 100644
--- a/android/cli/src/main/kotlin/cicada/cli/Tests.kt
+++ b/android/cli/src/main/kotlin/cicada/cli/Tests.kt
@@ -439,6 +439,7 @@ object Tests {
equal(0, cut(tone(3.0, 0.002)).size, "below the gate is silence")
equal(0, cut(tone(3.0, 0.02, syllables = false), silence(1.0)).size, "a steady hum over the gate is not speech")
equal(1, cut(tone(3.0), silence(1.0)).size, "speech, which rises and falls, is")
+ equal(1, cut(tone(3.0, 0.03), silence(1.0)).size, "quiet speech, whose dips fall below the gate, is too")
}
fun wavRoundTrip() {
diff --git a/android/core/src/main/kotlin/cicada/Segmenter.kt b/android/core/src/main/kotlin/cicada/Segmenter.kt
index b631f9c..455769c 100644
--- a/android/core/src/main/kotlin/cicada/Segmenter.kt
+++ b/android/core/src/main/kotlin/cicada/Segmenter.kt
@@ -20,7 +20,7 @@ class Segmenter {
@Volatile var pause = 0.6
@Volatile var maxLength = 8.0
@Volatile var minSpeech = 0.25
- @Volatile var steady = 2.0 // loud frames' 90th / 10th percentile below this: not speech
+ @Volatile var steady = 2.0 // frames' 90th / 10th percentile below this: not speech
private const val PRE_ROLL = 0.15
private const val TAIL = 0.15
private const val CUT_WINDOW = 2.0
@@ -84,14 +84,18 @@ class Segmenter {
}
}
- /// Steady sound just over the gate (a fan, hum, hiss) isn't speech: its loud frames barely vary
+ /// Steady sound just over the gate (a fan, hum, hiss) isn't speech: its frames barely vary
/// (90th / 10th percentile about 1.1; speech, even over such a floor, 3 and up). Given one, Ming
/// writes a stock sentence in the hint's language ("I'm going to show you a couple of things").
- /// Speech buried under steady noise goes too; system audio rarely carries it.
+ /// Speech buried under steady noise goes too; system audio rarely carries it. Every frame from
+ /// the first loud one to the last counts, the quiet ones held at the gate: counting only the
+ /// loud ones dropped quiet speech (under about -30 dBFS), whose dips fall below the gate.
internal fun isSteady(frameLevels: List<Double>): Boolean {
- val loud = frameLevels.filter { it >= threshold }.sorted()
- if (loud.size < 2) return false
- return loud[(0.9 * (loud.size - 1)).toInt()] < steady * loud[(0.1 * (loud.size - 1)).toInt()]
+ val first = frameLevels.indexOfFirst { it >= threshold }
+ val last = frameLevels.indexOfLast { it >= threshold }
+ if (first < 0 || last <= first) return false
+ val body = frameLevels.subList(first, last + 1).map { maxOf(it, threshold) }.sorted()
+ return body[(0.9 * (body.size - 1)).toInt()] < steady * body[(0.1 * (body.size - 1)).toInt()]
}
/// Emits `current[0 until end]` and keeps what follows as the start of the next segment.