知了 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(mic): open the microphone on start only when asked, once per meeting
wquguru3cbe4ae056bb
diff --git a/Sources/Cicada/AppModel.swift b/Sources/Cicada/AppModel.swiftindex 6b4e03f..f77d24b 100644--- a/Sources/Cicada/AppModel.swift+++ b/Sources/Cicada/AppModel.swift@@ -182,6 +182,8 @@ final class AppModel: ObservableObject {private var speakerSetting: AnyCancellable?private var speakerMemorySetting: AnyCancellable?private var handsFreeSetting: AnyCancellable?+ /// 开始听时打开麦克风 already opened it for this meeting's call.+ private var micAutoOpened = falsevar openOnboarding: (() -> Void)?var openMainWindow: (() -> Void)?@@ -729,10 +731,12 @@ final class AppModel: ObservableObject {/// listening began. Starting by itself (launch, a meeting app's call) waits for the first words.func start(byUser: Bool = false) {guard !listen.isRunning else { return }- // Starting by hand means the meeting is here now: open the room microphone too, unless- // this Mac is only ever used for online meetings (设置 › 通用). Launch still stays silent.+ // Starting by hand means the meeting is here now: open the room microphone too, when the+ // user turned on 开始听时打开麦克风 (设置 › 通用). Launch still stays silent.+ micAutoOpened = falseif byUser, settings.autoMicOnStart, settings.listenSource == "system" {settings.listenSource = Recognition.legacy ? "room" : "both"+ micAutoOpened = truedebugLog("mic auto-on: user started listening")}let session = store.begin()@@ -1347,7 +1351,9 @@ final class AppModel: ObservableObject {// A meeting app call started while we were already listening to the Mac only: add the// room microphone, or the user's own voice is missing from the record (Tencent Meeting,// Zoom, …). 启动时 launch() still starts without the microphone; this is the call signal.- if settings.autoMicOnStart, settings.listenSource == "system", !calls.isEmpty {+ // Once a meeting: closing the microphone by hand during the call must stay closed.+ if settings.autoMicOnStart, !micAutoOpened, settings.listenSource == "system", !calls.isEmpty {+ micAutoOpened = truedebugLog("mic auto-on: a meeting app started a call")setMic(true)}@@ -1530,7 +1536,7 @@ final class AppModel: ObservableObject {}let alert = NSAlert()alert.messageText = L("记住“\(chosen)”的声音?")- alert.informativeText = L("声纹只保存在这台 Mac,用于以后会议自动认出这个人;可以随时在声纹库里删除。")+ alert.informativeText = L("请先确认对方知道。声纹只保存在这台 Mac,用于以后会议认出这个人,可随时在声纹库里删除。")alert.addButton(withTitle: L("记住"))alert.addButton(withTitle: L("不用"))guard alert.runModal() == .alertFirstButtonReturn else { return }diff --git a/Sources/Cicada/Settings.swift b/Sources/Cicada/Settings.swiftindex a3b50a0..a850c0e 100644--- a/Sources/Cicada/Settings.swift+++ b/Sources/Cicada/Settings.swift@@ -258,8 +258,9 @@ final class AppSettings: ObservableObject {@Published var listenSource: String {didSet { save() }}- /// 开始听时打开麦克风: a user-started meeting hears the room as well as the Mac. Off for- /// online-only meetings; launch still never opens the microphone by itself.+ /// 开始听时打开麦克风: a user-started meeting, or a meeting app's call, also opens the room+ /// microphone, once per meeting. Off by default: an open mic pauses 不用按键 and hears the+ /// speakers. Launch never opens the microphone by itself.@Published var autoMicOnStart: Bool {didSet { save() }}@@ -287,7 +288,7 @@ final class AppSettings: ObservableObject {sourceMode = .auto}target = defaults.string(forKey: "target") ?? "system"- subtitles = defaults.string(forKey: "subtitles") ?? "original"+ subtitles = defaults.string(forKey: "subtitles") ?? "both"notesLanguage = defaults.string(forKey: "notesLanguage") ?? "mine"speakEnabled = defaults.bool(forKey: "speakEnabled")// Anyone who had it on before this question existed already knows.@@ -329,7 +330,7 @@ final class AppSettings: ObservableObject {silenceEnd = defaults.string(forKey: "silenceEnd") ?? "prompt"silenceMinutes = defaults.object(forKey: "silenceMinutes") as? Double ?? 10listenSource = ["room", "both"].contains(defaults.string(forKey: "listenSource")) ? defaults.string(forKey: "listenSource")! : "system"- autoMicOnStart = defaults.object(forKey: "autoMicOnStart") as? Bool ?? true+ autoMicOnStart = defaults.bool(forKey: "autoMicOnStart")roomMicUID = defaults.string(forKey: "roomMicUID") ?? ""diagnostics = defaults.object(forKey: "diagnostics") as? Bool ?? DevBuild.isDevnotesCapturable = defaults.bool(forKey: "notesCapturable")