知了 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
refactor: a confirmed language stays confirmed when only one model answers a check
wquguru62d405a9ec97
diff --git a/Sources/Cicada/LanguageDetector.swift b/Sources/Cicada/LanguageDetector.swiftindex 4348137..c0c176c 100644--- a/Sources/Cicada/LanguageDetector.swift+++ b/Sources/Cicada/LanguageDetector.swift@@ -175,8 +175,10 @@ struct LanguageDetection {if ranked.count == 1 {// The right model is ≥0.85 sure; English heard by a French model scored 0.12.guard best.lang == active, best.confidence >= 0.6, best.score >= 0.6 else {- // Asked again only by the usual triggers (a pause, 20 s more speech), or when a model- // arrives. One model is checked only while unsure, so this never takes back a confirmation.+ // A confirmed language stands: one answer while confirmed is a check whose other+ // models failed (`rank` drops them), not the one model there is saying no.+ if confirmed { return .none }+ // Asked again only by the usual triggers (a pause, 20 s more speech), or when a model arrives.let first = !mismatchverdict = .notThisreturn .notThis(best.lang, firstTime: first)diff --git a/Tests/CicadaTests/StateMachineTests.swift b/Tests/CicadaTests/StateMachineTests.swiftindex d659538..fb1f6de 100644--- a/Tests/CicadaTests/StateMachineTests.swift+++ b/Tests/CicadaTests/StateMachineTests.swift@@ -80,6 +80,9 @@ import Testingvar e = LanguageDetection()_ = e.apply([c(english, 0.12)], active: english)#expect(e.apply([c(english, 0.9)], active: english) == .confirmed(english))+ // Confirmed, a check where only one model answered doesn't take the language back.+ #expect(e.apply([c(english, 0.12)], active: english) == .none)+ #expect(e.confirmed)}@Test func twoCloseCallsLetLinesBeKept() {