知了 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: while a meeting is listened to, the talk key hears you from the moment you press it and no longer sends the meeting's own words
wquguru872a570659d2
diff --git a/Sources/Cicada/AppModel.swift b/Sources/Cicada/AppModel.swiftindex 8ca9932..ed0d962 100644--- a/Sources/Cicada/AppModel.swift+++ b/Sources/Cicada/AppModel.swift@@ -247,6 +247,7 @@ final class AppModel: ObservableObject {MainActor.assumeIsolated {guard let self else { return }self.speak.handsFree = on && self.settings.speakEnabled && !self.settings.hearsRoom && self.running+ self.speak.keepUnit = self.settings.speakEnabled && self.runningself.speak.refreshHandsFree()}}diff --git a/Sources/Cicada/SpeakEngine.swift b/Sources/Cicada/SpeakEngine.swiftindex baad383..e7caa02 100644--- a/Sources/Cicada/SpeakEngine.swift+++ b/Sources/Cicada/SpeakEngine.swift@@ -104,11 +104,7 @@ final class SpeakEngine {let settings: AppSettingsprivate(set) var phase: Phase = .idle {didSet {- // The press's echo-cancelling unit is kept until its sentence has gone out, not let go of- // at key-up: a press while that sentence still plays reuses it instead of remaking the- // voice output under it. Idle, it would silence the mic for every other app (the room's- // and hands-free's own use keeps it).- if phase == .idle, !voiceMic.inUse { voiceMic.release() }+ if phase == .idle { unitIdle() }// Hands-free: a sentence said while the last one was translated waits its turn.if handsFree, phase == .idle || phase == .speaking, !segments.isEmpty {DispatchQueue.main.async { [weak self] in MainActor.assumeIsolated { self?.nextSegment() } }@@ -243,7 +239,7 @@ final class SpeakEngine {guard let self else { return }// Stopped while it was being made: nobody else may be left to give it back.guard self.handsFreeInput == d else {- if self.phase == .idle, !self.voiceMic.inUse { self.voiceMic.release() }+ if self.phase == .idle { self.unitIdle() }return}let queue = self.micQueue@@ -264,8 +260,7 @@ final class SpeakEngine {micQueue.sync { detector.reset(); segment = nil; recent = []; recentSeconds = 0 }// The talk key's unit keeps the meeting at its level again (made anew once nobody uses it).voiceMic.advancedDucking = false- // Not kept for the next press: while it exists every other app's mic hears almost nothing (#24).- if phase == .idle, !voiceMic.inUse { voiceMic.release() }+ if phase == .idle { unitIdle() }debugLog("hands-free: stopped")}@@ -405,6 +400,20 @@ final class SpeakEngine {}}+ /// While a meeting is listened to with 同声传译 on, the echo-cancelling unit is made ahead and+ /// kept between presses. Made at each press, a press lost its first ~1.4 s and the fresh unit let+ /// the meeting from the speakers through as what I said: a press nobody spoke in sent the meeting+ /// back into it (audio-test, meeting at 56 %: 1.8.0 100 % and 0 sent; made per press 14–87 % and+ /// 2 of 3 silent presses sent). The meeting app hears the virtual mic then, so the built-in mic+ /// it mutes for other apps (#24) matters only outside a meeting, when it is let go of.+ var keepUnit = false {+ didSet { if keepUnit != oldValue, phase == .idle { unitIdle() } }+ }++ private func unitIdle() {+ if keepUnit, echoCancel, let d = echoInput { voiceMic.prepare(input: d) } else if !voiceMic.inUse { voiceMic.release() }+ }+func teardownAnalyzer() async {if let input = utterance?.input { Task { await input.cancel() } }utterance = nil@@ -560,7 +569,7 @@ final class SpeakEngine {private func attachPress(_ press: Date, ok: Bool, device: AudioObjectID, format: AVAudioFormat, input cont: RecognitionStream) {// The key was let go of before the unit was ready: the phase going idle found nothing to give back.guard phase == .listening, pressStarted == press, utterance?.input === cont else {- if phase == .idle, !voiceMic.inUse { voiceMic.release() }+ if phase == .idle { unitIdle() }return}let conv = converter