Skip to content

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

perf(asr): run final transcription off the main actor

altic-dev761f2c8c57cf
diff --git a/Sources/Fluid/Services/ASRService.swift b/Sources/Fluid/Services/ASRService.swift
index 0d8d4059..be0f970e 100644
--- a/Sources/Fluid/Services/ASRService.swift
+++ b/Sources/Fluid/Services/ASRService.swift
@@ -2968,12 +2968,17 @@ final class ASRService: ObservableObject {
}
defer { delayedFinalStatusTask.cancel() }
result = try await self.transcriptionExecutor.run(benchmarkSessionID: self.benchmarkSessionID) { [provider] in
- let executionStartedAt = ProcessInfo.processInfo.systemUptime
- DebugLogger.shared.debug("ASR_BENCH t=\(executionStartedAt) final_executor_begin mainThread=\(Thread.isMainThread)", source: "ASRBenchmark")
- defer {
- DebugLogger.shared.debug("ASR_BENCH t=\(ProcessInfo.processInfo.systemUptime) final_executor_end", source: "ASRBenchmark")
- }
- return try await provider.transcribeFinal(pcm)
+ // The executor closure inherits main-actor isolation, so inference
+ // and every await hop would otherwise run on or wait for the main
+ // thread. Detach so the UI stays responsive during final ASR.
+ try await Task.detached(priority: .userInitiated) {
+ let executionStartedAt = ProcessInfo.processInfo.systemUptime
+ DebugLogger.shared.debug("ASR_BENCH t=\(executionStartedAt) final_executor_begin mainThread=\(Thread.isMainThread)", source: "ASRBenchmark")
+ defer {
+ DebugLogger.shared.debug("ASR_BENCH t=\(ProcessInfo.processInfo.systemUptime) final_executor_end", source: "ASRBenchmark")
+ }
+ return try await provider.transcribeFinal(pcm)
+ }.value
}
delayedFinalStatusTask.cancel()
self.publishStoppedState(for: stoppingSessionID)