Fastest and only macOS Dictation app with on-device STT and custom trained AI enhancement model. Windows, iOS testflight! Android, Linux waitlist open! A local Wispr Flow alternative. Follow https://x.com/fluidvoiceapp for more
centralize microhpone input irrespective of audio pipeline
grohith327cb92c52d3962
diff --git a/Sources/Fluid/Services/ASRService.swift b/Sources/Fluid/Services/ASRService.swiftindex c711aef4..08e08e19 100644--- a/Sources/Fluid/Services/ASRService.swift+++ b/Sources/Fluid/Services/ASRService.swift@@ -728,14 +728,7 @@ final class ASRService: ObservableObject {}private func resolvedInputDeviceForCapture() -> AudioDevice.Device? {- if SettingsStore.shared.microphoneSelectionMode == .manual,- let preferredUID = SettingsStore.shared.preferredInputDeviceUID,- preferredUID.isEmpty == false,- let preferredDevice = AudioDevice.getInputDevice(byUID: preferredUID)- {- return preferredDevice- }- return AudioDevice.getDefaultInputDevice()+ AppServices.shared.microphonePreferenceCoordinator.inputDeviceForCapture()}/// Prepares the direct device callback without starting hardware IO. This@@ -1909,10 +1902,34 @@ final class ASRService: ObservableObject {private func bindPreferredInputDeviceIfNeeded() -> Bool {DebugLogger.shared.debug("bindPreferredInputDeviceIfNeeded() - Starting input device binding", source: "ASRService")- DebugLogger.shared.info(- "Using current macOS default input device. Manual microphone mode reasserts the preferred device before engine start.",+ guard SettingsStore.shared.microphoneSelectionMode == .manual else {+ DebugLogger.shared.info("Using current macOS default input device", source: "ASRService")+ return true+ }++ guard let device = self.resolvedInputDeviceForCapture() else {+ DebugLogger.shared.error(+ "No input device available for manual microphone capture.",+ source: "ASRService"+ )+ return false+ }++ DebugLogger.shared.debug(+ "Attempting to bind AVAudioEngine input to capture device '\(device.name)' (uid: \(device.uid))",source: "ASRService")++ let ok = self.setEngineInputDevice(deviceID: device.id, deviceUID: device.uid, deviceName: device.name)+ if ok == false {+ DebugLogger.shared.warning(+ "Failed to bind engine input to '\(device.name)' (uid: \(device.uid)). Trying system default input.",+ source: "ASRService"+ )+ return self.tryBindToSystemDefaultInput()+ }++ DebugLogger.shared.info("✅ Bound AVAudioEngine input to '\(device.name)'", source: "ASRService")return true}diff --git a/Sources/Fluid/Services/MicrophonePreferenceCoordinator.swift b/Sources/Fluid/Services/MicrophonePreferenceCoordinator.swiftindex 9ae85a7b..61b67cf7 100644--- a/Sources/Fluid/Services/MicrophonePreferenceCoordinator.swift+++ b/Sources/Fluid/Services/MicrophonePreferenceCoordinator.swift@@ -98,6 +98,18 @@ final class MicrophonePreferenceCoordinator: ObservableObject {return result}+ func inputDeviceForCapture() -> AudioDevice.Device? {+ if self.settings.microphoneSelectionMode == .manual,+ let preferredUID = self.settings.preferredInputDeviceUID,+ preferredUID.isEmpty == false,+ let preferredDevice = self.devices.listInputDevices().first(where: { $0.uid == preferredUID })+ {+ return preferredDevice+ }++ return self.devices.defaultInputDevice()+ }+func stabilizePreferredInputAfterHardwareChange(reason: String) {self.stabilizationTask?.cancel()self.stabilizationTask = Task { [weak self] indiff --git a/Tests/FluidDictationIntegrationTests/HotkeyShortcutTests.swift b/Tests/FluidDictationIntegrationTests/HotkeyShortcutTests.swiftindex be7b2ded..65bd2b5e 100644--- a/Tests/FluidDictationIntegrationTests/HotkeyShortcutTests.swift+++ b/Tests/FluidDictationIntegrationTests/HotkeyShortcutTests.swift@@ -418,6 +418,31 @@ final class HotkeyShortcutTests: XCTestCase {}}+ @MainActor+ func testMicrophoneCoordinatorResolvesManualPreferredInputForCapture() throws {+ try self.withRestoredDefaults(keys: [+ self.microphoneSelectionModeKey,+ self.preferredInputDeviceUIDKey,+ ]) {+ SettingsStore.shared.microphoneSelectionMode = .manual+ SettingsStore.shared.preferredInputDeviceUID = "studio-mic"+ let studioMic = Self.device(uid: "studio-mic", name: "Studio Mic")+ let devices = FakeAudioDeviceManager(+ inputs: [+ Self.device(uid: "internal", name: "MacBook Pro Microphone"),+ studioMic,+ ],+ defaultInputUID: "internal"+ )+ let coordinator = MicrophonePreferenceCoordinator(settings: .shared, devices: devices)++ let resolved = coordinator.inputDeviceForCapture()++ XCTAssertEqual(resolved, studioMic)+ XCTAssertEqual(devices.setInputCalls, [])+ }+ }+private static func device(uid: String, name: String) -> AudioDevice.Device {AudioDevice.Device(id: AudioObjectID(abs(uid.hashValue % 100_000) + 1),