mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-24 21:21:14 +00:00
* feat(macos): honor the selected microphone in Talk and surface live level, transcript, and mic picker in chat * chore(i18n): translate new talk activity strings and regenerate Apple/Android catalogs
38 lines
978 B
Swift
38 lines
978 B
Swift
import Observation
|
|
import OpenClawChatUI
|
|
|
|
@MainActor
|
|
@Observable
|
|
final class MacChatAudioInputCatalog {
|
|
private(set) var devices: [AudioInputDeviceDescriptor] = []
|
|
|
|
@ObservationIgnored private let observer = AudioInputDeviceObserver()
|
|
|
|
func start() {
|
|
self.refresh()
|
|
self.observer.start { [weak self] in
|
|
Task { @MainActor in
|
|
self?.refresh()
|
|
}
|
|
}
|
|
}
|
|
|
|
func stop() {
|
|
self.observer.stop()
|
|
}
|
|
|
|
func select(_ deviceID: String?, state: AppState) {
|
|
let selectedID = deviceID ?? ""
|
|
state.voiceWakeMicID = selectedID
|
|
state.voiceWakeMicName = self.devices.first(where: { $0.uid == selectedID })?.name ?? ""
|
|
}
|
|
|
|
var chatDevices: [OpenClawChatAudioInputDevice] {
|
|
self.devices.map { OpenClawChatAudioInputDevice(id: $0.uid, name: $0.name) }
|
|
}
|
|
|
|
private func refresh() {
|
|
self.devices = AudioInputDeviceObserver.availableInputDevices()
|
|
}
|
|
}
|