知了 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): a very quiet voice in a meeting is no longer mistaken for a fan or hum and left without subtitles
wqugurubc2ae04adec9
diff --git a/linux/cicada/core/segmenter.py b/linux/cicada/core/segmenter.pyindex a9c7ca6..73c5d0c 100644--- a/linux/cicada/core/segmenter.py+++ b/linux/cicada/core/segmenter.py@@ -36,7 +36,8 @@ class Segmenter:pause = 0.6max_length = 8.0min_speech = 0.25- steady = 2.0 # frames' 90th / 10th percentile below this: not speech+ steady = 2.0 # frames' 90th / 10th percentile below this: not speech…+ dips = 2.5 # …unless the median is this far over the 10th percentile, quiet ones held at gate / 8def __init__(self):self.pending = array("h")@@ -103,12 +104,23 @@ class Segmenter: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. Every frame fromthe 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."""+ loud ones dropped quiet speech (under about -30 dBFS), whose dips fall below the gate.+ A voice so quiet that its loudest frames barely clear the gate (about -38 dBFS: 6 of 6 lines+ lost in testing) still pauses between syllables, its quietest tenth of frames far under its+ median (8 dB and more); noise near the gate stays within about 6 dB of its median. So a flat+ top is steady only when it has no such dips, measured with quiet frames held at gate / 8.+ Very low rumble (brown noise with almost nothing over 20 Hz) can look like that and gets+ through more often than before (about 1 in 3 segments, was 1 in 5); what Ming makes of it+ still meets the hear filter (translator.is_noise)."""loud = [i for i, l in enumerate(levels) if l >= self.threshold]if len(loud) < 2:return False- body = sorted(max(l, self.threshold) for l in levels[loud[0]:loud[-1] + 1])- return body[int(0.9 * (len(body) - 1))] < self.steady * body[int(0.1 * (len(body) - 1))]+ body = levels[loud[0]:loud[-1] + 1]+ top = sorted(max(l, self.threshold) for l in body)+ if top[int(0.9 * (len(top) - 1))] >= self.steady * top[int(0.1 * (len(top) - 1))]:+ return False+ low = sorted(max(l, self.threshold / 8) for l in body)+ return low[int(0.5 * (len(low) - 1))] < self.dips * low[int(0.1 * (len(low) - 1))]def _close(self, end_at: int) -> None:"""Emits current[:end] and keeps what follows as the start of the next segment."""diff --git a/linux/tests/test_core.py b/linux/tests/test_core.pyindex c867dda..9438197 100644--- a/linux/tests/test_core.py+++ b/linux/tests/test_core.py@@ -103,9 +103,11 @@ MAC = """{}"""-def tone(seconds, amp=0.3, syllables=True):- """A 300 Hz tone that swells and fades four times a second like syllables; steady when not."""- env = (lambda i: 0.55 + 0.45 * math.sin(2 * math.pi * 4 * i / 16000)) if syllables else (lambda i: 1.0)+def tone(seconds, amp=0.3, syllables=True, wobble=0.0):+ """A 300 Hz tone that swells and fades four times a second like syllables; steady when not, or+ rising and falling by `wobble` twice a second like a fan."""+ env = (lambda i: 0.55 + 0.45 * math.sin(2 * math.pi * 4 * i / 16000)) if syllables else \+ (lambda i: 1.0 + wobble * math.sin(2 * math.pi * 0.5 * i / 16000))return array("h", (int(math.sin(2 * math.pi * 300 * i / 16000) * env(i) * amp * 32767) for i in range(int(seconds * 16000))))@@ -427,6 +429,10 @@ class Segmenting(Base):self.assertEqual(1, len(cut(tone(3.0), silence(1.0))))# Quiet speech, whose dips fall below the gate, is too.self.assertEqual(1, len(cut(tone(3.0, 0.03), silence(1.0))))+ # A voice whose loudest frames barely clear the gate still dips far between syllables…+ self.assertEqual(1, len(cut(tone(3.0, 0.022), silence(1.0))))+ # …a hum at the gate that slowly rises and falls doesn't.+ self.assertEqual(0, len(cut(tone(4.0, 0.016, syllables=False, wobble=0.3), silence(1.0))))def test_wav_round_trip(self):pcm = tone(0.5)