知了 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: the microphone menus no longer list the speakers or a VPAUAggregateAudioDevice while echo cancellation runs
wquguru07ed4c052ec2
diff --git a/Sources/Cicada/SystemMic.swift b/Sources/Cicada/SystemMic.swiftindex 38bc4d8..d87c329 100644--- a/Sources/Cicada/SystemMic.swift+++ b/Sources/Cicada/SystemMic.swift@@ -4,7 +4,43 @@ import Foundation/// Input side of `AudioDevices`: the devices that can record, and the system default input.extension AudioDevices {- static func inputs() -> [OutputDevice] { devices(scope: kAudioObjectPropertyScopeInput) }+ /// The microphones, without what macOS adds while an echo-cancelling unit runs here.+ static func inputs() -> [OutputDevice] {+ devices(scope: kAudioObjectPropertyScopeInput).filter {+ !$0.uid.hasPrefix("VPAUAggregateAudioDevice") && !isEchoReference($0.id)+ }+ }++ /// While this process holds an echo-cancelling unit (同声传译, 记录我的发言), macOS gives the speakers+ /// an input of their own (what they play, for the canceller to subtract) and lists a private+ /// aggregate: neither hears the room, and the speakers would sit in the menu as a microphone.+ /// That input is on the output the canceller plays to and has no terminal type; a real+ /// microphone's says it is one.+ static func isEchoReference(_ device: AudioObjectID) -> Bool {+ // A headset is one device for its mic and its earpiece: its mic stays, whatever it reports.+ let t = transport(device)+ guard device == SystemAudioTap.defaultOutputDevice(),+ t != kAudioDeviceTransportTypeBluetooth, t != kAudioDeviceTransportTypeBluetoothLE else { return false }+ func streams(_ scope: AudioObjectPropertyScope) -> [AudioStreamID] {+ var addr = AudioObjectPropertyAddress(mSelector: kAudioDevicePropertyStreams, mScope: scope,+ mElement: kAudioObjectPropertyElementMain)+ var size: UInt32 = 0+ guard AudioObjectGetPropertyDataSize(device, &addr, 0, nil, &size) == noErr, size > 0 else { return [] }+ var ids = [AudioStreamID](repeating: 0, count: Int(size) / MemoryLayout<AudioStreamID>.size)+ guard AudioObjectGetPropertyData(device, &addr, 0, nil, &size, &ids) == noErr else { return [] }+ return ids+ }+ let inputs = streams(kAudioObjectPropertyScopeInput)+ guard !inputs.isEmpty, !streams(kAudioObjectPropertyScopeOutput).isEmpty else { return false }+ return inputs.allSatisfy { id in+ var type: UInt32 = 0+ var size = UInt32(MemoryLayout<UInt32>.size)+ var addr = AudioObjectPropertyAddress(mSelector: kAudioStreamPropertyTerminalType,+ mScope: kAudioObjectPropertyScopeGlobal, mElement: kAudioObjectPropertyElementMain)+ AudioObjectGetPropertyData(id, &addr, 0, nil, &size, &type)+ return type == kAudioStreamTerminalTypeUnknown+ }+ }static var defaultInput: OutputDevice? {var id = AudioObjectID(0)diff --git a/site/changelog.json b/site/changelog.jsonindex 7cf118e..2aa994c 100644--- a/site/changelog.json+++ b/site/changelog.json@@ -22,6 +22,14 @@"title": "同声传译的“按住说话”键可以自己换,没有右 Ctrl 的键盘也能用。","text": "在“设置 › 同声传译”里点“按住说话”旁的“更改”,按一下左 Ctrl、右 Shift、Caps Lock 或 F 键就能换上。打字键、Windows 键和 Alt 不能选,会说明原因。Ctrl 和 Shift 只有单独按住才触发,不影响 Ctrl C 这类快捷键。"},+ {+ "kind": "fixed",+ "platforms": [+ "mac"+ ],+ "title": "麦克风列表里不再出现扬声器和“VPAUAggregateAudioDevice”。",+ "text": "以前开着同声传译的回声消除时,“设置 › 同声传译”的麦克风列表里会多出“MacBook Pro 扬声器”和一个叫 VPAUAggregateAudioDevice 的设备,选了它们什么也听不到。现在只列真正的麦克风,“打开麦克风”旁的新菜单也一样。"+ },{"kind": "fixed","platforms": [